Skip to content

Commit c81ff58

Browse files
committed
fix(signature-flow): block no-op default option on instance create
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 684b1d8 commit c81ff58

1 file changed

Lines changed: 37 additions & 4 deletions

File tree

src/views/Settings/PolicyWorkbench/settings/signature-flow/SignatureFlowScalarRuleEditor.vue

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111
:key="flow.value"
1212
class="signature-flow-scalar-editor__option"
1313
type="radio"
14+
:disabled="flow.disabled"
1415
:model-value="normalizedValue === flow.value"
1516
name="signature-flow-scalar-editor"
16-
@update:modelValue="onFlowChange(flow.value, $event)">
17+
@update:modelValue="onFlowChange(flow.value, flow.disabled, $event)">
1718
<div class="signature-flow-scalar-editor__copy">
1819
<strong>{{ flow.label }}</strong>
1920
<p>{{ flow.description }}</p>
2021
</div>
2122
</NcCheckboxRadioSwitch>
2223
</div>
24+
<p v-if="isInstanceCreateMode" class="signature-flow-scalar-editor__hint">
25+
{{ t('libresign', 'To create an instance rule, choose Simultaneous or Sequential. "Let users choose" already matches the system default and is not saved as an instance override.') }}
26+
</p>
2327
</div>
2428
</template>
2529

@@ -36,13 +40,15 @@ defineOptions({
3640
3741
const props = defineProps<{
3842
modelValue: EffectivePolicyValue
43+
editorScope?: 'system' | 'group' | 'user'
44+
editorMode?: 'create' | 'edit' | null
3945
}>()
4046
4147
const emit = defineEmits<{
4248
'update:modelValue': [value: EffectivePolicyValue]
4349
}>()
4450
45-
const flows: Array<{ value: SignatureFlowMode | 'none', label: string, description: string }> = [
51+
const baseFlows: Array<{ value: SignatureFlowMode | 'none', label: string, description: string }> = [
4652
{
4753
value: 'parallel',
4854
label: t('libresign', 'Simultaneous (Parallel)'),
@@ -60,6 +66,27 @@ const flows: Array<{ value: SignatureFlowMode | 'none', label: string, descripti
6066
},
6167
]
6268
69+
const isInstanceCreateMode = computed(() => {
70+
return props.editorScope === 'system' && props.editorMode === 'create'
71+
})
72+
73+
const flows = computed(() => {
74+
return baseFlows.map((flow) => {
75+
if (flow.value === 'none' && isInstanceCreateMode.value) {
76+
return {
77+
...flow,
78+
disabled: true,
79+
description: t('libresign', 'Already the system default for this setting. Choose another option to create an explicit instance rule.'),
80+
}
81+
}
82+
83+
return {
84+
...flow,
85+
disabled: false,
86+
}
87+
})
88+
})
89+
6390
const normalizedValue = computed<SignatureFlowMode | 'none' | null>(() => {
6491
const value = props.modelValue
6592
if (value === 'parallel' || value === 'ordered_numeric' || value === 'none') {
@@ -69,8 +96,8 @@ const normalizedValue = computed<SignatureFlowMode | 'none' | null>(() => {
6996
return null
7097
})
7198
72-
function onFlowChange(flow: SignatureFlowMode | 'none', selected?: unknown) {
73-
if (selected === false) {
99+
function onFlowChange(flow: SignatureFlowMode | 'none', disabled: boolean, selected?: unknown) {
100+
if (disabled || selected === false) {
74101
return
75102
}
76103
@@ -99,6 +126,12 @@ function onFlowChange(flow: SignatureFlowMode | 'none', selected?: unknown) {
99126
color: var(--color-text-maxcontrast);
100127
}
101128
129+
&__hint {
130+
margin: 0;
131+
font-size: 0.84rem;
132+
color: var(--color-text-maxcontrast);
133+
}
134+
102135
:deep(.signature-flow-scalar-editor__option.checkbox-radio-switch) {
103136
width: 100%;
104137
}

0 commit comments

Comments
 (0)