Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/gitbook/references/plugins/dashboard-anchors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
4 changes: 3 additions & 1 deletion reposilite-frontend/src/anchors/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,9 @@
"file": "src/components/md/MdAlert.vue",
"stability": "experimental",
"parts": [],
"states": []
"states": [
"error"
]
},
{
"name": "md-badge",
Expand Down
12 changes: 12 additions & 0 deletions reposilite-frontend/src/components/md/MdAlert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' } })

Expand Down
37 changes: 36 additions & 1 deletion reposilite-frontend/src/components/md/MdAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,42 @@ const style = computed(() => TONES[props.tone])

<template>
<div
:role="tone === 'error' ? 'alert' : 'status'"
v-if="tone === 'error'"
role="alert"
data-tone="error"
:class="['flex items-start gap-3 rounded-corner-medium p-4', style.container]"
data-ingot-component="md-alert"
data-ingot-state="error"
>
<MdIcon
:path="style.path"
size="md"
:class="['mt-0.5 shrink-0', style.icon]"
/>
<div class="flex min-w-0 flex-1 flex-col gap-2">
<p
v-if="title"
class="md-title-small m-0"
>
{{ title }}
</p>
<div
v-if="$slots.default"
class="md-body-medium"
>
<slot />
</div>
<div
v-if="$slots.action"
class="flex flex-wrap gap-2"
>
<slot name="action" />
</div>
</div>
</div>
<div
v-else
role="status"
:data-tone="tone"
:class="['flex items-start gap-3 rounded-corner-medium p-4', style.container]"
data-ingot-component="md-alert"
Expand Down
Loading