From e7ec02c160225689a4eaa16c79542948db531811 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 19 Sep 2022 14:09:33 +0200 Subject: [PATCH] refactor(nc-gui): return permission check if preview permission found --- packages/nc-gui/composables/useUIPermission/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/composables/useUIPermission/index.ts b/packages/nc-gui/composables/useUIPermission/index.ts index 57e014d1c9..57249d1d95 100644 --- a/packages/nc-gui/composables/useUIPermission/index.ts +++ b/packages/nc-gui/composables/useUIPermission/index.ts @@ -40,14 +40,14 @@ export function useUIPermission() { } const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => { - let hasPreviewPermission = false if (previewAs.value && !skipPreviewAs) { - hasPreviewPermission = hasPermission(previewAs.value, true, permission) + const hasPreviewPermission = hasPermission(previewAs.value, true, permission) + + if (hasPreviewPermission) return true } - return ( - hasPreviewPermission || - Object.entries(allRoles.value).some(([role, hasRole]) => hasPermission(role as Role | ProjectRole, hasRole, permission)) + return Object.entries(allRoles.value).some(([role, hasRole]) => + hasPermission(role as Role | ProjectRole, hasRole, permission), ) }