@@ -45,8 +45,9 @@ 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 '
48+ import { computed } from ' vue '
4949
50+ import { usePoliciesStore } from ' ../../store/policies'
5051
5152import NcAppNavigationItem from ' @nextcloud/vue/components/NcAppNavigationItem'
5253import NcIconSvgWrapper from ' @nextcloud/vue/components/NcIconSvgWrapper'
@@ -64,25 +65,22 @@ defineOptions({
6465
6566const isAdmin = getCurrentUser ()?.isAdmin ?? false
6667const config = loadState <{ can_manage_group_policies? : boolean }>(' libresign' , ' config' , {})
67- const effectivePoliciesState = loadState <EffectivePoliciesResponse >(' libresign' , ' effective_policies' , { policies: {} })
68- const hasDelegatedEditablePolicies = Object .values (effectivePoliciesState .policies ?? {}).some ((policy ) => {
68+ const policiesStore = usePoliciesStore ()
69+
70+ const hasDelegatedPolicies = computed (() => Object .values (policiesStore .policies ).some ((policy ) => {
6971 if (! policy || typeof policy !== ' object' ) {
7072 return false
7173 }
74+
7275 const policyState = policy as {
73- editableByCurrentActor? : boolean
7476 groupCount? : number
7577 userCount? : number
7678 }
77- const hasDelegatedRule = (policyState .groupCount ?? 0 ) > 0 || (policyState .userCount ?? 0 ) > 0
78- if (! hasDelegatedRule ) {
79- return false
80- }
8179
82- return Boolean (policyState .editableByCurrentActor )
83- })
80+ return (policyState .groupCount ?? 0 ) > 0 || ( policyState . userCount ?? 0 ) > 0
81+ }))
8482
85- const canManagePolicies = isAdmin || (Boolean (config .can_manage_group_policies ) && hasDelegatedEditablePolicies )
83+ const canManagePolicies = computed (() => isAdmin || (Boolean (config .can_manage_group_policies ) && hasDelegatedPolicies . value ) )
8684
8785function getAdminRoute() {
8886 return generateUrl (' settings/admin/libresign' )
0 commit comments