diff --git a/frontend/src/directives/modules/permission.ts b/frontend/src/directives/modules/permission.ts index 0b67dfb37b75..586e4b88bc5d 100644 --- a/frontend/src/directives/modules/permission.ts +++ b/frontend/src/directives/modules/permission.ts @@ -110,7 +110,6 @@ const applyPermission = (el: HTMLElement, binding: DirectiveBinding { return routePermission ? [routePermission] : []; }; -export const hasManagePermissionAccess = (value?: PermissionBindingValue) => { +const hasPermissionAccessByMode = (mode: PermissionMode, value?: PermissionBindingValue) => { const globalStore = GlobalStore(); if (globalStore.isAdmin || globalStore.isNodeAdmin) { return true; } - const permissions = toPermissionList(value).map(toManagePermission).filter(Boolean); - if (permissions.length === 0) { + const permissions = toPermissionList(value); + const normalizedPermissions = mode === 'manage' ? permissions.map(toManagePermission).filter(Boolean) : permissions; + if (normalizedPermissions.length === 0) { return false; } - return permissions.every((permission) => globalStore.hasPermission(permission)); + return normalizedPermissions.every((permission) => globalStore.hasPermission(permission)); }; -export const hasPermissionAccess = (value?: PermissionBindingValue) => { - const globalStore = GlobalStore(); +export const hasManagePermissionAccess = (value?: PermissionBindingValue) => { + return hasPermissionAccessByMode('manage', value); +}; - if (globalStore.isAdmin || globalStore.isNodeAdmin) { - return true; - } - const permissions = toPermissionList(value); - if (permissions.length === 0) { - return false; - } - return permissions.every((permission) => globalStore.hasPermission(permission)); +export const hasPermissionAccess = (value?: PermissionBindingValue) => { + return hasPermissionAccessByMode('view', value); }; diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 225e87ae4b5a..69b38e017a49 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -38,9 +38,7 @@ "build/**/*.ts", "build/**/*.d.ts", "vite.config.ts", - "auto-imports.d.ts", - "components.d.ts", - "vite-env.d.ts" + "auto-imports.d.ts" ], "exclude": ["node_modules", "dist", "**/*.js", "*.json", "*.md"] }