Skip to content

Commit 26d9d91

Browse files
authored
fix(ui): lay out the form field groups with the shared field grid (#1302)
LdapPanel, SsoProviderDialog and the member credential form each wrote their own two column grid, keyed to the medium window class. They now use MdFieldGrid, so the columns follow the shared rule (two columns from the expanded window class). Signed-off-by: TheMeinerLP <github@themeinerlp.dev>
1 parent 573ab16 commit 26d9d91

6 files changed

Lines changed: 46 additions & 19 deletions

File tree

‎reposilite-frontend/src/components/access/LdapPanel.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ describe('LdapPanel', () => {
104104
document.body.innerHTML = ''
105105
})
106106

107+
describe('field grids', () => {
108+
it('lays its fields out with the shared field grid, not a hand-written grid', async () => {
109+
await mountPanel()
110+
111+
const handWritten = wrapper.findAll('.medium\\:grid-cols-2')
112+
const shared = wrapper.findAll('.expanded\\:grid-cols-2')
113+
expect(handWritten.length, 'no field group writes its own two column grid').toBe(0)
114+
expect(shared.length, 'the four field groups use the shared field grid').toBeGreaterThanOrEqual(4)
115+
})
116+
})
117+
107118
describe('headings', () => {
108119
it('titles both sections with level 2 headings in the title-medium role, under the level 1 page heading', async () => {
109120
await mountPanel()

‎reposilite-frontend/src/components/access/LdapPanel.vue‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import MdAlert from '../md/MdAlert.vue'
2323
import MdButton from '../md/MdButton.vue'
2424
import MdCard from '../md/MdCard.vue'
2525
import MdChipInput from '../md/MdChipInput.vue'
26+
import MdFieldGrid from '../md/MdFieldGrid.vue'
2627
import MdSection from '../md/MdSection.vue'
2728
import MdStatePanel from '../md/MdStatePanel.vue'
2829
import MdSwitch from '../md/MdSwitch.vue'
@@ -189,7 +190,7 @@ onMounted(load)
189190
<p class="md-body-medium text-on-surface-variant">
190191
The service account the server uses to search. Leave both empty to search anonymously.
191192
</p>
192-
<div class="grid gap-4 medium:grid-cols-2">
193+
<MdFieldGrid>
193194
<MdTextField
194195
id="ldap-bind-dn"
195196
v-model="form.bindDn"
@@ -207,7 +208,7 @@ onMounted(load)
207208
:error="errorOf('bindPassword') !== ''"
208209
:error-text="errorOf('bindPassword')"
209210
/>
210-
</div>
211+
</MdFieldGrid>
211212
</MdSection>
212213

213214
<MdSection
@@ -216,7 +217,7 @@ onMounted(load)
216217
heading-id="ldap-users-title"
217218
aria-labelledby="ldap-users-title"
218219
>
219-
<div class="grid gap-4 medium:grid-cols-2">
220+
<MdFieldGrid>
220221
<MdTextField
221222
id="ldap-user-base"
222223
v-model="form.userBaseDn"
@@ -260,7 +261,7 @@ onMounted(load)
260261
type="text"
261262
autocomplete="off"
262263
/>
263-
</div>
264+
</MdFieldGrid>
264265
<MdSwitch
265266
id="ldap-create-users"
266267
v-model="form.autoCreateUsers"
@@ -279,7 +280,7 @@ onMounted(load)
279280
A team whose external reference is <code>ldap:&lt;group&gt;</code> is synced from the groups
280281
of this directory: its members follow the group, and they cannot be removed by hand.
281282
</p>
282-
<div class="grid gap-4 medium:grid-cols-2">
283+
<MdFieldGrid>
283284
<MdTextField
284285
id="ldap-group-base"
285286
v-model="form.groupBaseDn"
@@ -304,7 +305,7 @@ onMounted(load)
304305
type="text"
305306
autocomplete="off"
306307
/>
307-
</div>
308+
</MdFieldGrid>
308309
<MdChipInput
309310
id="ldap-admin-groups"
310311
v-model="form.adminGroups"
@@ -351,7 +352,7 @@ onMounted(load)
351352
? 'Save your changes first. The test reads the saved directory.'
352353
: 'Connects with the saved settings. A user name and password also check that the user signs in.'"
353354
>
354-
<div class="grid gap-4 medium:grid-cols-2">
355+
<MdFieldGrid>
355356
<MdTextField
356357
id="ldap-test-username"
357358
v-model="testUsername"
@@ -366,7 +367,7 @@ onMounted(load)
366367
type="password"
367368
autocomplete="off"
368369
/>
369-
</div>
370+
</MdFieldGrid>
370371
<div class="flex flex-wrap items-center gap-3">
371372
<MdButton
372373
variant="outlined"

‎reposilite-frontend/src/components/access/SsoProviderDialog.card.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,17 @@ describe('SsoProviderDialog register card', () => {
7676
expect(section?.querySelector('[aria-label="Copy callback URL"]'), 'the copy button sits in the card').not.toBeNull()
7777
})
7878
})
79+
80+
describe('SsoProviderDialog field grids', () => {
81+
afterEach(() => {
82+
wrapper?.unmount()
83+
wrapper = undefined
84+
})
85+
86+
it('lays its fields out with the shared field grid, not a hand-written grid', async () => {
87+
await openDialog()
88+
89+
expect(document.querySelectorAll('.medium\\:grid-cols-2').length, 'no field group writes its own two column grid').toBe(0)
90+
expect(document.querySelectorAll('.expanded\\:grid-cols-2').length, 'the field groups use the shared field grid').toBeGreaterThanOrEqual(1)
91+
})
92+
})

‎reposilite-frontend/src/components/access/SsoProviderDialog.vue‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import MdDialog from '../md/MdDialog.vue'
2020
import MdButton from '../md/MdButton.vue'
2121
import MdCard from '../md/MdCard.vue'
2222
import MdChipInput from '../md/MdChipInput.vue'
23+
import MdFieldGrid from '../md/MdFieldGrid.vue'
2324
import MdDisclosure from '../md/MdDisclosure.vue'
2425
import MdIconButton from '../md/MdIconButton.vue'
2526
import MdSwitch from '../md/MdSwitch.vue'
@@ -225,7 +226,7 @@ const validateDomain = (text: string, existing: string[]) => {
225226
novalidate
226227
@submit.prevent="save()"
227228
>
228-
<div class="grid gap-4 medium:grid-cols-2">
229+
<MdFieldGrid>
229230
<MdTextField
230231
id="sso-id"
231232
v-model="form.id"
@@ -247,7 +248,7 @@ const validateDomain = (text: string, existing: string[]) => {
247248
:error-text="errorOf('label')"
248249
required
249250
/>
250-
</div>
251+
</MdFieldGrid>
251252

252253
<MdTextField
253254
id="sso-issuer"
@@ -299,7 +300,7 @@ const validateDomain = (text: string, existing: string[]) => {
299300
</div>
300301
</MdCard>
301302

302-
<div class="grid gap-4 medium:grid-cols-2">
303+
<MdFieldGrid>
303304
<MdTextField
304305
id="sso-client-id"
305306
v-model="form.clientId"
@@ -323,7 +324,7 @@ const validateDomain = (text: string, existing: string[]) => {
323324
:error-text="errorOf('clientSecret')"
324325
:required="githubEndpoints"
325326
/>
326-
</div>
327+
</MdFieldGrid>
327328

328329
<MdChipInput
329330
id="sso-scopes"
@@ -385,7 +386,7 @@ const validateDomain = (text: string, existing: string[]) => {
385386
<template #summary>
386387
Advanced
387388
</template>
388-
<div class="grid gap-4 medium:grid-cols-2">
389+
<MdFieldGrid>
389390
<MdTextField
390391
id="sso-claim-username"
391392
v-model="form.usernameClaim"
@@ -414,7 +415,7 @@ const validateDomain = (text: string, existing: string[]) => {
414415
type="text"
415416
autocomplete="off"
416417
/>
417-
</div>
418+
</MdFieldGrid>
418419
<!-- A login the provider has already verified with a second factor counts as one, so the policy does not ask again. -->
419420
<div class="mt-4 flex flex-col gap-4">
420421
<MdChipInput

‎reposilite-frontend/src/components/settings/RepositoryMembersPicker.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ describe('RepositoryMembersPicker credentials of the members', () => {
185185
expect(wrapper.find('#members-login-1').exists()).toBe(false)
186186
})
187187

188-
it('puts the credential fields side by side on the medium window class, not on a default breakpoint', async () => {
188+
it('puts the credential fields side by side on the expanded window class, not on a default breakpoint', async () => {
189189
mountWithCredentials({ modelValue: [entry('releases', { authorization: loopback })] })
190190
await editButton('releases').trigger('click')
191191

192192
const form = wrapper.get('[data-test="member-credential-form"]')
193-
expect(form.classes(), 'two columns from 600 pixels').toContain('medium:grid-cols-2')
193+
expect(form.classes(), 'two columns from 840 pixels').toContain('expanded:grid-cols-2')
194194
expect(form.classes().filter(name => /^(sm|md|lg|xl|2xl):/.test(name)), 'no default breakpoint prefix').toEqual([])
195195
})
196196

‎reposilite-frontend/src/components/settings/RepositoryMembersPicker.vue‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import { computed, ref } from 'vue'
2020
import MdAlert from '../md/MdAlert.vue'
2121
import MdButton from '../md/MdButton.vue'
22+
import MdFieldGrid from '../md/MdFieldGrid.vue'
2223
import MdIconButton from '../md/MdIconButton.vue'
2324
import MdSelect from '../md/MdSelect.vue'
2425
import MdTextField from '../md/MdTextField.vue'
@@ -185,10 +186,9 @@ const setCredential = (index: number, field: string, value: unknown) => {
185186
{{ openCredential === index ? 'Done' : 'Edit credential' }}
186187
</MdButton>
187188
</div>
188-
<div
189+
<MdFieldGrid
189190
v-if="openCredential === index"
190191
data-test="member-credential-form"
191-
class="grid gap-4 medium:grid-cols-2"
192192
>
193193
<MdTextField
194194
:id="`${idPrefix}-login-${index}`"
@@ -207,7 +207,7 @@ const setCredential = (index: number, field: string, value: unknown) => {
207207
supporting-text="A stored password shows as ********. Type a new value to replace it."
208208
@update:model-value="setCredential(index, 'password', $event)"
209209
/>
210-
</div>
210+
</MdFieldGrid>
211211
</div>
212212
</li>
213213
</ol>

0 commit comments

Comments
 (0)