|
|
@ -12,11 +12,11 @@ const [setup, use] = useInjectionState(() => { |
|
|
|
const hasPermission = (role: Role | ProjectRole, hasRole: boolean, permission: Permission | string) => { |
|
|
|
const hasPermission = (role: Role | ProjectRole, hasRole: boolean, permission: Permission | string) => { |
|
|
|
const rolePermission = rolePermissions[role] |
|
|
|
const rolePermission = rolePermissions[role] |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
if (!hasRole || !rolePermission) return false |
|
|
|
hasRole && |
|
|
|
|
|
|
|
rolePermission && |
|
|
|
if (isString(rolePermission) && rolePermission === '*') return true |
|
|
|
((isString(rolePermission) && rolePermission === '*') || rolePermission[permission as keyof typeof rolePermission]) |
|
|
|
|
|
|
|
) |
|
|
|
return rolePermission[permission as keyof typeof rolePermission] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => { |
|
|
|
const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => { |
|
|
|