Skip to content

Commit 0101b3f

Browse files
authored
fix(ui): build the controls of the migration steps from primitives (#1293)
The password choice of the Connect step, the conflict policy and include controls of the Mapping step, the checklist of the Cut-over step and the report filters and acceptance of the Dry run step were hand-built native controls with their own classes. They now use MdRadio, MdCheckbox, MdFieldset, MdSelect, MdTextField and MdButton, so they share the states, touch targets and focus rings of the rest of the dashboard. SyncStep is left to its own pull request. Signed-off-by: TheMeinerLP <github@themeinerlp.dev>
1 parent 1c084c1 commit 0101b3f

8 files changed

Lines changed: 131 additions & 126 deletions

File tree

‎reposilite-frontend/src/components/migration/ConnectStep.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { flushPromises, type VueWrapper } from '@vue/test-utils'
1919
import ConnectStep from './ConnectStep.vue'
2020
import { ApiProblem } from '../../store/migration/migrationApi'
2121
import { fakeApi, mountWith, cleanup, okConnection } from './testing'
22+
import MdRadio from '../md/MdRadio.vue'
23+
import MdFieldset from '../md/MdFieldset.vue'
2224

2325
const URL_VALUE = 'https://nexus.example.test'
2426
const USER = 'importer'
@@ -83,7 +85,7 @@ describe('the Connect step', () => {
8385

8486
it('accepts a secret reference as text and sends it as the password', async () => {
8587
const { wrapper, api } = await mountWith(ConnectStep)
86-
const referenceChoice = wrapper.findAll('label').find(entry => entry.text().includes('Use a secret reference'))
88+
const referenceChoice = wrapper.findAllComponents(MdRadio).find(entry => entry.text().includes('Use a secret reference'))
8789
await referenceChoice!.find('input').setValue(true)
8890
await fill(wrapper, { password: null })
8991
await wrapper.find('#migration-connect-reference').setValue('${env:NEXUS_PASSWORD}')
@@ -161,4 +163,12 @@ describe('the Connect step', () => {
161163
expect(api.testConnection, 'no call without the form').not.toHaveBeenCalled()
162164
expect(wrapper.text()).toContain('Enter the Nexus URL')
163165
})
166+
167+
it('draws the password choice as a fieldset of radio primitives', async () => {
168+
const { wrapper } = await mountWith(ConnectStep)
169+
170+
expect(wrapper.findAllComponents(MdFieldset).length, 'the choice is an MdFieldset').toBeGreaterThan(0)
171+
expect(wrapper.findAllComponents(MdRadio), 'both choices are MdRadio').toHaveLength(2)
172+
expect(wrapper.find('legend').text()).toBe('Password')
173+
})
164174
})

‎reposilite-frontend/src/components/migration/ConnectStep.vue‎

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { computed, inject, nextTick, reactive, ref } from 'vue'
2121
import { RouterLink } from 'vue-router'
2222
import MdAlert from '../md/MdAlert.vue'
2323
import MdButton from '../md/MdButton.vue'
24+
import MdFieldset from '../md/MdFieldset.vue'
25+
import MdRadio from '../md/MdRadio.vue'
2426
import MdTextField from '../md/MdTextField.vue'
2527
import PasswordField from './PasswordField.vue'
2628
import ProblemAlert from './ProblemAlert.vue'
@@ -186,29 +188,22 @@ const submit = async () => {
186188
:error-text="errors.user"
187189
@update:model-value="user = $event"
188190
/>
189-
<fieldset class="flex flex-col gap-2">
190-
<legend class="md-label-large text-on-surface">
191-
Password
192-
</legend>
193-
<label class="flex items-center gap-2 md-body-large">
194-
<input
195-
v-model="mode"
196-
type="radio"
197-
name="migration-password-mode"
198-
value="literal"
199-
>
191+
<MdFieldset legend="Password">
192+
<MdRadio
193+
v-model="mode"
194+
name="migration-password-mode"
195+
value="literal"
196+
>
200197
Enter the password
201-
</label>
202-
<label class="flex items-center gap-2 md-body-large">
203-
<input
204-
v-model="mode"
205-
type="radio"
206-
name="migration-password-mode"
207-
value="reference"
208-
>
198+
</MdRadio>
199+
<MdRadio
200+
v-model="mode"
201+
name="migration-password-mode"
202+
value="reference"
203+
>
209204
Use a secret reference
210-
</label>
211-
</fieldset>
205+
</MdRadio>
206+
</MdFieldset>
212207
<PasswordField
213208
v-if="mode === 'literal'"
214209
id="migration-connect-password"

‎reposilite-frontend/src/components/migration/CutOverStep.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import type { MigrationJob } from '../../store/migration/types'
2020
import CutOverStep from './CutOverStep.vue'
2121
import { createWizardStore } from '../../store/migration/wizardStore'
2222
import { fakeApi, mountWith, cleanup } from './testing'
23+
import MdCheckbox from '../md/MdCheckbox.vue'
24+
import MdFieldset from '../md/MdFieldset.vue'
2325

2426
afterEach(cleanup)
2527

@@ -198,4 +200,11 @@ describe('the Cut-over step', () => {
198200

199201
expect(document.getElementById('migration-cutover-delete-confirm')!.classList.contains('bg-error'), 'the removal uses the error colour role').toBe(true)
200202
})
203+
204+
it('draws the checklist as a fieldset of checkbox primitives', async () => {
205+
const { wrapper } = await mountWith(CutOverStep, { wizard: wizardWith([importJob(), verifyJob(verified)]), at: '/settings/migration/cut-over' })
206+
207+
expect(wrapper.findAllComponents(MdFieldset).length, 'the checklist is an MdFieldset').toBeGreaterThan(0)
208+
expect(wrapper.findAllComponents(MdCheckbox), 'each item is an MdCheckbox').toHaveLength(3)
209+
})
201210
})

‎reposilite-frontend/src/components/migration/CutOverStep.vue‎

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { computed, inject, onMounted, ref } from 'vue'
2121
import MdList from '../md/MdList.vue'
2222
import MdListItem from '../md/MdListItem.vue'
2323
import MdButton from '../md/MdButton.vue'
24+
import MdCheckbox from '../md/MdCheckbox.vue'
25+
import MdFieldset from '../md/MdFieldset.vue'
2426
import MdDataTable from '../md/MdDataTable.vue'
2527
import MigrationDialog from './MigrationDialog.vue'
2628
import ProblemAlert from './ProblemAlert.vue'
@@ -148,22 +150,19 @@ onMounted(() => {
148150
Switching the clients is the last step. Work through the checklist in order.
149151
</p>
150152

151-
<fieldset class="flex flex-col gap-2">
152-
<legend class="md-title-small text-on-surface">
153-
Checklist
154-
</legend>
155-
153+
<MdFieldset
154+
legend="Checklist"
155+
class="gap-2"
156+
>
156157
<MdList divided>
157158
<MdListItem>
158159
<div class="flex flex-col gap-1">
159-
<label class="flex items-center gap-2 md-body-large">
160-
<input
161-
id="migration-cutover-freeze"
162-
v-model="freezeDone"
163-
type="checkbox"
164-
>
160+
<MdCheckbox
161+
id="migration-cutover-freeze"
162+
v-model="freezeDone"
163+
>
165164
Freeze Nexus writes
166-
</label>
165+
</MdCheckbox>
167166
<p class="md-body-medium text-on-surface-variant">
168167
In Nexus, set each repository you migrate to read-only, so no client writes to it during the switch. Ingot never
169168
writes to Nexus, so this is done in Nexus.
@@ -173,15 +172,13 @@ onMounted(() => {
173172

174173
<MdListItem>
175174
<div class="flex flex-col gap-1">
176-
<label class="flex items-center gap-2 md-body-large">
177-
<input
178-
id="migration-cutover-verify"
179-
type="checkbox"
180-
:checked="verified"
181-
disabled
182-
>
175+
<MdCheckbox
176+
id="migration-cutover-verify"
177+
:model-value="verified"
178+
disabled
179+
>
183180
Verify all repositories
184-
</label>
181+
</MdCheckbox>
185182
<p class="md-body-medium text-on-surface-variant">
186183
Set by the newest verify job. It is ticked when every repository is VERIFIED, and it cannot be ticked by hand.
187184
</p>
@@ -214,21 +211,19 @@ onMounted(() => {
214211

215212
<MdListItem>
216213
<div class="flex flex-col gap-1">
217-
<label class="flex items-center gap-2 md-body-large">
218-
<input
219-
id="migration-cutover-switch"
220-
v-model="switchDone"
221-
type="checkbox"
222-
>
214+
<MdCheckbox
215+
id="migration-cutover-switch"
216+
v-model="switchDone"
217+
>
223218
Switch clients
224-
</label>
219+
</MdCheckbox>
225220
<p class="md-body-medium text-on-surface-variant">
226221
Point each client at Ingot with the settings below, then tick this item.
227222
</p>
228223
</div>
229224
</MdListItem>
230225
</MdList>
231-
</fieldset>
226+
</MdFieldset>
232227

233228
<section
234229
v-if="targets.length"

‎reposilite-frontend/src/components/migration/DryRunStep.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import { createWizardStore } from '../../store/migration/wizardStore'
2121
import { ApiProblem } from '../../store/migration/migrationApi'
2222
import { planFingerprint } from '../../store/migration/gating'
2323
import { fakeApi, mountWith, cleanup, manualRuntime } from './testing'
24+
import MdButton from '../md/MdButton.vue'
25+
import MdCheckbox from '../md/MdCheckbox.vue'
26+
import MdSelect from '../md/MdSelect.vue'
27+
import MdTextField from '../md/MdTextField.vue'
2428

2529
afterEach(cleanup)
2630

@@ -219,4 +223,16 @@ describe('the Dry run step', () => {
219223
expect(api.report).toHaveBeenCalledWith(7, 'json')
220224
expect(wrapper.findAll('[data-test="report"] table tbody tr')).toHaveLength(3)
221225
})
226+
227+
it('builds the report filters, the acceptance and its button from primitives', async () => {
228+
const { wrapper } = await mountWith(DryRunStep, { wizard: mappedWizard(), api: finishedApi(), at: '/settings/migration/dry-run' })
229+
await wrapper.find('#migration-dry-run-start').trigger('click')
230+
await flushPromises()
231+
232+
expect(wrapper.findAllComponents(MdSelect).length, 'the status filter is an MdSelect').toBeGreaterThan(0)
233+
expect(wrapper.findAllComponents(MdTextField).some(field => field.props('type') === 'search'), 'the search is an MdTextField').toBe(true)
234+
expect(wrapper.findAllComponents(MdCheckbox).length, 'the acceptance is an MdCheckbox').toBeGreaterThan(0)
235+
const accept = wrapper.findAllComponents(MdButton).find(button => button.attributes('id') === 'migration-accept-report')
236+
expect(accept?.props('variant'), 'the accept button is a filled MdButton').toBe('filled')
237+
})
222238
})

‎reposilite-frontend/src/components/migration/DryRunStep.vue‎

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import { computed, inject, onMounted, ref } from 'vue'
2121
import { RouterLink } from 'vue-router'
2222
import MdButton from '../md/MdButton.vue'
23+
import MdCheckbox from '../md/MdCheckbox.vue'
24+
import MdSelect from '../md/MdSelect.vue'
25+
import MdTextField from '../md/MdTextField.vue'
2326
import MdDataTable from '../md/MdDataTable.vue'
2427
import PasswordField from './PasswordField.vue'
2528
import ProblemAlert from './ProblemAlert.vue'
@@ -54,6 +57,7 @@ const reportLoaded = ref(false)
5457
const readReport = ref(false)
5558
const statusFilter = ref('')
5659
const textFilter = ref('')
60+
const statusOptions = [{ value: '', label: 'All statuses' }, ...LOSS_STATUSES.map(status => ({ value: status as string, label: lossStatusText(status) }))]
5761
5862
const watched = useJobWatch({
5963
api,
@@ -329,40 +333,19 @@ onMounted(() => {
329333
</div>
330334

331335
<div class="flex flex-wrap items-end gap-4">
332-
<div class="flex flex-col gap-1">
333-
<label
334-
for="migration-report-status"
335-
class="md-label-large"
336-
>Status</label>
337-
<select
338-
id="migration-report-status"
339-
v-model="statusFilter"
340-
class="rounded-corner-extra-small border border-outline bg-surface px-2 py-2"
341-
>
342-
<option value="">
343-
All statuses
344-
</option>
345-
<option
346-
v-for="status in LOSS_STATUSES"
347-
:key="status"
348-
:value="status"
349-
>
350-
{{ lossStatusText(status) }}
351-
</option>
352-
</select>
353-
</div>
354-
<div class="flex flex-col gap-1">
355-
<label
356-
for="migration-report-search"
357-
class="md-label-large"
358-
>Search the report</label>
359-
<input
360-
id="migration-report-search"
361-
v-model="textFilter"
362-
type="search"
363-
class="rounded-corner-extra-small border border-outline bg-surface px-2 py-2"
364-
>
365-
</div>
336+
<MdSelect
337+
id="migration-report-status"
338+
v-model="statusFilter"
339+
label="Status"
340+
width="content"
341+
:options="statusOptions"
342+
/>
343+
<MdTextField
344+
id="migration-report-search"
345+
v-model="textFilter"
346+
type="search"
347+
label="Search the report"
348+
/>
366349
<div class="flex gap-4">
367350
<a
368351
class="md-focus-ring text-primary"
@@ -389,24 +372,20 @@ onMounted(() => {
389372
/>
390373

391374
<div class="flex flex-col gap-3">
392-
<label class="flex items-center gap-2 md-body-large">
393-
<input
394-
id="migration-accept-check"
395-
v-model="readReport"
396-
type="checkbox"
397-
>
375+
<MdCheckbox
376+
id="migration-accept-check"
377+
v-model="readReport"
378+
>
398379
I have read the loss report for this mapping
399-
</label>
380+
</MdCheckbox>
400381
<div>
401-
<button
382+
<MdButton
402383
id="migration-accept-report"
403-
type="button"
404-
class="md-focus-ring rounded-corner-full bg-primary px-6 py-2.5 md-label-large text-on-primary disabled:bg-on-surface/12 disabled:text-on-surface/38"
405384
:disabled="!readReport || acceptanceCurrent"
406385
@click="acceptReport"
407386
>
408387
Accept the loss report
409-
</button>
388+
</MdButton>
410389
</div>
411390
<p
412391
v-if="acceptanceCurrent"

‎reposilite-frontend/src/components/migration/MappingStep.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import { flushPromises, type VueWrapper } from '@vue/test-utils'
1919
import MappingStep from './MappingStep.vue'
2020
import { createWizardStore } from '../../store/migration/wizardStore'
2121
import { mountWith, cleanup, discovery } from './testing'
22+
import MdRadio from '../md/MdRadio.vue'
23+
import MdCheckbox from '../md/MdCheckbox.vue'
24+
import MdFieldset from '../md/MdFieldset.vue'
2225

2326
afterEach(cleanup)
2427

@@ -149,4 +152,12 @@ describe('the Mapping step', () => {
149152

150153
expect(document.getElementById('migration-overwrite-confirm')!.classList.contains('bg-error'), 'the confirmation uses the error colour role').toBe(true)
151154
})
155+
156+
it('draws the conflict policy as radio primitives and the include control as a checkbox primitive', async () => {
157+
const { wrapper } = await mountWith(MappingStep, { wizard: discoveredWizard(), at: '/settings/migration/mapping' })
158+
159+
expect(wrapper.findAllComponents(MdFieldset).length, 'the policy is an MdFieldset').toBeGreaterThan(0)
160+
expect(wrapper.findAllComponents(MdRadio).length, 'every policy is an MdRadio').toBeGreaterThanOrEqual(2)
161+
expect(wrapper.findAllComponents(MdCheckbox).length, 'every include control is an MdCheckbox').toBeGreaterThanOrEqual(1)
162+
})
152163
})

0 commit comments

Comments
 (0)