Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Converge toast notification chrome on shared primitives

rcourtman0bc0b8a34631
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 249f4ee1ff..53f87fedb8 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -205,6 +205,13 @@ Native multiline form fields are also a shared primitive boundary.
textarea chrome for alert, settings, and infrastructure runtime surfaces; those
surfaces must not recreate raw native `<textarea>` shells locally.
+Toast notification chrome is a shared primitive boundary. `Toast` owns the
+global notification stack shell, status icon placement, and dismiss action
+chrome; status glyphs must come from the shared library icon set and dismiss
+controls must compose `ActionIconButton`. Consumer-specific raw SVG status
+icons, toast-local close-button class strings, and page-local toast stacks are
+forbidden unless the shared-template registry is intentionally extended first.
+
The System Updates install guide is a shared settings primitive, not a
deployment-lane-only panel. `UpdateInstallGuide` must render the canonical
update-plan readiness verdict inline with the update action, and a blocked
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index e9bb6213e9..e61daafc0d 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -130,6 +130,32 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "toast-notification-shell",
+ "category": "notification",
+ "summary": "Toast notification status icons and dismiss actions must compose library icons and ActionIconButton so every page inherits shared notification chrome instead of raw SVG glyphs or local close-button classes.",
+ "canonical": {
+ "path": "src/components/Toast/Toast.tsx",
+ "export": "Toast"
+ },
+ "requiredConsumers": [{ "path": "src/components/Toast/Toast.tsx" }],
+ "forbiddenPatterns": [
+ {
+ "path": "src/components/Toast/Toast.tsx",
+ "patterns": [
+ "<svg",
+ "const icons = {",
+ "flex-shrink-0 text-muted hover:text-base-content hover:bg-surface rounded-md p-1.5 transition-all duration-200"
+ ]
+ }
+ ],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/Toast/__tests__/Toast.test.tsx",
+ "src/components/shared/Button.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "inline-detail-section-panel-shell",
"category": "row-detail",
diff --git a/frontend-modern/src/components/Toast/Toast.tsx b/frontend-modern/src/components/Toast/Toast.tsx
index f21a7a66b4..9c2687eaf1 100644
--- a/frontend-modern/src/components/Toast/Toast.tsx
+++ b/frontend-modern/src/components/Toast/Toast.tsx
@@ -1,5 +1,11 @@
import { Component, createSignal, For, Show, onCleanup, onMount } from 'solid-js';
import { Portal } from 'solid-js/web';
+import AlertTriangleIcon from 'lucide-solid/icons/alert-triangle';
+import CheckCircleIcon from 'lucide-solid/icons/check-circle';
+import CircleAlertIcon from 'lucide-solid/icons/circle-alert';
+import InfoIcon from 'lucide-solid/icons/info';
+import XIcon from 'lucide-solid/icons/x';
+import { ActionIconButton } from '@/components/shared/Button';
import { POLLING_INTERVALS } from '@/constants';
import { getSemanticTonePresentation } from '@/utils/semanticTonePresentation';
@@ -24,47 +30,19 @@ export const Toast: Component<ToastProps> = (props) => {
let autoRemoveTimer: number | undefined;
let closeAnimationTimer: number | undefined;
- const icons = {
- success: (
- <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2.5"
- d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
- />
- </svg>
- ),
- error: (
- <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2.5"
- d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
- />
- </svg>
- ),
- warning: (
- <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2.5"
- d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
- />
- </svg>
- ),
- info: (
- <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2.5"
- d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
- />
- </svg>
- ),
+ const icon = () => {
+ const iconClass = 'h-5 w-5';
+ switch (props.toast.type) {
+ case 'success':
+ return <CheckCircleIcon class={iconClass} aria-hidden="true" />;
+ case 'error':
+ return <CircleAlertIcon class={iconClass} aria-hidden="true" />;
+ case 'warning':
+ return <AlertTriangleIcon class={iconClass} aria-hidden="true" />;
+ case 'info':
+ default:
+ return <InfoIcon class={iconClass} aria-hidden="true" />;
+ }
};
const iconTone = () => getSemanticTonePresentation(props.toast.type);
@@ -124,7 +102,7 @@ export const Toast: Component<ToastProps> = (props) => {
<div
class={`flex-shrink-0 flex items-center justify-center p-1.5 sm:p-2 rounded-md border bg-surface ${iconTone().iconClass} ${iconTone().panelClass}`}
>
- {icons[props.toast.type]}
+ {icon()}
</div>
<div class="flex-1">
<h3 class="text-sm font-medium text-base-content">{props.toast.title}</h3>
@@ -140,22 +118,17 @@ export const Toast: Component<ToastProps> = (props) => {
</details>
</Show>
</div>
- <button
+ <ActionIconButton
type="button"
onClick={handleClose}
- aria-label="Dismiss notification"
+ label="Dismiss notification"
title="Dismiss"
- class="flex-shrink-0 text-muted hover:text-base-content hover:bg-surface rounded-md p-1.5 transition-all duration-200"
+ tone="muted"
+ size="sm"
+ class="flex-shrink-0"
>
- <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M6 18L18 6M6 6l12 12"
- />
- </svg>
- </button>
+ <XIcon class="h-4 w-4" aria-hidden="true" />
+ </ActionIconButton>
</div>
</div>
);
diff --git a/frontend-modern/src/components/Toast/__tests__/Toast.test.tsx b/frontend-modern/src/components/Toast/__tests__/Toast.test.tsx
index 4317d0cac1..f96f11bf8e 100644
--- a/frontend-modern/src/components/Toast/__tests__/Toast.test.tsx
+++ b/frontend-modern/src/components/Toast/__tests__/Toast.test.tsx
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
import { batch } from 'solid-js';
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { Toast, ToastContainer } from '@/components/Toast/Toast';
+import toastSource from '@/components/Toast/Toast.tsx?raw';
describe('Toast', () => {
afterEach(() => {
@@ -93,4 +94,18 @@ describe('Toast', () => {
// Message is directly visible as a subtitle
expect(screen.getByText('The node is currently offline')).toBeInTheDocument();
});
+
+ it('keeps toast status and dismiss chrome on shared primitives', () => {
+ expect(toastSource).toContain('ActionIconButton');
+ expect(toastSource).toContain('lucide-solid/icons/check-circle');
+ expect(toastSource).toContain('lucide-solid/icons/circle-alert');
+ expect(toastSource).toContain('lucide-solid/icons/alert-triangle');
+ expect(toastSource).toContain('lucide-solid/icons/info');
+ expect(toastSource).toContain('lucide-solid/icons/x');
+ expect(toastSource).not.toContain('<svg');
+ expect(toastSource).not.toContain('const icons = {');
+ expect(toastSource).not.toContain(
+ 'flex-shrink-0 text-muted hover:text-base-content hover:bg-surface rounded-md p-1.5 transition-all duration-200',
+ );
+ });
});
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index c93729d79b..a9dfe53374 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -112,6 +112,7 @@ import webInterfaceUrlFieldModelSource from '@/components/shared/webInterfaceUrl
import webInterfaceUrlFieldStateSource from '@/components/shared/useWebInterfaceUrlFieldState.ts?raw';
import webInterfaceNameLinkSource from '@/components/shared/WebInterfaceNameLink.tsx?raw';
import inlineDetailTableRowSource from '@/components/shared/InlineDetailTableRow.tsx?raw';
+import toastSource from '@/components/Toast/Toast.tsx?raw';
import sharedTemplateRegistrySource from '../../../scripts/shared-template-registry.json?raw';
import discoveryTabSource from '@/components/Discovery/DiscoveryTab.tsx?raw';
import emailProviderSelectSource from '@/components/Alerts/EmailProviderSelect.tsx?raw';
@@ -322,6 +323,45 @@ describe('shared primitive guardrails', () => {
expect(rawTableUsers).toEqual(['./PulseDataGrid.tsx']);
});
+ it('keeps toast notification chrome on shared action and icon primitives', () => {
+ const registry = JSON.parse(sharedTemplateRegistrySource) as {
+ rules?: Array<{
+ id: string;
+ canonical?: { path?: string; export?: string };
+ requiredConsumers?: Array<{ path?: string }>;
+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;
+ }>;
+ };
+ const registeredRule = registry.rules?.find((rule) => rule.id === 'toast-notification-shell');
+
+ expect(registeredRule?.canonical?.path).toBe('src/components/Toast/Toast.tsx');
+ expect(registeredRule?.canonical?.export).toBe('Toast');
+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual([
+ 'src/components/Toast/Toast.tsx',
+ ]);
+ expect(registeredRule?.forbiddenPatterns).toEqual([
+ {
+ path: 'src/components/Toast/Toast.tsx',
+ patterns: [
+ '<svg',
+ 'const icons = {',
+ 'flex-shrink-0 text-muted hover:text-base-content hover:bg-surface rounded-md p-1.5 transition-all duration-200',
+ ],
+ },
+ ]);
+ expect(toastSource).toContain('ActionIconButton');
+ expect(toastSource).toContain('lucide-solid/icons/check-circle');
+ expect(toastSource).toContain('lucide-solid/icons/circle-alert');
+ expect(toastSource).toContain('lucide-solid/icons/alert-triangle');
+ expect(toastSource).toContain('lucide-solid/icons/info');
+ expect(toastSource).toContain('lucide-solid/icons/x');
+ expect(toastSource).not.toContain('<svg');
+ expect(toastSource).not.toContain('const icons = {');
+ expect(toastSource).not.toContain(
+ 'flex-shrink-0 text-muted hover:text-base-content hover:bg-surface rounded-md p-1.5 transition-all duration-200',
+ );
+ });
+
it('routes canonical settings and feature segmented selectors through FilterButtonGroup', () => {
const registry = JSON.parse(sharedTemplateRegistrySource) as {
rules?: Array<{