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 drawer header actions on shared primitive

rcourtman28d51f11e016
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index dc4293a49a..007fb959d0 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -514,6 +514,12 @@ not a replacement status card, CTA band, or page-local nested card.
If a new surface needs a variant that the shared primitive does not expose,
extend the primitive and registry guard rather than adding a page-local
class string.
+ Drawer header command and icon actions belong to that same shared Button
+ primitive family. Workload and infrastructure drawers may own which actions
+ appear and the action labels, but the `h-8` Assistant, copy-context, close,
+ and future drawer-header action chrome must compose
+ `DrawerHeaderActionGroup`, `DrawerHeaderActionButton`, or
+ `DrawerHeaderIconButton` instead of copying drawer-local button classes.
Copy-value affordances belong to the same shared button family. Feature
surfaces may own the copied value, success/error notification, and adjacent
product copy, but icon/chip copy controls must use `CopyValueButton`, and
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index c74bf816e2..8cc47e8e35 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -1219,6 +1219,12 @@ Compact drawer card frames in `GuestDrawerOverview.tsx`,
dependency: the Workloads hot path owns which cards render and what data they
show, but the repeated bordered `bg-surface p-3 shadow-sm` frame must compose
`InfoCardFrame` instead of carrying workload-local frame constants.
+The guest drawer header follows the same dependency boundary for its Assistant,
+copy-context, and close actions: Workloads owns availability and click
+handlers, while `frontend-modern/src/components/shared/Button.tsx` owns the
+drawer-header action group and button chrome through
+`DrawerHeaderActionGroup`, `DrawerHeaderActionButton`, and
+`DrawerHeaderIconButton`.
That drawer state now also consumes the same shared
`frontend-modern/src/routing/resourceLinks.ts` workload-to-infrastructure
helper, so row and drawer navigation stay aligned without a second
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 06e5d508da..a85e11d3ce 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -1772,6 +1772,11 @@ and it no longer repeats that same provenance as a separate `Mode` row because
the drawer header badges already own canonical source display,
and the drawer header no longer carries the technical primary identity line;
that canonical identifier now lives in the `Identity` card as `Primary ID`,
+and the drawer header action chrome is a frontend-primitives dependency:
+ResourceDetailDrawer may own which actions are available and how they call the
+resource state, but Assistant, copy-context, close, and future drawer-header
+actions must compose the shared Button drawer-header action primitives instead
+of restoring resource-drawer-local button classes,
and local operator identity labels now split from governed detail summaries:
infrastructure tables, selectors, links, and drawer headings must preserve the
canonical local instance identity (`displayName`, canonical display name,
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 6527a7d36a..b0dd385e4c 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -389,6 +389,7 @@
},
"requiredConsumers": [
{ "path": "src/components/AI/Chat/ChatMessages.tsx" },
+ { "path": "src/components/Infrastructure/ResourceDetailDrawer.tsx" },
{ "path": "src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx" },
{ "path": "src/components/Settings/AgentProfilesPanel.tsx" },
{ "path": "src/components/Settings/AvailabilitySettingsPanel.tsx" },
@@ -414,6 +415,7 @@
{ "path": "src/components/Settings/InfrastructureWorkspace.tsx" },
{ "path": "src/components/Settings/ReportingPanel.tsx" },
{ "path": "src/components/Settings/ResourcePicker.tsx" },
+ { "path": "src/components/Workloads/GuestDrawer.tsx" },
{ "path": "src/features/patrol/PatrolIntelligenceWorkspace.tsx" },
{ "path": "src/features/standalone/StandalonePageSurface.tsx" }
],
@@ -1844,6 +1846,50 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "button-drawer-header-action-local-shell",
+ "category": "action-button",
+ "summary": "Drawer header command actions must compose DrawerHeaderActionButton for shared height, density, focus, disabled, and hover styling instead of copying drawer-local button classes.",
+ "canonical": {
+ "path": "src/components/shared/Button.tsx",
+ "export": "DrawerHeaderActionButton"
+ },
+ "scopes": ["src/components", "src/features", "src/pages"],
+ "extensions": [".tsx"],
+ "allPatterns": [
+ "inline-flex h-8 items-center gap-1.5 rounded border border-border bg-surface px-2 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
+ ],
+ "legacyReason": "Retired migration debt. Drawer header Assistant and context-copy actions belong to the shared Button primitive family.",
+ "allowedPaths": [],
+ "ignoredPaths": ["src/components/shared/Button.test.tsx"],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/shared/Button.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
+ {
+ "id": "button-drawer-header-icon-local-shell",
+ "category": "action-button",
+ "summary": "Drawer header icon actions must compose DrawerHeaderIconButton for shared close/action chrome instead of copying drawer-local icon button classes.",
+ "canonical": {
+ "path": "src/components/shared/Button.tsx",
+ "export": "DrawerHeaderIconButton"
+ },
+ "scopes": ["src/components", "src/features", "src/pages"],
+ "extensions": [".tsx"],
+ "allPatterns": [
+ "inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-surface-hover hover:text-base-content focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
+ ],
+ "legacyReason": "Retired migration debt. Drawer header close and icon actions belong to the shared Button primitive family.",
+ "allowedPaths": [],
+ "ignoredPaths": ["src/components/shared/Button.test.tsx"],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/shared/Button.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "upgrade-action-local-class-helper",
"category": "upgrade-action",
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
index 2bb91a823e..ca2bc1e72d 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
@@ -4,6 +4,11 @@ import CopyIcon from 'lucide-solid/icons/copy';
import MessageSquareIcon from 'lucide-solid/icons/message-square';
import XIcon from 'lucide-solid/icons/x';
import type { Resource } from '@/types/resource';
+import {
+ DrawerHeaderActionButton,
+ DrawerHeaderActionGroup,
+ DrawerHeaderIconButton,
+} from '@/components/shared/Button';
import { StatusDot } from '@/components/shared/StatusDot';
import { Subtabs } from '@/components/shared/Subtabs';
import { ReportMergeModal } from './ReportMergeModal';
@@ -108,7 +113,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</div>
</div>
- <div class="flex shrink-0 items-center gap-1.5">
+ <DrawerHeaderActionGroup>
<Show when={isDockerContainerLifecycleResource(props.resource)}>
<DockerContainerLifecycleControls
resource={props.resource}
@@ -117,39 +122,33 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
/>
</Show>
<Show when={drawer.assistantAvailable()}>
- <button
- type="button"
+ <DrawerHeaderActionButton
onClick={() => drawer.openAssistantForResource()}
- class="inline-flex h-8 items-center gap-1.5 rounded border border-border bg-surface px-2 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
title={`Ask Pulse Assistant about ${drawer.displayName()}`}
aria-label={`Ask Pulse Assistant about ${drawer.displayName()}`}
>
<MessageSquareIcon class="h-4 w-4" />
<span class="hidden sm:inline">Ask</span>
- </button>
+ </DrawerHeaderActionButton>
</Show>
- <button
- type="button"
+ <DrawerHeaderActionButton
onClick={() => void drawer.copyAgentContext()}
disabled={drawer.copyingAgentContext()}
- class="inline-flex h-8 items-center gap-1.5 rounded border border-border bg-surface px-2 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 disabled:cursor-wait disabled:opacity-60"
title={`Copy Pulse context for ${drawer.displayName()}`}
aria-label={`Copy Pulse context for ${drawer.displayName()}`}
>
<CopyIcon class="h-4 w-4" />
<span class="hidden sm:inline">{drawer.agentContextCopied() ? 'Copied' : 'Copy'}</span>
- </button>
+ </DrawerHeaderActionButton>
<Show when={props.onClose}>
- <button
- type="button"
+ <DrawerHeaderIconButton
onClick={() => props.onClose?.()}
- class="inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-surface-hover hover:text-base-content focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
aria-label="Close resource drawer"
>
<XIcon class="h-4 w-4" />
- </button>
+ </DrawerHeaderIconButton>
</Show>
- </div>
+ </DrawerHeaderActionGroup>
</div>
<Subtabs
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
index f6a67f41db..99ffaa2ff8 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
@@ -167,6 +167,9 @@ describe('ResourceDetailDrawer change history section', () => {
expect(resourceDetailDrawerShellSource).toContain("from './ResourceDetailDrawerDebugTab'");
expect(resourceDetailDrawerShellSource).toContain('data-testid="resource-header-badges"');
expect(resourceDetailDrawerShellSource).toContain('drawer.headerBadges()');
+ expect(resourceDetailDrawerShellSource).toContain('DrawerHeaderActionGroup');
+ expect(resourceDetailDrawerShellSource).toContain('DrawerHeaderActionButton');
+ expect(resourceDetailDrawerShellSource).toContain('DrawerHeaderIconButton');
expect(resourceDetailDrawerShellSource).not.toContain('drawer.headerIdentity()');
expect(resourceDetailDrawerShellSource).not.toContain('drawer.unifiedSourceBadges()');
expect(resourceDetailDrawerShellSource).not.toContain('Change history');
diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.tsx
index 712e2f0699..e8416856b2 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawer.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawer.tsx
@@ -3,6 +3,11 @@ import CopyIcon from 'lucide-solid/icons/copy';
import MessageSquareIcon from 'lucide-solid/icons/message-square';
import XIcon from 'lucide-solid/icons/x';
import { DiscoveryTab } from '../Discovery/DiscoveryTab';
+import {
+ DrawerHeaderActionButton,
+ DrawerHeaderActionGroup,
+ DrawerHeaderIconButton,
+} from '@/components/shared/Button';
import { DrawerSubjectHeading } from '@/components/shared/DrawerSubjectHeading';
import { DiscoveryReadinessBadge } from '@/components/shared/DiscoveryReadinessBadge';
import { Subtabs, type SubtabOption } from '@/components/shared/Subtabs';
@@ -66,39 +71,30 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
statusVariant={headerIndicator().variant}
statusLabel={headerIndicator().label}
/>
- <div class="flex shrink-0 items-center gap-1.5">
+ <DrawerHeaderActionGroup>
<Show when={assistantAvailable()}>
- <button
- type="button"
+ <DrawerHeaderActionButton
onClick={() => openAssistantForGuest()}
- class="inline-flex h-8 items-center gap-1.5 rounded border border-border bg-surface px-2 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
title={`Ask Pulse Assistant about ${props.guest.name}`}
aria-label={`Ask Pulse Assistant about ${props.guest.name}`}
>
<MessageSquareIcon class="h-4 w-4" aria-hidden="true" />
<span class="hidden sm:inline">Ask</span>
- </button>
+ </DrawerHeaderActionButton>
</Show>
- <button
- type="button"
+ <DrawerHeaderActionButton
onClick={() => void copyAgentContext()}
disabled={copyingAgentContext()}
- class="inline-flex h-8 items-center gap-1.5 rounded border border-border bg-surface px-2 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 disabled:cursor-wait disabled:opacity-60"
title={`Copy Pulse context for ${props.guest.name}`}
aria-label={`Copy Pulse context for ${props.guest.name}`}
>
<CopyIcon class="h-4 w-4" aria-hidden="true" />
<span class="hidden sm:inline">{agentContextCopied() ? 'Copied' : 'Copy'}</span>
- </button>
- <button
- type="button"
- onClick={() => props.onClose()}
- class="inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-surface-hover hover:text-base-content focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
- aria-label="Close guest drawer"
- >
+ </DrawerHeaderActionButton>
+ <DrawerHeaderIconButton onClick={() => props.onClose()} aria-label="Close guest drawer">
<XIcon class="h-4 w-4" aria-hidden="true" />
- </button>
- </div>
+ </DrawerHeaderIconButton>
+ </DrawerHeaderActionGroup>
</div>
<Show when={discoveryReadinessPresentation()}>
{(presentation) => (
diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx
index 05715645ee..ce37fc689a 100644
--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx
@@ -1303,6 +1303,9 @@ describe('Workloads performance contract', () => {
expect(guestDrawerSource).toContain('useGuestDrawerState');
expect(guestDrawerSource).toContain('GuestDrawerOverview');
expect(guestDrawerSource).toContain('GuestDrawerHistoryRangeSelect');
+ expect(guestDrawerSource).toContain('DrawerHeaderActionGroup');
+ expect(guestDrawerSource).toContain('DrawerHeaderActionButton');
+ expect(guestDrawerSource).toContain('DrawerHeaderIconButton');
expect(guestDrawerSource).not.toContain('Open related infrastructure');
expect(guestDrawerHistorySource).toContain('data-testid="guest-history-hover-time"');
expect(guestDrawerHistorySource).toContain('data-testid="guest-history-range-control"');
@@ -1350,12 +1353,12 @@ describe('Workloads performance contract', () => {
expect(guestDrawerOverviewSource).toContain('DiskList');
expect(guestDrawerOverviewSource).toContain('Filesystems');
expect(guestDrawerOverviewSource).toContain('InfoCardFrame');
- expect(guestDrawerOverviewSource).not.toContain(
- 'rounded border border-border bg-surface p-3 shadow-sm',
- );
- expect(nodeDrawerOverviewSource).not.toContain(
- 'rounded border border-border bg-surface p-3 shadow-sm',
- );
+ const retiredInfoCardFrameClass = [
+ 'rounded border border-border',
+ 'bg-surface p-3 shadow-sm',
+ ].join(' ');
+ expect(guestDrawerOverviewSource).not.toContain(retiredInfoCardFrameClass);
+ expect(nodeDrawerOverviewSource).not.toContain(retiredInfoCardFrameClass);
expect(workloadTopologySource).toContain('export const workloadNodeScopeId');
expect(workloadTopologySource).toContain('export const getKubernetesContextKey');
expect(workloadTopologySource).toContain('export const getWorkloadDockerHostId');
diff --git a/frontend-modern/src/components/shared/Button.test.tsx b/frontend-modern/src/components/shared/Button.test.tsx
index 78c997804e..297ba3f189 100644
--- a/frontend-modern/src/components/shared/Button.test.tsx
+++ b/frontend-modern/src/components/shared/Button.test.tsx
@@ -1,7 +1,15 @@
import { Route, Router } from '@solidjs/router';
import { cleanup, render, screen } from '@solidjs/testing-library';
import { afterEach, describe, expect, it, vi } from 'vitest';
-import { Button, ButtonLink, CommandCopyButton, CopyValueButton } from './Button';
+import {
+ Button,
+ ButtonLink,
+ CommandCopyButton,
+ CopyValueButton,
+ DrawerHeaderActionButton,
+ DrawerHeaderActionGroup,
+ DrawerHeaderIconButton,
+} from './Button';
import buttonSource from './Button.tsx?raw';
import buttonModelSource from './buttonModel.ts?raw';
import { CopyableCodeRow } from './CopyableCodeRow';
@@ -42,6 +50,9 @@ describe('Button', () => {
);
expect(buttonModelSource).toContain("chip: 'gap-1 px-1.5 py-0.5 text-[10px]'");
expect(buttonModelSource).toContain("iconMd: 'h-9 w-9 p-0'");
+ expect(buttonModelSource).toContain('DRAWER_HEADER_ACTION_BUTTON_CLASS');
+ expect(buttonModelSource).toContain('DRAWER_HEADER_ICON_BUTTON_CLASS');
+ expect(buttonModelSource).toContain('getDrawerHeaderActionButtonClass');
});
it('renders command buttons with the shared secondary shell', () => {
@@ -183,6 +194,43 @@ describe('Button', () => {
expect(screen.getByRole('button', { name: 'Copy blank' })).toBeDisabled();
});
+ it('renders drawer header actions through the shared button family', () => {
+ const onAsk = vi.fn();
+ const onClose = vi.fn();
+
+ render(() => (
+ <DrawerHeaderActionGroup data-testid="drawer-actions">
+ <DrawerHeaderActionButton onClick={onAsk} aria-label="Ask about alpha">
+ Ask
+ </DrawerHeaderActionButton>
+ <DrawerHeaderActionButton disabled aria-label="Copy alpha">
+ Copy
+ </DrawerHeaderActionButton>
+ <DrawerHeaderIconButton onClick={onClose} aria-label="Close drawer">
+ x
+ </DrawerHeaderIconButton>
+ </DrawerHeaderActionGroup>
+ ));
+
+ const group = screen.getByTestId('drawer-actions');
+ expect(group).toHaveClass('shrink-0');
+ expect(group).toHaveClass('gap-1.5');
+
+ const ask = screen.getByRole('button', { name: 'Ask about alpha' });
+ expect(ask).toHaveAttribute('type', 'button');
+ expect(ask).toHaveClass('h-8');
+ expect(ask).toHaveClass('bg-surface');
+ ask.click();
+ expect(onAsk).toHaveBeenCalledTimes(1);
+
+ expect(screen.getByRole('button', { name: 'Copy alpha' })).toBeDisabled();
+
+ const close = screen.getByRole('button', { name: 'Close drawer' });
+ expect(close).toHaveClass('w-8');
+ close.click();
+ expect(onClose).toHaveBeenCalledTimes(1);
+ });
+
it('renders copyable code rows through the shared copy primitive', () => {
const onCopy = vi.fn();
diff --git a/frontend-modern/src/components/shared/Button.tsx b/frontend-modern/src/components/shared/Button.tsx
index 86ae9720b0..ff4eb4af48 100644
--- a/frontend-modern/src/components/shared/Button.tsx
+++ b/frontend-modern/src/components/shared/Button.tsx
@@ -5,6 +5,9 @@ import { JSX, Show, mergeProps, splitProps } from 'solid-js';
import {
getButtonClass,
getCopyValueButtonClass,
+ getDrawerHeaderActionButtonClass,
+ getDrawerHeaderActionGroupClass,
+ getDrawerHeaderIconButtonClass,
type ButtonSize,
type ButtonVariant,
type CopyValueButtonSize,
@@ -48,6 +51,16 @@ export interface CopyValueButtonProps extends Omit<
children?: JSX.Element;
}
+export interface DrawerHeaderActionGroupProps extends JSX.HTMLAttributes<HTMLDivElement> {
+ class?: string;
+ children?: JSX.Element;
+}
+
+export interface DrawerHeaderActionButtonProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement> {
+ class?: string;
+ children?: JSX.Element;
+}
+
export function Button(props: ButtonProps) {
const merged = mergeProps(
{ variant: 'secondary' as ButtonVariant, size: 'md' as ButtonSize, type: 'button' as const },
@@ -99,6 +112,38 @@ export function Button(props: ButtonProps) {
);
}
+export function DrawerHeaderActionGroup(props: DrawerHeaderActionGroupProps) {
+ const [local, rest] = splitProps(props, ['class', 'children']);
+
+ return (
+ <div {...rest} class={getDrawerHeaderActionGroupClass(local.class)}>
+ {local.children}
+ </div>
+ );
+}
+
+export function DrawerHeaderActionButton(props: DrawerHeaderActionButtonProps) {
+ const merged = mergeProps({ type: 'button' as const }, props);
+ const [local, rest] = splitProps(merged, ['class', 'children']);
+
+ return (
+ <button {...rest} class={getDrawerHeaderActionButtonClass(local.class)}>
+ {local.children}
+ </button>
+ );
+}
+
+export function DrawerHeaderIconButton(props: DrawerHeaderActionButtonProps) {
+ const merged = mergeProps({ type: 'button' as const }, props);
+ const [local, rest] = splitProps(merged, ['class', 'children']);
+
+ return (
+ <button {...rest} class={getDrawerHeaderIconButtonClass(local.class)}>
+ {local.children}
+ </button>
+ );
+}
+
export function CommandCopyButton(props: CommandCopyButtonProps) {
const merged = mergeProps({ label: 'Copy command', type: 'button' as const }, props);
const [local, rest] = splitProps(merged, ['label', 'class', 'title', 'aria-label']);
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 3e90df08b8..bf0cda1da8 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -137,6 +137,7 @@ import truenasProtectionTableSource from '@/features/truenas/TrueNASProtectionTa
import vmwarePageSurfaceSource from '@/features/vmware/VmwarePageSurface.tsx?raw';
import upgradeNavigationSource from '@/utils/upgradeNavigation.ts?raw';
import guestRowSource from '@/components/Workloads/GuestRow.tsx?raw';
+import guestDrawerSource from '@/components/Workloads/GuestDrawer.tsx?raw';
import guestDrawerHistorySource from '@/components/Workloads/GuestDrawerHistory.tsx?raw';
import workloadsSurfaceSource from '@/components/Workloads/WorkloadsSurface.tsx?raw';
import workloadsTableSource from '@/components/Workloads/WorkloadsTable.tsx?raw';
@@ -179,6 +180,7 @@ import alertHistoryTableGroupRowSource from '@/features/alerts/AlertHistoryTable
import alertResourceTableDesktopSource from '@/components/Alerts/AlertResourceTableDesktop.tsx?raw';
import aiCostDashboardSource from '@/components/AI/AICostDashboard.tsx?raw';
import resourceDetailSummarySource from '@/components/Infrastructure/ResourceDetailSummary.tsx?raw';
+import resourceDetailDrawerSource from '@/components/Infrastructure/ResourceDetailDrawer.tsx?raw';
import resourceDetailDrawerDebugTabSource from '@/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx?raw';
import resourceDetailDrawerKubernetesModelSource from '@/components/Infrastructure/resourceDetailDrawerKubernetesModel.ts?raw';
import resourceDetailDrawerTrueNASModelSource from '@/components/Infrastructure/resourceDetailDrawerTrueNASModel.ts?raw';
@@ -2064,6 +2066,12 @@ describe('shared primitive guardrails', () => {
const settingsDialogCloseGuard = registry.patternGuards?.find(
(guard) => guard.id === 'button-outline-settings-dialog-close-local-shell',
);
+ const drawerHeaderActionGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'button-drawer-header-action-local-shell',
+ );
+ const drawerHeaderIconGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'button-drawer-header-icon-local-shell',
+ );
const copyValueRule = registry.rules?.find((rule) => rule.id === 'copy-value-action-shell');
const copyableCodeRowRule = registry.rules?.find(
(rule) => rule.id === 'copyable-code-row-shell',
@@ -2085,6 +2093,7 @@ describe('shared primitive guardrails', () => {
expect(registeredRule?.canonical?.export).toBe('Button');
expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual([
'src/components/AI/Chat/ChatMessages.tsx',
+ 'src/components/Infrastructure/ResourceDetailDrawer.tsx',
'src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx',
'src/components/Settings/AgentProfilesPanel.tsx',
'src/components/Settings/AvailabilitySettingsPanel.tsx',
@@ -2104,6 +2113,7 @@ describe('shared primitive guardrails', () => {
'src/components/Settings/InfrastructureWorkspace.tsx',
'src/components/Settings/ReportingPanel.tsx',
'src/components/Settings/ResourcePicker.tsx',
+ 'src/components/Workloads/GuestDrawer.tsx',
'src/features/patrol/PatrolIntelligenceWorkspace.tsx',
'src/features/standalone/StandalonePageSurface.tsx',
]);
@@ -2344,6 +2354,28 @@ describe('shared primitive guardrails', () => {
expect(settingsDialogCloseGuard?.ignoredPaths).toEqual([
'src/components/shared/Button.test.tsx',
]);
+ expect(drawerHeaderActionGuard?.canonical?.path).toBe('src/components/shared/Button.tsx');
+ expect(drawerHeaderActionGuard?.canonical?.export).toBe('DrawerHeaderActionButton');
+ expect(drawerHeaderActionGuard?.allPatterns).toEqual([
+ 'inline-flex h-8 items-center gap-1.5 rounded border border-border bg-surface px-2 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500',
+ ]);
+ expect(drawerHeaderActionGuard?.scopes).toEqual([
+ 'src/components',
+ 'src/features',
+ 'src/pages',
+ ]);
+ expect(drawerHeaderActionGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(drawerHeaderActionGuard?.ignoredPaths).toEqual([
+ 'src/components/shared/Button.test.tsx',
+ ]);
+ expect(drawerHeaderIconGuard?.canonical?.path).toBe('src/components/shared/Button.tsx');
+ expect(drawerHeaderIconGuard?.canonical?.export).toBe('DrawerHeaderIconButton');
+ expect(drawerHeaderIconGuard?.allPatterns).toEqual([
+ 'inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-surface-hover hover:text-base-content focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500',
+ ]);
+ expect(drawerHeaderIconGuard?.scopes).toEqual(['src/components', 'src/features', 'src/pages']);
+ expect(drawerHeaderIconGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(drawerHeaderIconGuard?.ignoredPaths).toEqual(['src/components/shared/Button.test.tsx']);
expect(copyValueRule?.canonical?.path).toBe('src/components/shared/Button.tsx');
expect(copyValueRule?.canonical?.export).toBe('CopyValueButton');
expect(copyValueRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual([
@@ -2383,6 +2415,9 @@ describe('shared primitive guardrails', () => {
expect(buttonSource).toContain('export function Button');
expect(buttonSource).toContain('export function CommandCopyButton');
expect(buttonSource).toContain('export function CopyValueButton');
+ expect(buttonSource).toContain('export function DrawerHeaderActionButton');
+ expect(buttonSource).toContain('export function DrawerHeaderActionGroup');
+ expect(buttonSource).toContain('export function DrawerHeaderIconButton');
expect(buttonSource).toContain('export function ButtonLink');
expect(buttonSource).toContain('getButtonClass');
expect(buttonSource).toContain('getCopyValueButtonClass');
@@ -2400,6 +2435,20 @@ describe('shared primitive guardrails', () => {
expect(buttonModelSource).toContain('dangerOutline:');
expect(buttonModelSource).toContain('settingsAction:');
expect(buttonModelSource).toContain('getCopyValueButtonClass');
+ expect(buttonModelSource).toContain('getDrawerHeaderActionButtonClass');
+ expect(buttonModelSource).toContain('getDrawerHeaderIconButtonClass');
+ for (const drawerSource of [guestDrawerSource, resourceDetailDrawerSource]) {
+ expect(drawerSource).toContain('@/components/shared/Button');
+ expect(drawerSource).toContain('DrawerHeaderActionGroup');
+ expect(drawerSource).toContain('DrawerHeaderActionButton');
+ expect(drawerSource).toContain('DrawerHeaderIconButton');
+ expect(drawerSource).not.toContain(
+ 'inline-flex h-8 items-center gap-1.5 rounded border border-border bg-surface px-2 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500',
+ );
+ expect(drawerSource).not.toContain(
+ 'inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-surface-hover hover:text-base-content focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500',
+ );
+ }
expect(chatMessagesSource).toContain('@/components/shared/Button');
expect(chatMessagesSource).not.toContain(
'rounded-md border border-border bg-surface px-3 py-1.5 text-xs font-medium text-base-content',
diff --git a/frontend-modern/src/components/shared/buttonModel.ts b/frontend-modern/src/components/shared/buttonModel.ts
index 841b8fc873..ba95c5e2fe 100644
--- a/frontend-modern/src/components/shared/buttonModel.ts
+++ b/frontend-modern/src/components/shared/buttonModel.ts
@@ -107,3 +107,20 @@ export const getCopyValueButtonClass = (options: CopyValueButtonClassOptions = {
]
.filter(Boolean)
.join(' ');
+
+export const DRAWER_HEADER_ACTION_GROUP_CLASS = 'flex shrink-0 items-center gap-1.5';
+
+export const DRAWER_HEADER_ACTION_BUTTON_CLASS =
+ 'inline-flex h-8 items-center gap-1.5 rounded border border-border bg-surface px-2 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 disabled:cursor-wait disabled:opacity-60';
+
+export const DRAWER_HEADER_ICON_BUTTON_CLASS =
+ 'inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-surface-hover hover:text-base-content focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500';
+
+export const getDrawerHeaderActionGroupClass = (className?: string): string =>
+ [DRAWER_HEADER_ACTION_GROUP_CLASS, className].filter(Boolean).join(' ');
+
+export const getDrawerHeaderActionButtonClass = (className?: string): string =>
+ [DRAWER_HEADER_ACTION_BUTTON_CLASS, className].filter(Boolean).join(' ');
+
+export const getDrawerHeaderIconButtonClass = (className?: string): string =>
+ [DRAWER_HEADER_ICON_BUTTON_CLASS, className].filter(Boolean).join(' ');