Browse Source

refactor(nc-gui): return permission check if preview permission found

pull/3703/head
braks 2 years ago
parent
commit
e7ec02c160
  1. 10
      packages/nc-gui/composables/useUIPermission/index.ts

10
packages/nc-gui/composables/useUIPermission/index.ts

@ -40,14 +40,14 @@ export function useUIPermission() {
} }
const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => { const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => {
let hasPreviewPermission = false
if (previewAs.value && !skipPreviewAs) { if (previewAs.value && !skipPreviewAs) {
hasPreviewPermission = hasPermission(previewAs.value, true, permission) const hasPreviewPermission = hasPermission(previewAs.value, true, permission)
if (hasPreviewPermission) return true
} }
return ( return Object.entries(allRoles.value).some(([role, hasRole]) =>
hasPreviewPermission || hasPermission(role as Role | ProjectRole, hasRole, permission),
Object.entries(allRoles.value).some(([role, hasRole]) => hasPermission(role as Role | ProjectRole, hasRole, permission))
) )
} }

Loading…
Cancel
Save