Skip to content

Commit 85e7eb3

Browse files
committed
fix(types): widen EffectivePolicyValue to include arrays, remove casts in realDefinition
1 parent df98a7d commit 85e7eb3

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export type SignatureFlowValue = SignatureFlowMode | 0 | 1 | 2
5454
export type EffectivePoliciesResponse = ApiOcsResponseData<ApiOperations['policy-effective'], 200>
5555
export type EffectivePoliciesState = EffectivePoliciesResponse['policies']
5656
export type EffectivePolicyState = ApiRecordValue<EffectivePoliciesState>
57-
export type EffectivePolicyValue = Exclude<ApiRequestJsonBody<AdminOperations['policy-set-system']>['value'], undefined>
57+
export type EffectivePolicyValue = Exclude<ApiRequestJsonBody<AdminOperations['policy-set-system']>['value'], undefined> | unknown[]
5858
export type GroupPolicyResponse = ApiOcsResponseData<ApiOperations['policy-get-group'], 200>
5959
export type GroupPolicyState = GroupPolicyResponse['policy']
6060

src/views/Settings/PolicyWorkbench/settings/identify-methods/realDefinition.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
import { t } from '@nextcloud/l10n'
77

8-
import type { EffectivePolicyValue } from '../../../../../types/index'
9-
import type { RealPolicySettingDefinition } from '../realTypes'
108
import IdentifyMethodsRuleEditor from './IdentifyMethodsRuleEditor.vue'
9+
1110
import { normalizeIdentifyMethodsPolicy, serializeIdentifyMethodsPolicy } from './model'
11+
import type { EffectivePolicyValue } from '../../../../../types/index'
12+
import type { RealPolicySettingDefinition } from '../realTypes'
1213

1314
export const identifyMethodsRealDefinition: RealPolicySettingDefinition = {
1415
key: 'identify_methods',
@@ -17,16 +18,16 @@ export const identifyMethodsRealDefinition: RealPolicySettingDefinition = {
1718
supportedScopes: ['system', 'group', 'user'],
1819
editor: IdentifyMethodsRuleEditor,
1920
resolutionMode: 'precedence',
20-
createEmptyValue: () => [] as unknown as EffectivePolicyValue,
21-
normalizeDraftValue: (value: EffectivePolicyValue) => serializeIdentifyMethodsPolicy(normalizeIdentifyMethodsPolicy(value)) as unknown as EffectivePolicyValue,
21+
createEmptyValue: () => [],
22+
normalizeDraftValue: (value: EffectivePolicyValue) => serializeIdentifyMethodsPolicy(normalizeIdentifyMethodsPolicy(value)),
2223
hasSelectableDraftValue: () => true,
2324
normalizeAllowChildOverride: (_scope, allowChildOverride: boolean) => allowChildOverride,
2425
getFallbackSystemDefault: (policyValue: EffectivePolicyValue | null | undefined, sourceScope?: string | null) => {
2526
if (sourceScope === 'system' && policyValue !== null && policyValue !== undefined) {
2627
return policyValue
2728
}
2829

29-
return [] as unknown as EffectivePolicyValue
30+
return []
3031
},
3132
summarizeValue: (value: EffectivePolicyValue) => {
3233
const normalized = normalizeIdentifyMethodsPolicy(value)

0 commit comments

Comments
 (0)