mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 23:46:28 +00:00
Apply RBAC permissions across admin and tasks
Enforce page access and action-level permissions across admin and task views, including exports and record actions. Move user creation to a client component behind server-side permission checks, standardize data fetching, and remove the deprecated user-role route.
This commit is contained in:
@@ -17,9 +17,10 @@ import { type IRole } from './type';
|
||||
|
||||
type Props = {
|
||||
data: IRole[];
|
||||
actions?: string[];
|
||||
};
|
||||
|
||||
const ComponentRolePage: FC<Props> = ({ data }) => {
|
||||
const ComponentRolePage: FC<Props> = ({ data, actions }) => {
|
||||
const [filterData, setFilterData] = useState<IRole[]>([]);
|
||||
const [searchText, setSearchText] = useState('');
|
||||
|
||||
@@ -140,7 +141,7 @@ const ComponentRolePage: FC<Props> = ({ data }) => {
|
||||
key: 'action',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
render: (_, record) => (
|
||||
render: (_, record) => (actions?.includes('UPDATE') || actions?.includes('EDIT') || actions?.includes('DELETE')) && (
|
||||
<AlertDialog>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
@@ -155,16 +156,20 @@ const ComponentRolePage: FC<Props> = ({ data }) => {
|
||||
View Details
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/admin/rbac/user-role/edit/${record.id}`}>
|
||||
Edit Role
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<AlertDialogTrigger asChild>
|
||||
<DropdownMenuItem className="text-rose-600 dark:text-rose-400">
|
||||
Delete Role
|
||||
{(actions.includes('UPDATE') || actions.includes('EDIT')) && (
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/admin/rbac/user-role/edit/${record.id}`}>
|
||||
Edit Role
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
</AlertDialogTrigger>
|
||||
)}
|
||||
{(actions.includes('DELETE')) && (
|
||||
<AlertDialogTrigger asChild>
|
||||
<DropdownMenuItem className="text-rose-600 dark:text-rose-400">
|
||||
Delete Role
|
||||
</DropdownMenuItem>
|
||||
</AlertDialogTrigger>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<ConfirmAsync
|
||||
@@ -204,16 +209,18 @@ const ComponentRolePage: FC<Props> = ({ data }) => {
|
||||
onChange={handleSearch}
|
||||
/>
|
||||
</div>
|
||||
<Link href="/admin/rbac/user-role/create">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="h-8 text-his hover:text-his hover:bg-his/10 font-semibold"
|
||||
>
|
||||
<PlusCircledIcon className="mr-2 h-4 w-4" />
|
||||
Create Role
|
||||
</Button>
|
||||
</Link>
|
||||
{(actions?.includes('CREATE')) && (
|
||||
<Link href="/admin/rbac/user-role/create">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="h-8 text-his hover:text-his hover:bg-his/10 font-semibold"
|
||||
>
|
||||
<PlusCircledIcon className="mr-2 h-4 w-4" />
|
||||
Create Role
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Table
|
||||
|
||||
Reference in New Issue
Block a user