|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { t } from '@nextcloud/l10n' |
| 7 | + |
| 8 | +import type { EffectivePolicyValue } from '../../../../../types/index' |
| 9 | +import type { RealPolicySettingDefinition } from '../realTypes' |
| 10 | +import ApprovalGroupsRuleEditor from './ApprovalGroupsRuleEditor.vue' |
| 11 | +import { DEFAULT_APPROVAL_GROUPS, resolveApprovalGroups, serializeApprovalGroups } from './model' |
| 12 | + |
| 13 | +export const approvalGroupsRealDefinition: RealPolicySettingDefinition = { |
| 14 | + key: 'approval_group', |
| 15 | + title: t('libresign', 'Identification document approvers'), |
| 16 | + description: t('libresign', 'Choose which groups can approve submitted identification documents when this flow is enabled.'), |
| 17 | + supportedScopes: ['system', 'group'], |
| 18 | + editor: ApprovalGroupsRuleEditor, |
| 19 | + resolutionMode: 'precedence', |
| 20 | + createEmptyValue: () => serializeApprovalGroups(DEFAULT_APPROVAL_GROUPS), |
| 21 | + normalizeDraftValue: (value: EffectivePolicyValue) => serializeApprovalGroups(value), |
| 22 | + hasSelectableDraftValue: (value: EffectivePolicyValue) => resolveApprovalGroups(value).length > 0, |
| 23 | + normalizeAllowChildOverride: () => false, |
| 24 | + getFallbackSystemDefault: (policyValue: EffectivePolicyValue | null | undefined, sourceScope?: string | null) => { |
| 25 | + if (sourceScope === 'system' && policyValue !== null && policyValue !== undefined) { |
| 26 | + return policyValue |
| 27 | + } |
| 28 | + |
| 29 | + return serializeApprovalGroups(DEFAULT_APPROVAL_GROUPS) |
| 30 | + }, |
| 31 | + summarizeValue: (value: EffectivePolicyValue) => { |
| 32 | + const groupIds = resolveApprovalGroups(value) |
| 33 | + if (groupIds.length === 0) { |
| 34 | + return t('libresign', 'No approver groups configured') |
| 35 | + } |
| 36 | + |
| 37 | + if (groupIds.length <= 2) { |
| 38 | + return groupIds.join(', ') |
| 39 | + } |
| 40 | + |
| 41 | + return t('libresign', '{count} approver groups', { count: String(groupIds.length) }) |
| 42 | + }, |
| 43 | + formatAllowOverride: () => t('libresign', 'Lower-level customization is disabled for this setting'), |
| 44 | +} |
0 commit comments