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 demo banner notice on InlineNotice primitive

rcourtman0f58d9d9d473
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 53f87fedb8..87d014531a 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -310,6 +310,11 @@ canonical `agent` resource type. Kubernetes is cluster-agent-backed: canonical
rows, so the unified-resource owner must project the cluster agent identity and
cluster-scoped agent version onto those node rows before the shared stale-agent
collector can decide whether the node inventory is gated by an older agent.
+Global dismissible notice bars are also part of the shared `InlineNotice`
+boundary. `frontend-modern/src/components/DemoBanner.tsx` must compose
+`InlineNotice` with the `banner` layout, the shared icon library, and the
+primitive's dismiss slot instead of carrying a local blue notice shell, raw SVG
+status icon, or page-local close button classes.
Kubernetes policy inventory follows that same primitive boundary while the
unified-resource owner supplies NetworkPolicy policy type and rule-count
columns, PodDisruptionBudget budget and observed health columns, ResourceQuota
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index e61daafc0d..a1f4bb8ab9 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -517,6 +517,33 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "demo-banner-notice-shell",
+ "category": "callout",
+ "summary": "Dismissible global demo-mode notices must compose InlineNotice banner layout and shared dismiss chrome instead of copying local blue notice shells, raw SVG icons, or page-local close buttons.",
+ "canonical": {
+ "path": "src/components/shared/InlineNotice.tsx",
+ "export": "InlineNotice"
+ },
+ "requiredConsumers": [{ "path": "src/components/DemoBanner.tsx" }],
+ "forbiddenPatterns": [
+ {
+ "path": "src/components/DemoBanner.tsx",
+ "patterns": [
+ "<svg",
+ "<button",
+ "bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800",
+ "p-1 hover:bg-blue-100 dark:hover:bg-blue-800 rounded text-blue-600"
+ ]
+ }
+ ],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/__tests__/DemoBanner.test.tsx",
+ "src/components/shared/InlineNotice.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "status-dot-shell",
"category": "status-indicator",
diff --git a/frontend-modern/src/components/DemoBanner.tsx b/frontend-modern/src/components/DemoBanner.tsx
index 3993e0eb0d..7bfa9b6dee 100644
--- a/frontend-modern/src/components/DemoBanner.tsx
+++ b/frontend-modern/src/components/DemoBanner.tsx
@@ -1,4 +1,6 @@
+import InfoIcon from 'lucide-solid/icons/info';
import { createSignal, onMount, Show } from 'solid-js';
+import { InlineNotice } from '@/components/shared/InlineNotice';
import { presentationPolicyIsDemoMode } from '@/stores/sessionPresentationPolicy';
export function DemoBanner() {
@@ -18,34 +20,17 @@ export function DemoBanner() {
return (
<Show when={presentationPolicyIsDemoMode() && !dismissed()}>
- <div class="bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800 px-3 py-2">
- <div class="container mx-auto flex items-center justify-between text-sm">
- <div class="flex items-center gap-2 text-blue-700 dark:text-blue-300">
- <svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
- <path
- fill-rule="evenodd"
- d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z"
- clip-rule="evenodd"
- />
- </svg>
- <span>Demo instance with mock data (read-only)</span>
- </div>
- <button
- onClick={handleDismiss}
- class="p-1 hover:bg-blue-100 dark:hover:bg-blue-800 rounded text-blue-600 dark:text-blue-400 transition-colors"
- title="Dismiss"
- >
- <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M6 18L18 6M6 6l12 12"
- />
- </svg>
- </button>
- </div>
- </div>
+ <InlineNotice
+ role="status"
+ tone="info"
+ layout="banner"
+ icon={<InfoIcon class="h-4 w-4" aria-hidden="true" />}
+ onDismiss={handleDismiss}
+ dismissLabel="Dismiss demo banner"
+ dismissTitle="Dismiss"
+ >
+ Demo instance with mock data (read-only)
+ </InlineNotice>
</Show>
);
}
diff --git a/frontend-modern/src/components/__tests__/DemoBanner.test.tsx b/frontend-modern/src/components/__tests__/DemoBanner.test.tsx
index 776a078680..abc1a361eb 100644
--- a/frontend-modern/src/components/__tests__/DemoBanner.test.tsx
+++ b/frontend-modern/src/components/__tests__/DemoBanner.test.tsx
@@ -1,5 +1,6 @@
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import demoBannerSource from '@/components/DemoBanner.tsx?raw';
/* ------------------------------------------------------------------ */
/* Mocks */
@@ -33,6 +34,19 @@ describe('DemoBanner', () => {
render(() => <DemoBanner />);
}
+ it('keeps demo notice chrome on shared InlineNotice primitives', () => {
+ expect(demoBannerSource).toContain('InlineNotice');
+ expect(demoBannerSource).toContain('layout="banner"');
+ expect(demoBannerSource).toContain('lucide-solid/icons/info');
+ expect(demoBannerSource).not.toContain('<svg');
+ expect(demoBannerSource).not.toContain(
+ 'bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800',
+ );
+ expect(demoBannerSource).not.toContain(
+ 'p-1 hover:bg-blue-100 dark:hover:bg-blue-800 rounded text-blue-600',
+ );
+ });
+
/* ---------- Visibility ---------- */
it('shows the banner when demo mode is enabled', async () => {
diff --git a/frontend-modern/src/components/shared/InlineNotice.test.tsx b/frontend-modern/src/components/shared/InlineNotice.test.tsx
index 8aef715a30..2fcf5daf51 100644
--- a/frontend-modern/src/components/shared/InlineNotice.test.tsx
+++ b/frontend-modern/src/components/shared/InlineNotice.test.tsx
@@ -1,5 +1,5 @@
-import { cleanup, render, screen } from '@solidjs/testing-library';
-import { afterEach, describe, expect, it } from 'vitest';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it, vi } from 'vitest';
import { InlineNotice } from './InlineNotice';
describe('InlineNotice', () => {
@@ -52,4 +52,28 @@ describe('InlineNotice', () => {
const notice = screen.getByText('Shared informational notice.').closest('.rounded-lg');
expect(notice?.className).toContain('border-blue-300');
});
+
+ it('owns dismissible banner notice layout and close action chrome', () => {
+ const onDismiss = vi.fn();
+
+ render(() => (
+ <InlineNotice
+ role="status"
+ tone="info"
+ layout="banner"
+ onDismiss={onDismiss}
+ dismissLabel="Dismiss demo banner"
+ dismissTitle="Dismiss"
+ >
+ Demo instance with mock data.
+ </InlineNotice>
+ ));
+
+ const notice = screen.getByRole('status');
+ expect(notice.className).toContain('rounded-none');
+ expect(notice.className).toContain('border-x-0');
+ fireEvent.click(screen.getByRole('button', { name: 'Dismiss demo banner' }));
+
+ expect(onDismiss).toHaveBeenCalledOnce();
+ });
});
diff --git a/frontend-modern/src/components/shared/InlineNotice.tsx b/frontend-modern/src/components/shared/InlineNotice.tsx
index fdbf223e2f..ce845021d7 100644
--- a/frontend-modern/src/components/shared/InlineNotice.tsx
+++ b/frontend-modern/src/components/shared/InlineNotice.tsx
@@ -1,19 +1,30 @@
+import XIcon from 'lucide-solid/icons/x';
import { mergeProps, Show, splitProps, type JSX } from 'solid-js';
+import { ActionIconButton } from './Button';
export type InlineNoticeTone = 'danger' | 'info' | 'success' | 'warning';
+export type InlineNoticeLayout = 'inline' | 'banner';
interface InlineNoticeProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'class'> {
tone?: InlineNoticeTone;
+ layout?: InlineNoticeLayout;
icon?: JSX.Element;
actionHref?: string;
actionLabel?: JSX.Element;
actionIcon?: JSX.Element;
actionAriaLabel?: string;
+ onDismiss?: () => void;
+ dismissLabel?: string;
+ dismissTitle?: string;
class?: string;
}
-export const INLINE_NOTICE_BASE_CLASS =
- 'flex items-start gap-2 rounded-lg border px-3 py-2 text-sm';
+export const INLINE_NOTICE_BASE_CLASS = 'flex items-start gap-2 border px-3 py-2 text-sm';
+
+export const INLINE_NOTICE_LAYOUT_CLASSES: Record<InlineNoticeLayout, string> = {
+ inline: 'rounded-lg',
+ banner: 'rounded-none border-x-0 border-t-0',
+};
export const INLINE_NOTICE_TONE_CLASSES: Record<InlineNoticeTone, string> = {
danger:
@@ -44,23 +55,30 @@ const INLINE_NOTICE_ACTION_ICON_CLASS =
'inline-flex h-3.5 w-3.5 items-center justify-center [&>svg]:h-3.5 [&>svg]:w-3.5';
export function InlineNotice(props: InlineNoticeProps) {
- const merged = mergeProps({ tone: 'warning' as InlineNoticeTone }, props);
+ const merged = mergeProps(
+ { tone: 'warning' as InlineNoticeTone, layout: 'inline' as InlineNoticeLayout },
+ props,
+ );
const [local, rest] = splitProps(merged, [
'tone',
+ 'layout',
'icon',
'actionHref',
'actionLabel',
'actionIcon',
'actionAriaLabel',
+ 'onDismiss',
+ 'dismissLabel',
+ 'dismissTitle',
'children',
'class',
]);
return (
<div
- class={`${INLINE_NOTICE_BASE_CLASS} ${INLINE_NOTICE_TONE_CLASSES[local.tone]} ${
- local.class ?? ''
- }`.trim()}
+ class={`${INLINE_NOTICE_BASE_CLASS} ${INLINE_NOTICE_LAYOUT_CLASSES[local.layout]} ${
+ INLINE_NOTICE_TONE_CLASSES[local.tone]
+ } ${local.class ?? ''}`.trim()}
{...rest}
>
<Show when={local.icon}>
@@ -93,6 +111,21 @@ export function InlineNotice(props: InlineNoticeProps) {
)}
</Show>
</div>
+ <Show when={local.onDismiss}>
+ {(onDismiss) => (
+ <ActionIconButton
+ type="button"
+ label={local.dismissLabel ?? 'Dismiss notice'}
+ title={local.dismissTitle ?? local.dismissLabel ?? 'Dismiss notice'}
+ tone="muted"
+ size="sm"
+ class="-mr-1 -mt-1"
+ onClick={() => onDismiss()()}
+ >
+ <XIcon class="h-4 w-4" aria-hidden="true" />
+ </ActionIconButton>
+ )}
+ </Show>
</div>
);
}
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index a9dfe53374..fa4f6cf184 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -3,6 +3,7 @@ import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
import calloutCardSource from '@/components/shared/CalloutCard.tsx?raw';
import inlineNoticeSource from '@/components/shared/InlineNotice.tsx?raw';
+import demoBannerSource from '@/components/DemoBanner.tsx?raw';
import assistantCommandHelpDialogSource from '@/components/AI/Chat/AssistantCommandHelpDialog.tsx?raw';
import chatMessagesSource from '@/components/AI/Chat/ChatMessages.tsx?raw';
import aiChatSource from '@/components/AI/Chat/index.tsx?raw';
@@ -3937,6 +3938,48 @@ describe('shared primitive guardrails', () => {
}
});
+ it('routes dismissible demo notices through InlineNotice banner 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 === 'demo-banner-notice-shell');
+
+ expect(registeredRule?.canonical?.path).toBe('src/components/shared/InlineNotice.tsx');
+ expect(registeredRule?.canonical?.export).toBe('InlineNotice');
+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual([
+ 'src/components/DemoBanner.tsx',
+ ]);
+ expect(registeredRule?.forbiddenPatterns).toEqual([
+ {
+ path: 'src/components/DemoBanner.tsx',
+ patterns: [
+ '<svg',
+ '<button',
+ 'bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800',
+ 'p-1 hover:bg-blue-100 dark:hover:bg-blue-800 rounded text-blue-600',
+ ],
+ },
+ ]);
+ expect(inlineNoticeSource).toContain('INLINE_NOTICE_LAYOUT_CLASSES');
+ expect(inlineNoticeSource).toContain('ActionIconButton');
+ expect(demoBannerSource).toContain('InlineNotice');
+ expect(demoBannerSource).toContain('layout="banner"');
+ expect(demoBannerSource).toContain('lucide-solid/icons/info');
+ expect(demoBannerSource).not.toContain('<svg');
+ expect(demoBannerSource).not.toContain('<button');
+ expect(demoBannerSource).not.toContain(
+ 'bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800',
+ );
+ expect(demoBannerSource).not.toContain(
+ 'p-1 hover:bg-blue-100 dark:hover:bg-blue-800 rounded text-blue-600',
+ );
+ });
+
it('keeps TLS verification warnings in the shared primitive boundary', () => {
expect(tlsVerificationWarningBannerSource).toContain('role="alert"');
expect(tlsVerificationWarningBannerSource).toContain('TLS verification disabled.');