Skip to content

Commit 43de34e

Browse files
committed
fix(policy): separate create scope control from scope filter
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 6238bca commit 43de34e

1 file changed

Lines changed: 38 additions & 14 deletions

File tree

src/views/Settings/PolicyWorkbench/RealPolicyWorkbench.vue

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,14 @@
200200
</label>
201201
</div>
202202
<div v-if="state.viewMode === 'system-admin'" class="policy-workbench__crud-create">
203-
<p class="policy-workbench__table-note policy-workbench__table-note--compact">
204-
{{ t('libresign', 'Select the scope filter to choose where the next rule will be created.') }}
205-
</p>
203+
<label class="policy-workbench__create-inline">
204+
<span>{{ t('libresign', 'Create in') }}</span>
205+
<select class="policy-workbench__create-select" :value="newRuleScope" @change="setNewRuleScope(($event.target as HTMLSelectElement).value as 'system' | 'group' | 'user', true)">
206+
<option value="system">{{ t('libresign', 'Instance') }}</option>
207+
<option value="group">{{ t('libresign', 'Group') }}</option>
208+
<option value="user">{{ t('libresign', 'User') }}</option>
209+
</select>
210+
</label>
206211
<NcButton variant="primary" size="small" :disabled="isCreateRuleDisabled" :title="createRuleDisabledReason || undefined" @click="startCreateRule()">
207212
{{ t('libresign', 'Create rule') }}
208213
</NcButton>
@@ -263,7 +268,7 @@
263268
</NcActionButton>
264269
</NcActions>
265270
</template>
266-
<span class="policy-workbench__table-note">{{ t('libresign', 'Read only') }}</span>
271+
<span v-else class="policy-workbench__table-note">{{ t('libresign', 'Read only') }}</span>
267272
</td>
268273
</tr>
269274
<tr v-if="pagedCrudRows.length === 0">
@@ -401,6 +406,7 @@ const lastPress = ref<{ surface: 'cards' | 'list', key: string, x: number, y: nu
401406
const recentSelectionGesture = ref<{ surface: 'cards' | 'list', key: string, at: number } | null>(null)
402407
const crudSearch = ref('')
403408
const crudScopeFilter = ref<'all' | 'system' | 'group' | 'user'>('all')
409+
const newRuleScope = ref<'system' | 'group' | 'user'>('group')
404410
const crudPage = ref(1)
405411
const CRUD_PAGE_SIZE = 20
406412
@@ -544,15 +550,11 @@ const editorHelp = computed(() => {
544550
})
545551
546552
const createRuleDisabledReason = computed(() => {
547-
if (crudScopeFilter.value === 'all') {
548-
return t('libresign', 'Select Instance, Group, or User in the scope filter before creating a rule.')
549-
}
550-
551-
if (crudScopeFilter.value === 'group') {
553+
if (newRuleScope.value === 'group') {
552554
return state.createGroupOverrideDisabledReason || ''
553555
}
554556
555-
if (crudScopeFilter.value === 'user') {
557+
if (newRuleScope.value === 'user') {
556558
return state.createUserOverrideDisabledReason || ''
557559
}
558560
@@ -649,16 +651,20 @@ function setCrudScopeFilter(value: 'all' | 'system' | 'group' | 'user', selected
649651
crudPage.value = 1
650652
}
651653
652-
function startCreateRule() {
653-
if (isCreateRuleDisabled.value) {
654+
function setNewRuleScope(value: 'system' | 'group' | 'user', selected: boolean) {
655+
if (!selected) {
654656
return
655657
}
656658
657-
if (crudScopeFilter.value === 'all') {
659+
newRuleScope.value = value
660+
}
661+
662+
function startCreateRule() {
663+
if (isCreateRuleDisabled.value) {
658664
return
659665
}
660666
661-
state.startEditor({ scope: crudScopeFilter.value })
667+
state.startEditor({ scope: newRuleScope.value })
662668
}
663669
664670
function onSettingsFilterChange(value: string | number) {
@@ -1894,6 +1900,24 @@ onBeforeUnmount(() => {
18941900
}
18951901
}
18961902
1903+
&__create-inline {
1904+
display: inline-flex;
1905+
align-items: center;
1906+
gap: 0.45rem;
1907+
font-size: 0.84rem;
1908+
color: var(--color-text-maxcontrast);
1909+
}
1910+
1911+
&__create-select {
1912+
height: 2rem;
1913+
min-width: 8.5rem;
1914+
padding: 0 0.5rem;
1915+
border: 1px solid color-mix(in srgb, var(--color-border-maxcontrast) 68%, transparent);
1916+
border-radius: 8px;
1917+
background: var(--color-main-background);
1918+
color: var(--color-main-text);
1919+
}
1920+
18971921
&__table-empty-state {
18981922
display: flex;
18991923
flex-direction: column;

0 commit comments

Comments
 (0)