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.

refactor(recovery): route workspace tabs through shared subtabs variant

rcourtman35aa4f7d8ce4
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index a7eac40cf1..fa326a9deb 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -647,6 +647,11 @@ search-row, filter-row, and inline-leading-slot layout surface. Monitoring
pages that need workspace tabs or count chips next to search should route that
through the shared `searchLeading` slot instead of recreating a second local
header strip above the control bar.
+When those workspace tabs need a denser embedded control-bar treatment, that
+presentation should live on the shared
+`frontend-modern/src/components/shared/Subtabs.tsx` owner as an explicit
+variant instead of each page layering local shell, list, and button class
+stacks onto the primitive.
The search-input enhancement surfaces now follow that same owner split.
`frontend-modern/src/components/shared/SearchInputEnhancements.tsx` stays the
render shell, `frontend-modern/src/components/shared/useSearchInputEnhancements.ts`
@@ -765,7 +770,9 @@ The recovery feature shell now also depends on the shared
protected-items versus recovery-events workspace switch. The recovery lane may
own the active view and route-state semantics, but the top-level tab framing
must stay on the canonical shared subtabs control instead of reviving a
-recovery-local switcher pattern.
+recovery-local switcher pattern. When recovery embeds that switcher inside the
+page-controls row, the contained styling should come from the shared subtabs
+variant boundary rather than from recovery-only class overrides.
That same recovery shell boundary now also owns one canonical top-level filter
controller in
`frontend-modern/src/features/recovery/useRecoverySurfaceState.ts`. Route-backed
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index ba2829bc56..71d54c723a 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -743,6 +743,10 @@ status strip above the control bar. Protected-items and recovery-events should
surface their tabs, counts, and issue cues through the shared page-controls
search row so the page hands from summary directly into one canonical control
surface, the same way other Pulse monitoring pages do.
+That same workspace handoff should stay on shared primitive styling too. When
+recovery embeds its workspace tabs inside the page-controls row, the switcher
+should use the shared `Subtabs.tsx` control-surface variant instead of stacking
+recovery-only shell, list, and button classes on top of the primitive.
That same workspace rule also means the protected-items versus recovery-events
switcher should live inside the active workspace header strip, not in its own
separate band above the cards, so the page hands off from summary directly into
diff --git a/frontend-modern/src/components/Recovery/Recovery.tsx b/frontend-modern/src/components/Recovery/Recovery.tsx
index 0d5c7809fa..fe4254d045 100644
--- a/frontend-modern/src/components/Recovery/Recovery.tsx
+++ b/frontend-modern/src/components/Recovery/Recovery.tsx
@@ -492,8 +492,8 @@ const Recovery: Component = () => {
value={workspaceView()}
onChange={(value) => setWorkspaceView(value as RecoveryWorkspaceView)}
ariaLabel="Recovery data view"
- listClass="flex flex-wrap items-center gap-1"
- tabClass="min-h-6 px-2 py-1 text-xs"
+ variant="control"
+ class="sm:w-max"
tabs={[
{
value: 'inventory',
diff --git a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
index 93bc74f5c1..d400474e90 100644
--- a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
+++ b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
@@ -221,6 +221,16 @@ describe('Recovery', () => {
expect(
within(inventoryControls).getByRole('tab', { name: /recovery events 0/i }),
).toBeInTheDocument();
+ expect(
+ within(inventoryControls)
+ .getByRole('tab', { name: /protected items 2/i })
+ .className,
+ ).not.toContain('border-b-2');
+ expect(
+ within(inventoryControls)
+ .getByRole('tab', { name: /protected items 2/i })
+ .className,
+ ).toContain('rounded-md');
expect(screen.queryByText('Protected inventory')).not.toBeInTheDocument();
expect(screen.queryByText('Needs Attention')).not.toBeInTheDocument();
expect(screen.getAllByText(/Page 1 \/ 1/i).length).toBeGreaterThan(0);
diff --git a/frontend-modern/src/components/shared/PageControls.guardrails.test.ts b/frontend-modern/src/components/shared/PageControls.guardrails.test.ts
index d55e51f450..20192788f9 100644
--- a/frontend-modern/src/components/shared/PageControls.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/PageControls.guardrails.test.ts
@@ -1,9 +1,11 @@
import { describe, expect, it } from 'vitest';
import pageControlsSource from '@/components/shared/PageControls.tsx?raw';
import dashboardFilterSource from '@/components/Dashboard/DashboardFilter.tsx?raw';
+import recoveryPageSource from '@/components/Recovery/Recovery.tsx?raw';
import recoveryHistorySectionSource from '@/components/Recovery/RecoveryHistorySection.tsx?raw';
import recoveryProtectedInventorySectionSource from '@/components/Recovery/RecoveryProtectedInventorySection.tsx?raw';
import infrastructurePageSurfaceSource from '@/features/infrastructure/InfrastructurePageSurface.tsx?raw';
+import subtabsSource from '@/components/shared/Subtabs.tsx?raw';
const tsxSources = import.meta.glob('../../**/*.tsx', {
query: '?raw',
@@ -99,4 +101,15 @@ describe('page controls guardrails', () => {
expect(recoveryProtectedInventorySectionSource).not.toContain('<FilterHeader');
expect(recoveryHistorySectionSource).not.toContain('<FilterHeader');
});
+
+ it('keeps embedded workspace tabs on the shared subtabs control variant', () => {
+ expect(subtabsSource).toContain("variant?: 'default' | 'control'");
+ expect(subtabsSource).toContain('subtabsControlShellClass');
+ expect(subtabsSource).toContain('subtabsControlListClass');
+ expect(recoveryPageSource).toContain('variant="control"');
+ expect(recoveryPageSource).not.toContain('listClass="gap-1 overflow-x-auto scrollbar-hide"');
+ expect(recoveryPageSource).not.toContain(
+ 'tabClass="min-h-8 whitespace-nowrap rounded-md border border-transparent px-3 py-1.5 text-xs"',
+ );
+ });
});
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index fcfa0ac9b8..ba85baf697 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -44,6 +44,7 @@ import scrollToTopButtonSource from '@/components/shared/ScrollToTopButton.tsx?r
import scrollToTopButtonModelSource from '@/components/shared/scrollToTopButtonModel.ts?raw';
import statusBadgeSource from '@/components/shared/StatusBadge.tsx?raw';
import statusBadgeModelSource from '@/components/shared/statusBadgeModel.ts?raw';
+import subtabsSource from '@/components/shared/Subtabs.tsx?raw';
import toggleSource from '@/components/shared/Toggle.tsx?raw';
import toggleModelSource from '@/components/shared/toggleModel.ts?raw';
import searchTipsPopoverSource from '@/components/shared/SearchTipsPopover.tsx?raw';
@@ -227,6 +228,14 @@ describe('shared primitive guardrails', () => {
expect(activeUseTrialNudgeModelSource).toContain('ACTIVE_USE_TRIAL_NUDGE_TITLE');
});
+ it('keeps shared subtabs variant-driven instead of page-local class stacks', () => {
+ expect(subtabsSource).toContain("variant?: 'default' | 'control'");
+ expect(subtabsSource).toContain('subtabsControlShellClass');
+ expect(subtabsSource).toContain('subtabsControlListClass');
+ expect(subtabsSource).toContain('subtabControlButtonClass');
+ expect(subtabsSource).toContain("local.variant === 'control'");
+ });
+
it('keeps trial banner on shell, runtime, and model owners', () => {
expect(trialBannerSource).toContain('useTrialBannerState');
expect(trialBannerSource).toContain('TRIAL_BANNER_TITLE');
diff --git a/frontend-modern/src/components/shared/Subtabs.tsx b/frontend-modern/src/components/shared/Subtabs.tsx
index 68cc396efe..ca0867696a 100644
--- a/frontend-modern/src/components/shared/Subtabs.tsx
+++ b/frontend-modern/src/components/shared/Subtabs.tsx
@@ -11,6 +11,7 @@ interface SubtabsProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'onChang
onChange: (value: string) => void;
tabs: SubtabOption[];
ariaLabel: string;
+ variant?: 'default' | 'control';
listClass?: string;
tabClass?: string;
}
@@ -21,6 +22,15 @@ export const subtabButtonClass =
'inline-flex min-h-10 items-center border-b-2 px-1 py-2 text-sm font-medium transition-colors';
export const subtabButtonActiveClass = 'border-blue-600 text-base-content';
export const subtabButtonInactiveClass = 'border-transparent text-muted hover:text-base-content';
+export const subtabsControlShellClass = 'rounded-md border border-border bg-surface-alt p-0.5';
+export const subtabsControlListClass =
+ 'flex flex-wrap items-center gap-1 overflow-x-auto scrollbar-hide';
+export const subtabControlButtonClass =
+ 'inline-flex min-h-8 whitespace-nowrap rounded-md border border-transparent px-3 py-1.5 text-xs font-medium transition-colors';
+export const subtabControlButtonActiveClass =
+ 'border-border-subtle bg-surface text-base-content shadow-sm';
+export const subtabControlButtonInactiveClass =
+ 'text-muted hover:bg-surface-hover hover:text-base-content';
export const Subtabs: Component<SubtabsProps> = (props) => {
const [local, divProps] = splitProps(props, [
@@ -28,17 +38,26 @@ export const Subtabs: Component<SubtabsProps> = (props) => {
'onChange',
'tabs',
'ariaLabel',
+ 'variant',
'class',
'listClass',
'tabClass',
]);
+ const isControlVariant = () => local.variant === 'control';
return (
- <div {...divProps} class={`${subtabsShellClass} ${local.class ?? ''}`.trim()}>
+ <div
+ {...divProps}
+ class={`${
+ isControlVariant() ? subtabsControlShellClass : subtabsShellClass
+ } ${local.class ?? ''}`.trim()}
+ >
<div
role="tablist"
aria-label={local.ariaLabel}
- class={`${subtabsListClass} ${local.listClass ?? ''}`.trim()}
+ class={`${
+ isControlVariant() ? subtabsControlListClass : subtabsListClass
+ } ${local.listClass ?? ''}`.trim()}
>
<For each={local.tabs}>
{(tab) => {
@@ -51,8 +70,16 @@ export const Subtabs: Component<SubtabsProps> = (props) => {
tabIndex={selected() ? 0 : -1}
disabled={tab.disabled}
onClick={() => local.onChange(tab.value)}
- class={`${subtabButtonClass} ${
- selected() ? subtabButtonActiveClass : subtabButtonInactiveClass
+ class={`${
+ isControlVariant() ? subtabControlButtonClass : subtabButtonClass
+ } ${
+ selected()
+ ? isControlVariant()
+ ? subtabControlButtonActiveClass
+ : subtabButtonActiveClass
+ : isControlVariant()
+ ? subtabControlButtonInactiveClass
+ : subtabButtonInactiveClass
} ${local.tabClass ?? ''}`.trim()}
>
{tab.label}