File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,15 +65,24 @@ defineOptions({
6565const isAdmin = getCurrentUser ()?.isAdmin ?? false
6666const config = loadState <{ can_manage_group_policies? : boolean }>(' libresign' , ' config' , {})
6767const effectivePoliciesState = loadState <EffectivePoliciesResponse >(' libresign' , ' effective_policies' , { policies: {} })
68- const hasEditablePolicies = Object .values (effectivePoliciesState .policies ?? {}).some ((policy ) => {
68+ const hasDelegatedEditablePolicies = Object .values (effectivePoliciesState .policies ?? {}).some ((policy ) => {
6969 if (! policy || typeof policy !== ' object' ) {
7070 return false
7171 }
72+ const policyState = policy as {
73+ editableByCurrentActor? : boolean
74+ groupCount? : number
75+ userCount? : number
76+ }
77+ const hasDelegatedRule = (policyState .groupCount ?? 0 ) > 0 || (policyState .userCount ?? 0 ) > 0
78+ if (! hasDelegatedRule ) {
79+ return false
80+ }
7281
73- return Boolean (( policy as { editableByCurrentActor ? : boolean }) .editableByCurrentActor )
82+ return Boolean (policyState .editableByCurrentActor )
7483})
7584
76- const canManagePolicies = isAdmin || (Boolean (config .can_manage_group_policies ) && hasEditablePolicies )
85+ const canManagePolicies = isAdmin || (Boolean (config .can_manage_group_policies ) && hasDelegatedEditablePolicies )
7786
7887function getAdminRoute() {
7988 return generateUrl (' settings/admin/libresign' )
You can’t perform that action at this time.
0 commit comments