From a6f739bb759f2c87f6cd9f065b1989091bf92df1 Mon Sep 17 00:00:00 2001 From: TheMeinerLP Date: Sat, 28 Nov 2026 18:29:31 +0100 Subject: [PATCH] fix(ui): let the alert carry its error state anchor An inline error notice was announced as an alert but did not say in the anchor that it was an error, so plugins matching on the state could not tell it apart from a plain status line. The alert now marks its root with the error state itself, which lets the call sites stop repeating it. Other tones carry no state. This is additive: a new state on an existing anchor. Nothing is removed or renamed. --- .../references/plugins/dashboard-anchors.md | 2 +- reposilite-frontend/src/anchors/registry.json | 4 +- .../src/components/md/MdAlert.test.ts | 12 ++++++ .../src/components/md/MdAlert.vue | 37 ++++++++++++++++++- 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/docs/gitbook/references/plugins/dashboard-anchors.md b/docs/gitbook/references/plugins/dashboard-anchors.md index 897a6b12b9..053963e316 100644 --- a/docs/gitbook/references/plugins/dashboard-anchors.md +++ b/docs/gitbook/references/plugins/dashboard-anchors.md @@ -106,7 +106,7 @@ The dashboard animates a change of page, a menu, a dialog and a few other surfac | `maintenance-view` | experimental | `src/components/maintenance/MaintenanceView.vue` | none | none | none | | `mapping-step` | experimental | `src/components/migration/MappingStep.vue` | none | none | none | | `maven-options-panel` | experimental | `src/components/repositories/MavenOptionsPanel.vue` | none | none | none | -| `md-alert` | experimental | `src/components/md/MdAlert.vue` | none | none | none | +| `md-alert` | experimental | `src/components/md/MdAlert.vue` | none | `error` | none | | `md-avatar` | experimental | `src/components/md/MdAvatar.vue` | none | none | none | | `md-badge` | experimental | `src/components/md/MdBadge.vue` | none | none | none | | `md-breadcrumb` | experimental | `src/components/md/MdBreadcrumb.vue` | none | none | none | diff --git a/reposilite-frontend/src/anchors/registry.json b/reposilite-frontend/src/anchors/registry.json index 729aafe746..d5c88b2ba6 100644 --- a/reposilite-frontend/src/anchors/registry.json +++ b/reposilite-frontend/src/anchors/registry.json @@ -784,7 +784,9 @@ "file": "src/components/md/MdAlert.vue", "stability": "experimental", "parts": [], - "states": [] + "states": [ + "error" + ] }, { "name": "md-badge", diff --git a/reposilite-frontend/src/components/md/MdAlert.test.ts b/reposilite-frontend/src/components/md/MdAlert.test.ts index 4dc5767d45..8a70cef9b5 100644 --- a/reposilite-frontend/src/components/md/MdAlert.test.ts +++ b/reposilite-frontend/src/components/md/MdAlert.test.ts @@ -65,6 +65,18 @@ describe('MdAlert', () => { expect(wrapper.find('button').text(), 'the action slot must render its button').toBe('Review') }) + it('marks the root with the error state only for the error tone', () => { + const error = mount(MdAlert, { props: { tone: 'error', title: 'Upload failed' } }) + + expect(error.attributes('data-ingot-state'), 'the error tone must carry the error state').toBe('error') + }) + + it.each(['warning', 'tertiary', 'info'] as const)('carries no state on the %s tone', (tone) => { + const wrapper = mount(MdAlert, { props: { tone, title: 'Heads up' } }) + + expect(wrapper.attributes('data-ingot-state'), `the ${tone} tone must not carry a state`).toBeUndefined() + }) + it('carries the anchor on the root', () => { const wrapper = mount(MdAlert, { props: { title: 'Heads up' } }) diff --git a/reposilite-frontend/src/components/md/MdAlert.vue b/reposilite-frontend/src/components/md/MdAlert.vue index e077629bfe..17dc51168e 100644 --- a/reposilite-frontend/src/components/md/MdAlert.vue +++ b/reposilite-frontend/src/components/md/MdAlert.vue @@ -53,7 +53,42 @@ const style = computed(() => TONES[props.tone])