fix(ui): align settings fields and expose diagnostic actions

Let the shared settings grid choose one column on phones and give shared notes the full row. Use visible source-opening buttons and neutral module summaries, remove invented source names, and drop the unused diagnostics panel query.
This commit is contained in:
Zakk committed 2026-10-02 08:49:36 +10:00
1 parent 72866ddc8d
commit 5f9302775e
8 files changed
+55 -30

No files matched your search

+44 -1
View File
@@ -19,6 +19,7 @@ test('modules are summaries with one link to each editor', async ({page}) => {
]) {
const card = modules.getByRole('region', {name: section, exact: true});
await expect(card.getByRole('button', {name: 'Edit', exact: true})).toHaveCount(0);
await expect(card.locator('.rp-light.info')).toHaveCount(0);
await card.getByRole('link', {name: 'Open page'}).click();
await expect(page).toHaveURL(new RegExp('#/' + path));
if (section === 'global') await expect(page.getByRole('region', {name: 'Persistent global settings'})).toBeInViewport();
@@ -68,6 +69,7 @@ test('legacy validation links focus diagnostics beside the source at its line',
await expect(page.getByRole('tab', {name: 'Config files', exact: true})).toHaveAttribute('aria-selected', 'true');
await expect(page.getByRole('tab', {name: 'Validation', exact: true})).toHaveCount(0);
await expect(page.getByRole('region', {name: 'Diagnostics', exact: true})).toBeFocused();
await expect(page.getByRole('region', {name: 'Diagnostics', exact: true})).toBeInViewport();
await expect(page.locator('.cm-activeLine')).toContainText('tproxy_port:');
await expect(page.getByRole('list', {name: 'Diagnostics'})).toHaveCount(1);
});
@@ -179,9 +181,20 @@ test('global controls share widths and align beneath wrapped labels', async ({pa
elements.map(element => {
const outer = element.getBoundingClientRect();
const control = element.querySelector('.rp-input, .rp-selectbtn')!.getBoundingClientRect();
return {row: outer.top, top: control.top, width: control.width, height: control.height};
const label = element.querySelector('label')!;
const range = document.createRange();
range.selectNodeContents(label);
return {row: outer.top, top: control.top, width: control.width, height: control.height, labelLines: range.getClientRects().length};
})
);
if (width === 390) expect.soft(fields.every(field => field.labelLines === 1)).toBe(true);
await expect.soft(page.locator('[data-setting] > .rp-field[style*="width"]')).toHaveCount(0);
const notes = page.getByRole('region', {name: 'Temporary runtime overrides'}).locator('.rp-fieldgrid > .rp-label');
await expect(notes).toHaveCount(2);
for (const note of await notes.all())
expect
.soft(await note.evaluate(element => element.getBoundingClientRect().width / element.parentElement!.getBoundingClientRect().width))
.toBeGreaterThan(0.99);
expect(Math.max(...fields.map(field => field.width)) - Math.min(...fields.map(field => field.width))).toBeLessThanOrEqual(1);
for (const row of new Set(fields.map(field => field.row))) {
const controls = fields.filter(field => field.row === row);
@@ -270,6 +283,36 @@ for (const mode of ['validation', 'restart'] as const) {
await expect(card).toContainText(mode === 'restart' ? '1 setting takes effect only after a restart; nothing written' : 'Validation found 1 error');
});
}
test('diagnostic source actions show a button and open the named file', async ({page}) => {
await mockBackend(page, {faults: true});
await page.goto('/#/config?tab=validate');
const action = page
.getByRole('region', {name: 'Diagnostics', exact: true})
.getByRole('button', {name: /Open.*rules.dae/})
.first();
await expect(action).toBeVisible();
await expect(action).not.toHaveClass(/quiet/);
await expect(action).toContainText('Open');
await action.click();
await expect(page).toHaveURL(/source=src-rules/);
});
for (const width of [390, 1440]) {
test(`accepted diagnostics retain focus and provenance with redacted sources at ${width}px`, async ({page}) => {
await page.setViewportSize({width, height: 1000});
const {api, handlers} = await mockBackend(page, {faults: true});
const config = await api.config();
config.sources[0].content = '<redacted>';
handlers['GET config'] = async () => config;
await page.goto('/#/config?tab=validate');
const panel = page.getByRole('region', {name: 'Diagnostics', exact: true});
await expect(panel).toBeFocused();
await expect(panel).toBeInViewport();
await expect(panel).toContainText('accepted configuration');
await expect(panel.getByRole('listitem').first()).toBeVisible();
await expect(panel).not.toContainText('Current config file diagnostics');
});
}
test('invalid stored hex ports remain visible and can be corrected', async ({page}) => {
const {api, handlers} = await mockBackend(page);
+1 -1
View File
@@ -29,7 +29,7 @@ export function Modules(props: ModulesProps) {
</div>
)}
{card.summary && (
<Light small tone={card.block ? 'info' : 'muted'}>
<Light small tone="muted">
{card.summary}
</Light>
)}
+2 -2
View File
@@ -144,8 +144,8 @@ export function SourceCard(props: SourceCardProps) {
<Light small tone={item.tone}>
{item.detail}
</Light>
<Button small quiet label={t('config.openSourceAt', {where: item.where})} onPress={() => props.open(item.sourceId, item.line)}>
{item.where}
<Button small onPress={() => props.open(item.sourceId, item.line)}>
{t('config.openSourceAt', {where: item.where})}
</Button>
</div>
))}
+1 -1
View File
@@ -97,7 +97,7 @@ export function useConfigPage({go, query}: PageProps) {
editor,
focusLine,
generation: config.data?.generation_id ?? '',
focusDiagnostics: params.get('tab') === 'validate' || params.get('panel') === 'diagnostics'
focusDiagnostics: params.get('tab') === 'validate'
}
: null;
const newSourceProps: NewSourceProps | null =
+4
View File
@@ -323,3 +323,7 @@ it('prefers reported source reasons over inferred credentials and falls back for
}
expect(readOnlyBadge({...source, read_only_reason: 'future' as never}, true, true, honk, t)?.reason).toBe('secret');
});
it('does not invent a source filename when no main file exists', () => {
expect(sectionSummaries([], honk, 'en', t).every(card => card.range === '')).toBe(true);
});
+1 -1
View File
@@ -149,7 +149,7 @@ export function sectionSummaries(sources: ConfigSource[], engine: Engine, lang:
source: main,
block: null,
href,
range: main ? fileName(main) : 'config.dae',
range: main ? fileName(main) : '',
// Only a writable main file is offered as the place to add the section.
summary: main?.writable ? t('config.moduleAbsent', {file: fileName(main)}) : t('config.moduleAbsentReadOnly'),
note: null
-1
View File
@@ -46,7 +46,6 @@ export function GlobalSettings(props: PageProps) {
<TextField
label={field.key}
name={field.key}
width={240}
value={field.value}
onChange={field.change}
isDisabled={!m.writable || m.busy || field.duplicate}
+2 -23
View File
@@ -229,29 +229,8 @@
width: 100% !important;
min-width: 0;
}
.rp-fieldgrid :is(label, .lbl, .rp-label) {
overflow-wrap: anywhere;
}
/* On a phone a row of settings fields sits in two even columns instead of wrapping to ragged widths. */
@media (max-width: 599.98px) {
.rp-toolbar.rp-fieldgrid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
align-items: start;
}
.rp-fieldgrid > * {
width: auto !important;
min-width: 0;
}
.rp-fieldgrid :is(.rp-field > label, .lbl) {
min-height: 32px;
}
.rp-fieldgrid :is(.rp-input, .rp-selectbtn) {
width: 100%;
}
.rp-fieldgrid > .rp-label {
grid-column: 1 / -1;
}
.rp-fieldgrid > .rp-label {
grid-column: 1 / -1;
}
/* A searchable picker's popover spans its trigger, as a picker's list does; the virtual rows cannot size it. */