Skip to content

Commit b417091

Browse files
committed
fix(settings): show policies menu from reactive policy store
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent fa39db7 commit b417091

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/components/Settings/Settings.vue

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ import { t } from '@nextcloud/l10n'
4545
import { getCurrentUser } from '@nextcloud/auth'
4646
import { loadState } from '@nextcloud/initial-state'
4747
import { generateUrl } from '@nextcloud/router'
48-
import type { EffectivePoliciesResponse } from '../../types'
48+
import { computed } from 'vue'
4949
50+
import { usePoliciesStore } from '../../store/policies'
5051
5152
import NcAppNavigationItem from '@nextcloud/vue/components/NcAppNavigationItem'
5253
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
@@ -64,25 +65,22 @@ defineOptions({
6465
6566
const isAdmin = getCurrentUser()?.isAdmin ?? false
6667
const 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
8785
function getAdminRoute() {
8886
return generateUrl('settings/admin/libresign')

0 commit comments

Comments
 (0)