diff --git a/docs/gitbook/references/plugins/dashboard-anchors.md b/docs/gitbook/references/plugins/dashboard-anchors.md index 897a6b12b..053963e31 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 729aafe74..d5c88b2ba 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 4dc5767d4..8a70cef9b 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 e077629bf..17dc51168 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])