updated permission types

This commit is contained in:
Anton Tranelis 2024-10-29 16:19:52 +01:00
parent 6b492db463
commit 03e7a9ca8c
2 changed files with 3 additions and 7 deletions

View File

@ -103,11 +103,11 @@ function usePermissionsManager(initialPermissions: Permission[]): {
p.action === action && p.action === action &&
p.collection === collectionName && p.collection === collectionName &&
( (
(p.role === user?.role && (p.policy === user?.role &&
( (
!item || evaluatePermissions(p.permissions) !item || evaluatePermissions(p.permissions)
)) || )) ||
(p.role == null && (p.policy == null &&
( (
(layer?.public_edit_items || item?.layer?.public_edit_items) && (layer?.public_edit_items || item?.layer?.public_edit_items) &&
(!item || evaluatePermissions(p.permissions)) (!item || evaluatePermissions(p.permissions))
@ -116,13 +116,9 @@ function usePermissionsManager(initialPermissions: Permission[]): {
); );
} }
}, },
// eslint-disable-next-line react-hooks/exhaustive-deps
[permissions, user] [permissions, user]
); );
return { permissions, setPermissionApi, setPermissionData, setAdminRole, hasUserPermission }; return { permissions, setPermissionApi, setPermissionData, setAdminRole, hasUserPermission };
} }

View File

@ -158,7 +158,7 @@ export type PermissionCondition = {
export type Permission = { export type Permission = {
id?: string; id?: string;
role: string; policy: string;
collection: string; collection: string;
action: PermissionAction; action: PermissionAction;
permissions?: { // Optional, für spezifische Bedingungen wie `user_created` permissions?: { // Optional, für spezifische Bedingungen wie `user_created`