From 95095c67c8f12d8c1d0dd94e1c30b74873361278 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 19 Sep 2022 20:32:17 +0200 Subject: [PATCH] refactor(nc-gui): use shared composable instead of injection state for permissions --- packages/nc-gui/composables/useUIPermission/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/composables/useUIPermission/index.ts b/packages/nc-gui/composables/useUIPermission/index.ts index 9cd73613d6..ffc2e1e83e 100644 --- a/packages/nc-gui/composables/useUIPermission/index.ts +++ b/packages/nc-gui/composables/useUIPermission/index.ts @@ -1,7 +1,7 @@ import { isString } from '@vueuse/core' import type { Permission } from './rolePermissions' import rolePermissions from './rolePermissions' -import { useGlobal, useRoles } from '#imports' +import { createSharedComposable, useGlobal, useRoles } from '#imports' import type { ProjectRole, Role } from '~/lib' const hasPermission = (role: Role | ProjectRole, hasRole: boolean, permission: Permission | string) => { @@ -14,9 +14,8 @@ const hasPermission = (role: Role | ProjectRole, hasRole: boolean, permission: P return rolePermission[permission as keyof typeof rolePermission] } -export function useUIPermission() { +export const useUIPermission = createSharedComposable(() => { const { previewAs } = useGlobal() - const { allRoles } = useRoles() const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => { @@ -32,4 +31,4 @@ export function useUIPermission() { } return { isUIAllowed } -} +})