File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ import { t } from '@nextcloud/l10n'
4545import { getCurrentUser } from ' @nextcloud/auth'
4646import { loadState } from ' @nextcloud/initial-state'
4747import { generateUrl } from ' @nextcloud/router'
48+ import type { EffectivePoliciesResponse } from ' ../../types'
4849
4950
5051import NcAppNavigationItem from ' @nextcloud/vue/components/NcAppNavigationItem'
@@ -63,7 +64,16 @@ defineOptions({
6364
6465const isAdmin = getCurrentUser ()?.isAdmin ?? false
6566const config = loadState <{ can_manage_group_policies? : boolean }>(' libresign' , ' config' , {})
66- const canManagePolicies = isAdmin || Boolean (config .can_manage_group_policies )
67+ const effectivePoliciesState = loadState <EffectivePoliciesResponse >(' libresign' , ' effective_policies' , { policies: {} })
68+ const hasEditablePolicies = Object .values (effectivePoliciesState .policies ?? {}).some ((policy ) => {
69+ if (! policy || typeof policy !== ' object' ) {
70+ return false
71+ }
72+
73+ return Boolean ((policy as { editableByCurrentActor? : boolean }).editableByCurrentActor )
74+ })
75+
76+ const canManagePolicies = isAdmin || (Boolean (config .can_manage_group_policies ) && hasEditablePolicies )
6777
6878function getAdminRoute() {
6979 return generateUrl (' settings/admin/libresign' )
You can’t perform that action at this time.
0 commit comments