rights system
This commit is contained in:
@@ -188,10 +188,10 @@ function PermissionMatrixTab() {
|
||||
onError: () => showError('Fehler beim Aktualisieren des Wartungsmodus'),
|
||||
});
|
||||
|
||||
// ── Permission save (saves full group permissions) ──
|
||||
// ── Permission save (bulk — single request for all affected groups) ──
|
||||
const permissionMutation = useMutation({
|
||||
mutationFn: (updates: { group: string; permissions: string[] }[]) =>
|
||||
Promise.all(updates.map(u => permissionsApi.setGroupPermissions(u.group, u.permissions))),
|
||||
permissionsApi.setBulkPermissions(updates),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-permission-matrix'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['my-permissions'] });
|
||||
@@ -576,16 +576,28 @@ function PermissionMatrixTab() {
|
||||
</TableCell>
|
||||
{nonAdminGroups.map(g => {
|
||||
const isGranted = (grants[g] || []).includes(perm.id);
|
||||
// Check if this perm is required by another granted perm (dependency lock)
|
||||
const groupGrants = grants[g] || [];
|
||||
const dependents = REVERSE_DEPS[perm.id] || [];
|
||||
const isRequiredByOther = isGranted && dependents.some(d => groupGrants.includes(d));
|
||||
return (
|
||||
<TableCell key={g} align="center" sx={{ minWidth: 120 }}>
|
||||
<Checkbox
|
||||
checked={isGranted}
|
||||
onChange={() =>
|
||||
handlePermissionToggle(g, perm.id, grants, groups)
|
||||
}
|
||||
disabled={permissionMutation.isPending}
|
||||
size="small"
|
||||
/>
|
||||
<Tooltip
|
||||
title={isRequiredByOther ? 'Wird von anderen Berechtigungen benötigt' : ''}
|
||||
placement="top"
|
||||
>
|
||||
<span>
|
||||
<Checkbox
|
||||
checked={isGranted}
|
||||
onChange={() =>
|
||||
handlePermissionToggle(g, perm.id, grants, groups)
|
||||
}
|
||||
disabled={permissionMutation.isPending}
|
||||
size="small"
|
||||
sx={isRequiredByOther ? { color: 'warning.main', '&.Mui-checked': { color: 'warning.main' } } : undefined}
|
||||
/>
|
||||
</span>
|
||||
</Tooltip>
|
||||
</TableCell>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -21,6 +21,10 @@ export const permissionsApi = {
|
||||
await api.put(`/api/permissions/admin/group/${encodeURIComponent(group)}`, { permissions });
|
||||
},
|
||||
|
||||
setBulkPermissions: async (updates: { group: string; permissions: string[] }[]): Promise<void> => {
|
||||
await api.put('/api/permissions/admin/bulk', { updates });
|
||||
},
|
||||
|
||||
setMaintenanceFlag: async (featureGroup: string, active: boolean): Promise<void> => {
|
||||
await api.put(`/api/permissions/admin/maintenance/${encodeURIComponent(featureGroup)}`, { active });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user