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.

Canonicalize grouped table mode control

rcourtman3e03171166b0
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 8be6f6d1ef..9425af539a 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -291,9 +291,12 @@ work extends shared components instead of creating new local variants.
feature shells may compose those labels, but they must not become a second
source of truth for alert, storage, recovery, infrastructure, workload, or
adjacent product vocabulary. Table-mode segmented controls that expose a
- grouping accessible label must use the shared `Group by` casing, while
- visible options describe the mode itself (`Grouped`, `List`, or the
- owning surface's equivalent) instead of resource-specific concepts. Shared
+ grouped/list view mode must use
+ `frontend-modern/src/components/shared/GroupedTableModeSegmentedControl.tsx`
+ so the shared primitive owns the `Group by` accessible label, `Grouped` and
+ `List` visible labels, tooltip titles, and icons instead of each resource
+ surface rebuilding that language with subtly different resource-specific
+ concepts. Shared
`PageControls` owns trailing filter-row actions such as utility buttons,
Columns, and Reset; those controls must stay grouped at the row end when
dense toolbars wrap so popovers remain viewport-safe instead of drifting
diff --git a/frontend-modern/src/components/Dashboard/DashboardFilter.tsx b/frontend-modern/src/components/Dashboard/DashboardFilter.tsx
index 4f12f14203..acc9bdb556 100644
--- a/frontend-modern/src/components/Dashboard/DashboardFilter.tsx
+++ b/frontend-modern/src/components/Dashboard/DashboardFilter.tsx
@@ -1,9 +1,7 @@
import { Component, For, Show } from 'solid-js';
import { Card } from '@/components/shared/Card';
-import {
- FilterSegmentedControl,
- LabeledFilterSelect,
-} from '@/components/shared/FilterToolbar';
+import { FilterSegmentedControl, LabeledFilterSelect } from '@/components/shared/FilterToolbar';
+import { GroupedTableModeSegmentedControl } from '@/components/shared/GroupedTableModeSegmentedControl';
import { PageControls } from '@/components/shared/PageControls';
import { SearchInput } from '@/components/shared/SearchInput';
import { STORAGE_KEYS } from '@/utils/localStorage';
@@ -179,53 +177,9 @@ export const DashboardFilter: Component<DashboardFilterProps> = (props) => {
<option value="stopped">Stopped</option>
</LabeledFilterSelect>
- <FilterSegmentedControl
+ <GroupedTableModeSegmentedControl
value={props.groupingMode()}
- onChange={(value) => props.setGroupingMode(value as 'grouped' | 'flat')}
- aria-label="Group by"
- options={[
- {
- value: 'grouped',
- title: 'Group by node',
- label: (
- <>
- <svg
- class="w-3 h-3"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="2"
- >
- <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2v11z" />
- </svg>
- Grouped
- </>
- ),
- },
- {
- value: 'flat',
- title: 'Flat list view',
- label: (
- <>
- <svg
- class="w-3 h-3"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="2"
- >
- <line x1="8" y1="6" x2="21" y2="6" />
- <line x1="8" y1="12" x2="21" y2="12" />
- <line x1="8" y1="18" x2="21" y2="18" />
- <line x1="3" y1="6" x2="3.01" y2="6" />
- <line x1="3" y1="12" x2="3.01" y2="12" />
- <line x1="3" y1="18" x2="3.01" y2="18" />
- </svg>
- List
- </>
- ),
- },
- ]}
+ onChange={props.setGroupingMode}
/>
<Show when={props.onChartsToggle}>
diff --git a/frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx
index 78201d2a56..9bebeb57d7 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx
@@ -182,6 +182,19 @@ describe('DashboardFilter', () => {
// --- Grouping mode ---
describe('grouping mode', () => {
+ it('uses the canonical grouped/list table-mode titles', () => {
+ const props = makeProps();
+ render(() => <DashboardFilter {...props} />);
+ expect(screen.getByRole('button', { name: 'Grouped' })).toHaveAttribute(
+ 'title',
+ 'Grouped table view',
+ );
+ expect(screen.getByRole('button', { name: 'List' })).toHaveAttribute(
+ 'title',
+ 'Flat list view',
+ );
+ });
+
it('calls setGroupingMode("flat") when List button is clicked', () => {
const props = makeProps();
render(() => <DashboardFilter {...props} />);
diff --git a/frontend-modern/src/components/shared/GroupedTableModeSegmentedControl.tsx b/frontend-modern/src/components/shared/GroupedTableModeSegmentedControl.tsx
new file mode 100644
index 0000000000..994dcde42b
--- /dev/null
+++ b/frontend-modern/src/components/shared/GroupedTableModeSegmentedControl.tsx
@@ -0,0 +1,53 @@
+import { splitProps, type Component, type JSX } from 'solid-js';
+import FolderTreeIcon from 'lucide-solid/icons/folder-tree';
+import ListIcon from 'lucide-solid/icons/list';
+import { FilterSegmentedControl } from './FilterToolbar';
+
+export type GroupedTableMode = 'grouped' | 'flat';
+
+export const GROUPED_TABLE_MODE_ARIA_LABEL = 'Group by';
+export const GROUPED_TABLE_MODE_GROUPED_TITLE = 'Grouped table view';
+export const GROUPED_TABLE_MODE_FLAT_TITLE = 'Flat list view';
+
+interface GroupedTableModeSegmentedControlProps
+ extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'onChange'> {
+ value: GroupedTableMode;
+ onChange: (value: GroupedTableMode) => void;
+}
+
+export const GroupedTableModeSegmentedControl: Component<
+ GroupedTableModeSegmentedControlProps
+> = (props) => {
+ const [local, divProps] = splitProps(props, ['value', 'onChange']);
+
+ return (
+ <FilterSegmentedControl
+ {...divProps}
+ aria-label={divProps['aria-label'] ?? GROUPED_TABLE_MODE_ARIA_LABEL}
+ value={local.value}
+ onChange={(value) => local.onChange(value as GroupedTableMode)}
+ options={[
+ {
+ value: 'grouped',
+ title: GROUPED_TABLE_MODE_GROUPED_TITLE,
+ label: (
+ <>
+ <FolderTreeIcon class="w-3 h-3" />
+ Grouped
+ </>
+ ),
+ },
+ {
+ value: 'flat',
+ title: GROUPED_TABLE_MODE_FLAT_TITLE,
+ label: (
+ <>
+ <ListIcon class="w-3 h-3" />
+ List
+ </>
+ ),
+ },
+ ]}
+ />
+ );
+};
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 1317cc3358..84c83eb824 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -66,7 +66,10 @@ import tableCardHeaderSource from '@/components/shared/TableCardHeader.tsx?raw';
import summaryTableCardHeaderSource from '@/components/shared/SummaryTableCardHeader.tsx?raw';
import summaryTableFocusSource from '@/components/shared/summaryTableFocus.ts?raw';
import tableCardSource from '@/components/shared/TableCard.tsx?raw';
+import groupedTableModeSegmentedControlSource from '@/components/shared/GroupedTableModeSegmentedControl.tsx?raw';
import groupedTableRowPresentationSource from '@/components/shared/groupedTableRowPresentation.ts?raw';
+import dashboardFilterSource from '@/components/Dashboard/DashboardFilter.tsx?raw';
+import infrastructurePageSurfaceSource from '@/features/infrastructure/InfrastructurePageSurface.tsx?raw';
import infrastructureSourceManagerSource from '@/components/Settings/InfrastructureSourceManager.tsx?raw';
import infrastructureSummaryTableSource from '@/components/shared/InfrastructureSummaryTable.tsx?raw';
import infrastructureSummaryTableRowSource from '@/components/shared/InfrastructureSummaryTableRow.tsx?raw';
@@ -484,6 +487,30 @@ describe('shared primitive guardrails', () => {
expect(unifiedResourceHostTableCardSource).toContain('data-summary-group-member-active');
});
+ it('keeps grouped/list table-mode controls on one shared presentation contract', () => {
+ expect(groupedTableModeSegmentedControlSource).toContain('GroupedTableModeSegmentedControl');
+ expect(groupedTableModeSegmentedControlSource).toContain('GROUPED_TABLE_MODE_ARIA_LABEL');
+ expect(groupedTableModeSegmentedControlSource).toContain(
+ "GROUPED_TABLE_MODE_GROUPED_TITLE = 'Grouped table view'",
+ );
+ expect(groupedTableModeSegmentedControlSource).toContain(
+ "GROUPED_TABLE_MODE_FLAT_TITLE = 'Flat list view'",
+ );
+ expect(groupedTableModeSegmentedControlSource).toContain(
+ "import FolderTreeIcon from 'lucide-solid/icons/folder-tree'",
+ );
+ expect(groupedTableModeSegmentedControlSource).toContain(
+ "import ListIcon from 'lucide-solid/icons/list'",
+ );
+
+ for (const source of [dashboardFilterSource, infrastructurePageSurfaceSource]) {
+ expect(source).toContain('GroupedTableModeSegmentedControl');
+ expect(source).not.toContain("title: 'Group by node'");
+ expect(source).not.toContain("title: 'Grouped table view'");
+ expect(source).not.toContain("title: 'Flat list view'");
+ }
+ });
+
it('keeps summary-linked row input semantics on the shared interaction helper', () => {
expect(summaryInteractionA11ySource).toContain('createSummaryInteractiveRowPreviewHandlers');
expect(summaryInteractionA11ySource).toContain('createSummaryInteractiveActionKeydownHandler');
diff --git a/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx b/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx
index 70ead4b060..30d9f57bb5 100644
--- a/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx
+++ b/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx
@@ -4,6 +4,7 @@ import { buildInfrastructureOnboardingPath } from '@/components/Settings/infrast
import { EmptyState } from '@/components/shared/EmptyState';
import { Card } from '@/components/shared/Card';
import { FilterSegmentedControl, LabeledFilterSelect } from '@/components/shared/FilterToolbar';
+import { GroupedTableModeSegmentedControl } from '@/components/shared/GroupedTableModeSegmentedControl';
import { PageControls } from '@/components/shared/PageControls';
import { PageHeader } from '@/components/shared/PageHeader';
import { SearchInput } from '@/components/shared/SearchInput';
@@ -229,53 +230,9 @@ export function InfrastructurePageSurface() {
</For>
</LabeledFilterSelect>
- <FilterSegmentedControl
+ <GroupedTableModeSegmentedControl
value={groupingMode()}
onChange={(value) => setGroupingMode(value as GroupingMode)}
- aria-label="Group by"
- options={[
- {
- value: 'grouped',
- title: 'Grouped table view',
- label: (
- <>
- <svg
- class="w-3 h-3"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="2"
- >
- <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2v11z" />
- </svg>
- Grouped
- </>
- ),
- },
- {
- value: 'flat',
- title: 'Flat list view',
- label: (
- <>
- <svg
- class="w-3 h-3"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="2"
- >
- <line x1="8" y1="6" x2="21" y2="6" />
- <line x1="8" y1="12" x2="21" y2="12" />
- <line x1="8" y1="18" x2="21" y2="18" />
- <line x1="3" y1="6" x2="3.01" y2="6" />
- <line x1="3" y1="12" x2="3.01" y2="12" />
- <line x1="3" y1="18" x2="3.01" y2="18" />
- </svg>
- List
- </>
- ),
- },
- ]}
/>
<FilterSegmentedControl
diff --git a/frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts b/frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts
index 7c6328c9a7..531d8461fc 100644
--- a/frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts
+++ b/frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts
@@ -81,9 +81,10 @@ describe('InfrastructurePageSurface guardrails', () => {
'data-testid="infrastructure-interaction-surface"',
);
expect(infrastructurePageSurfaceSource).toContain('data-summary-clear-ignore');
- expect(infrastructurePageSurfaceSource).toContain('aria-label="Group by"');
+ expect(infrastructurePageSurfaceSource).toContain('GroupedTableModeSegmentedControl');
+ expect(infrastructurePageSurfaceSource).not.toContain('aria-label="Group by"');
expect(infrastructurePageSurfaceSource).not.toContain('aria-label="Group By"');
- expect(infrastructurePageSurfaceSource).toContain("title: 'Grouped table view'");
+ expect(infrastructurePageSurfaceSource).not.toContain("title: 'Grouped table view'");
expect(infrastructurePageSurfaceSource).toContain('Grouped');
expect(infrastructurePageSurfaceSource).not.toContain("title: 'Group by cluster'");
expect(infrastructurePageSurfaceSource).not.toContain('SummaryScopeBar');