mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
feat(FE-331): implement permission guard in master data productions standards
This commit is contained in:
@@ -17,6 +17,7 @@ import RowCollapseOptions from '@/components/table/RowCollapseOptions';
|
|||||||
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
|
import RequirePermission from '@/components/helper/RequirePermission';
|
||||||
|
|
||||||
const RowOptionsMenu = ({
|
const RowOptionsMenu = ({
|
||||||
type = 'dropdown',
|
type = 'dropdown',
|
||||||
@@ -29,6 +30,7 @@ const RowOptionsMenu = ({
|
|||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<RowOptionsMenuWrapper type={type}>
|
<RowOptionsMenuWrapper type={type}>
|
||||||
|
<RequirePermission permissions='lti.master.production_standards.detail'>
|
||||||
<Button
|
<Button
|
||||||
href={`/master-data/production-standard/detail/?productionStandardId=${props.row.original.id}`}
|
href={`/master-data/production-standard/detail/?productionStandardId=${props.row.original.id}`}
|
||||||
variant='ghost'
|
variant='ghost'
|
||||||
@@ -38,7 +40,9 @@ const RowOptionsMenu = ({
|
|||||||
<Icon icon='mdi:eye-outline' width={16} height={16} />
|
<Icon icon='mdi:eye-outline' width={16} height={16} />
|
||||||
Detail
|
Detail
|
||||||
</Button>
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
|
|
||||||
|
<RequirePermission permissions='lti.master.production_standards.update'>
|
||||||
<Button
|
<Button
|
||||||
href={`/master-data/production-standard/detail/edit/?productionStandardId=${props.row.original.id}`}
|
href={`/master-data/production-standard/detail/edit/?productionStandardId=${props.row.original.id}`}
|
||||||
variant='ghost'
|
variant='ghost'
|
||||||
@@ -48,7 +52,9 @@ const RowOptionsMenu = ({
|
|||||||
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
|
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
|
||||||
Edit
|
Edit
|
||||||
</Button>
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
|
|
||||||
|
<RequirePermission permissions='lti.master.production_standards.delete'>
|
||||||
<Button
|
<Button
|
||||||
onClick={deleteClickHandler}
|
onClick={deleteClickHandler}
|
||||||
variant='ghost'
|
variant='ghost'
|
||||||
@@ -63,6 +69,7 @@ const RowOptionsMenu = ({
|
|||||||
/>
|
/>
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
</RowOptionsMenuWrapper>
|
</RowOptionsMenuWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -101,10 +108,16 @@ const ProductionStandardTable = () => {
|
|||||||
<>
|
<>
|
||||||
<div className='flex flex-col gap-6 p-6'>
|
<div className='flex flex-col gap-6 p-6'>
|
||||||
<div className='flex flex-row gap-6 justify-start'>
|
<div className='flex flex-row gap-6 justify-start'>
|
||||||
<Button href='/master-data/production-standard/add' variant='outline'>
|
<RequirePermission permissions='lti.master.production_standards.create'>
|
||||||
|
<Button
|
||||||
|
href='/master-data/production-standard/add'
|
||||||
|
variant='outline'
|
||||||
|
>
|
||||||
<Icon icon='mdi:plus' /> Tambah
|
<Icon icon='mdi:plus' /> Tambah
|
||||||
</Button>
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
</div>
|
</div>
|
||||||
|
<RequirePermission permissions='lti.master.production_standards.list'>
|
||||||
<Table<ProductionStandard>
|
<Table<ProductionStandard>
|
||||||
data={
|
data={
|
||||||
isResponseSuccess(productionStandards)
|
isResponseSuccess(productionStandards)
|
||||||
@@ -179,7 +192,9 @@ const ProductionStandardTable = () => {
|
|||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</RequirePermission>
|
||||||
</div>
|
</div>
|
||||||
|
<RequirePermission permissions='lti.master.production_standards.delete'>
|
||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
ref={deleteModal.ref}
|
ref={deleteModal.ref}
|
||||||
type='error'
|
type='error'
|
||||||
@@ -194,6 +209,7 @@ const ProductionStandardTable = () => {
|
|||||||
onClick: confirmationModalDeleteClickHandler,
|
onClick: confirmationModalDeleteClickHandler,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</RequirePermission>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { isResponseError } from '@/lib/api-helper';
|
|||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
||||||
import { useModal } from '@/components/Modal';
|
import { useModal } from '@/components/Modal';
|
||||||
|
import RequirePermission from '@/components/helper/RequirePermission';
|
||||||
|
|
||||||
type TableRowsType = {
|
type TableRowsType = {
|
||||||
customRow: boolean;
|
customRow: boolean;
|
||||||
@@ -1146,6 +1147,7 @@ const ProductionStandardForm = ({
|
|||||||
>
|
>
|
||||||
{formType === 'detail' && (
|
{formType === 'detail' && (
|
||||||
<div className='gap-2 flex items-center'>
|
<div className='gap-2 flex items-center'>
|
||||||
|
<RequirePermission permissions='lti.master.production_standards.update'>
|
||||||
<Button
|
<Button
|
||||||
className='min-w-24'
|
className='min-w-24'
|
||||||
color='warning'
|
color='warning'
|
||||||
@@ -1154,6 +1156,8 @@ const ProductionStandardForm = ({
|
|||||||
<Icon icon='mdi:pencil' />
|
<Icon icon='mdi:pencil' />
|
||||||
Edit
|
Edit
|
||||||
</Button>
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
|
<RequirePermission permissions='lti.master.production_standards.delete'>
|
||||||
<Button
|
<Button
|
||||||
type='button'
|
type='button'
|
||||||
className='min-w-24'
|
className='min-w-24'
|
||||||
@@ -1165,9 +1169,11 @@ const ProductionStandardForm = ({
|
|||||||
<Icon icon='mdi:delete' />
|
<Icon icon='mdi:delete' />
|
||||||
Hapus
|
Hapus
|
||||||
</Button>
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{formType == 'edit' && (
|
{formType == 'edit' && (
|
||||||
|
<RequirePermission permissions='lti.master.production_standards.delete'>
|
||||||
<Button
|
<Button
|
||||||
className='min-w-24'
|
className='min-w-24'
|
||||||
color='error'
|
color='error'
|
||||||
@@ -1179,6 +1185,7 @@ const ProductionStandardForm = ({
|
|||||||
<Icon icon='mdi:delete' />
|
<Icon icon='mdi:delete' />
|
||||||
Hapus
|
Hapus
|
||||||
</Button>
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
)}
|
)}
|
||||||
<div className='gap-2 flex items-center'>
|
<div className='gap-2 flex items-center'>
|
||||||
{formType === 'detail' ? 'Detail' : 'Total'}{' '}
|
{formType === 'detail' ? 'Detail' : 'Total'}{' '}
|
||||||
|
|||||||
@@ -152,4 +152,15 @@ export const ROUTE_PERMISSIONS: Record<string, string[]> = {
|
|||||||
'/master-data/flock/add/': ['lti.master.flocks.create'],
|
'/master-data/flock/add/': ['lti.master.flocks.create'],
|
||||||
'/master-data/flock/detail/': ['lti.master.flocks.detail'],
|
'/master-data/flock/detail/': ['lti.master.flocks.detail'],
|
||||||
'/master-data/flock/detail/edit/': ['lti.master.flocks.update'],
|
'/master-data/flock/detail/edit/': ['lti.master.flocks.update'],
|
||||||
|
|
||||||
|
'/master-data/production-standard/': ['lti.master.production_standards.list'],
|
||||||
|
'/master-data/production-standard/add/': [
|
||||||
|
'lti.master.production_standards.create',
|
||||||
|
],
|
||||||
|
'/master-data/production-standard/detail/': [
|
||||||
|
'lti.master.production_standards.detail',
|
||||||
|
],
|
||||||
|
'/master-data/production-standard/detail/edit/': [
|
||||||
|
'lti.master.production_standards.update',
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user