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 shared filter control deck

rcourtman828e885d8ead
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 07c11e046b..a870498d9e 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -365,18 +365,18 @@ work extends shared components instead of creating new local variants.
after another expanded group. User-facing filter options must use operator
mental models rather than implementation categories: Workloads Type exposes a
single `Containers` bucket while the `system-container` / `app-container`
- distinction remains an internal data/deep-link compatibility detail. Dense
- filter surfaces may opt into the `PageControls` stacked action layout so
- display, chart, column, and reset actions occupy their own compact grouped
- row instead of splitting the filter row into left/right zones or creating a
- full-width form-like divider. When a dense surface would otherwise read as a
- small form floating in a mostly empty full-width panel, it should route the
- filter rows and trailing actions through `PageControls` `controlDeckClass`
- so the controls read as one structured command deck instead of unrelated
- left-aligned fragments or a compact island inside a mostly empty full-width
- panel. Those structured decks must give each semantic section a visible
- boundary so adjacent radio groups, scope filters, and display actions do not
- collapse into one hard-to-scan strip. Narrow consumers such as
+ distinction remains an internal data/deep-link compatibility detail.
+ `PageControls` owns the default stacked control deck for page-level filters:
+ filter controls, display/chart controls, Columns, and Reset inherit one
+ shared structured command deck with visible section boundaries instead of
+ each page passing local `controlDeckClass`, action-rail, border, or
+ background strings. Pages that have multiple semantic filter groups may set
+ the shared `filterControlsVariant="sectioned-children"` mode and wrap those
+ groups with `pageControlsFilterSectionClass`, but the deck chrome and
+ trailing action section remain frontend-primitives owned. Those structured
+ decks must give each semantic section a visible boundary so adjacent radio
+ groups, scope filters, and display actions do not collapse into one
+ hard-to-scan strip. Narrow consumers such as
`ColumnPicker` must opt into their panel width through that primitive rather
than layering competing width classes page by page.
4. Add guardrail tests when a new shared pattern is introduced.
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 f909f3f7e4..0740471be3 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -200,12 +200,12 @@ regression protection.
17. Extend workload control defaults, persistent view preferences, keyboard reset behavior, column-visibility ownership, and tag-search flow through `frontend-modern/src/components/Workloads/useWorkloadsControlsState.ts` and `frontend-modern/src/components/Workloads/workloadsFilterModel.ts` rather than rebuilding sort/search/grouping state, reset drift, or column-toggle plumbing inside `frontend-modern/src/components/Workloads/useWorkloadsState.ts`
18. Extend workload filter active-count, reset semantics, and mobile toolbar state through `frontend-modern/src/components/Workloads/workloadsFilterModel.ts` and `frontend-modern/src/components/Workloads/useWorkloadsFilterState.ts`, rather than rebuilding filter-local state inside `frontend-modern/src/components/Workloads/WorkloadsFilter.tsx`
Workloads filter presentation may consume frontend-primitives responsive
- toggle controls and the shared structured control-deck wrapper with visible
- section boundaries, but the workload-owned state model must remain the
- source of truth for active filter counting, reset behavior, and mobile
- collapse so changing between wide toggle and narrow select presentation
- does not add a second filter state path or layout-measurement path on the
- workload hot path.
+ toggle controls, the shared `PageControls` structured control deck, and the
+ shared filter-section chrome for its semantic primary and secondary filter
+ groups, but the workload-owned state model must remain the source of truth
+ for active filter counting, reset behavior, and mobile collapse so changing
+ between wide toggle and narrow select presentation does not add a second
+ filter state path or layout-measurement path on the workload hot path.
19. Extend threshold-slider value-position math, title/label derivation, and drag scroll-lock runtime through `frontend-modern/src/components/Workloads/thresholdSliderModel.ts` and `frontend-modern/src/components/Workloads/useThresholdSliderState.ts` rather than rebuilding slider-local state and pointer lifecycle inside `frontend-modern/src/components/Workloads/ThresholdSlider.tsx`
20. Extend stacked disk-bar capacity math, segment/tooltip derivation, and resize-observer runtime through `frontend-modern/src/components/Workloads/stackedDiskBarModel.ts` and `frontend-modern/src/components/Workloads/useStackedDiskBarState.ts` rather than rebuilding disk-bar-local state, mode branching, and tooltip shaping inside `frontend-modern/src/components/Workloads/StackedDiskBar.tsx`
21. Extend stacked memory-bar capacity math, balloon/swap derivation, and resize-observer runtime through `frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts` and `frontend-modern/src/components/Workloads/useStackedMemoryBarState.ts` rather than rebuilding memory-bar-local state, tooltip shaping, and label-fit logic inside `frontend-modern/src/components/Workloads/StackedMemoryBar.tsx`
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index d0611403c8..941520eb08 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -83,7 +83,8 @@ state.
column visibility, and reset controls on the shared `PageControls` toolbar
rail. Recovery must not reintroduce local no-wrap toolbar overrides or
right-aligned utility wrappers that prevent the frontend-primitives action
- rail from owning responsive collapse behavior.
+ rail and structured control deck from owning responsive collapse behavior
+ and visible filter/action section boundaries.
Compact stable recovery-event filters, such as event outcome/status, may use
the frontend-primitives responsive toggle/select control, but Recovery must
keep route-backed event filter state and query semantics in its recovery
@@ -109,7 +110,10 @@ state.
filter sections collapse through the same primitive contract. The charts
toggle must read as an explicit `Show charts` / `Hide charts` pressed
display action, and the off state must remove the summary section fully
- instead of leaving a collapsed summary shell in the interface.
+ instead of leaving a collapsed summary shell in the interface. Storage
+ filters inherit the shared `PageControls` structured deck and must not
+ duplicate page-local control-deck, action-rail, border, or background class
+ strings.
Ceph table shells on the storage route share the same frontend-primitives
table contract: `frontend-modern/src/pages/Ceph.tsx` may own Ceph-specific
columns and rows, but horizontal overflow and scrollbar hiding must route
diff --git a/frontend-modern/src/components/Workloads/WorkloadsFilter.tsx b/frontend-modern/src/components/Workloads/WorkloadsFilter.tsx
index fcd33397a6..98c6da97ee 100644
--- a/frontend-modern/src/components/Workloads/WorkloadsFilter.tsx
+++ b/frontend-modern/src/components/Workloads/WorkloadsFilter.tsx
@@ -6,7 +6,7 @@ import {
LabeledFilterToggleGroup,
} from '@/components/shared/FilterToolbar';
import { GroupedTableModeSegmentedControl } from '@/components/shared/GroupedTableModeSegmentedControl';
-import { PageControls } from '@/components/shared/PageControls';
+import { PageControls, pageControlsFilterSectionClass } from '@/components/shared/PageControls';
import { SearchInput } from '@/components/shared/SearchInput';
import { STORAGE_KEYS } from '@/utils/localStorage';
import { isContainerWorkloadViewMode } from '@/utils/workloads';
@@ -76,10 +76,7 @@ export const WorkloadsFilter: Component<WorkloadsFilterProps> = (props) => {
),
}}
showFilters={showToolbarFilters()}
- actionsLayout="stacked"
- controlDeckClass="workloads-filter-control-deck grid w-full min-w-0 items-start gap-2 rounded-md border border-border bg-surface-alt p-1.5 shadow-sm xl:grid-cols-[minmax(0,1fr)_auto]"
- filterControlsClass="page-controls-filter-controls w-full min-w-0"
- toolbarActionsClass="page-controls-toolbar-actions inline-flex max-w-full flex-wrap items-center gap-2 rounded-md border border-border-subtle bg-surface px-1.5 py-1 shadow-sm xl:justify-self-end"
+ filterControlsVariant="sectioned-children"
toolbarTrailing={
<>
<GroupedTableModeSegmentedControl
@@ -96,96 +93,98 @@ export const WorkloadsFilter: Component<WorkloadsFilterProps> = (props) => {
</>
}
>
- <div class="workloads-filter-control-stack grid w-full min-w-0 gap-2 xl:grid-cols-[max-content_minmax(16rem,1fr)] xl:items-start">
- <div class="workloads-filter-primary-controls flex min-w-0 flex-wrap items-center gap-1 rounded-md border border-border-subtle bg-surface px-1.5 py-1 shadow-sm xl:flex-col xl:items-start">
- <LabeledFilterToggleGroup
- id="workloads-type-filter"
- label="Type"
- value={typeFilterValue()}
- onChange={(value) => props.setViewMode(value as ViewMode)}
- selectClass="min-w-[7rem]"
- options={WORKLOAD_TYPE_OPTIONS}
- />
+ <div
+ class={`${pageControlsFilterSectionClass} workloads-filter-primary-controls flex min-w-0 flex-wrap items-center gap-1 xl:flex-col xl:items-start`}
+ >
+ <LabeledFilterToggleGroup
+ id="workloads-type-filter"
+ label="Type"
+ value={typeFilterValue()}
+ onChange={(value) => props.setViewMode(value as ViewMode)}
+ selectClass="min-w-[7rem]"
+ options={WORKLOAD_TYPE_OPTIONS}
+ />
- <LabeledFilterToggleGroup
- id="workloads-status-filter"
- label="Status"
- value={props.statusMode()}
- onChange={(value) =>
- props.setStatusMode(value as 'all' | 'running' | 'degraded' | 'stopped')
- }
- options={WORKLOAD_STATUS_FILTER_OPTIONS}
- />
- </div>
+ <LabeledFilterToggleGroup
+ id="workloads-status-filter"
+ label="Status"
+ value={props.statusMode()}
+ onChange={(value) =>
+ props.setStatusMode(value as 'all' | 'running' | 'degraded' | 'stopped')
+ }
+ options={WORKLOAD_STATUS_FILTER_OPTIONS}
+ />
+ </div>
- <Show when={hasSecondaryFilters()}>
- <div class="workloads-filter-secondary-controls flex max-w-full min-w-0 flex-wrap items-center gap-1 rounded-md border border-border-subtle bg-surface px-1.5 py-1 shadow-sm">
- <Show when={props.hostFilter}>
- {(hostFilter) => (
- <LabeledFilterSelect
- id={hostFilter().id ?? 'workloads-host-filter'}
- label={hostFilter().label ?? 'Agent'}
- value={hostFilter().value}
- onChange={(e) => hostFilter().onChange(e.currentTarget.value)}
- selectClass="min-w-[8rem]"
- >
- <For each={hostFilter().options}>
- {(option) => <option value={option.value}>{option.label}</option>}
- </For>
- </LabeledFilterSelect>
- )}
- </Show>
+ <Show when={hasSecondaryFilters()}>
+ <div
+ class={`${pageControlsFilterSectionClass} workloads-filter-secondary-controls flex max-w-full min-w-0 flex-wrap items-center gap-1`}
+ >
+ <Show when={props.hostFilter}>
+ {(hostFilter) => (
+ <LabeledFilterSelect
+ id={hostFilter().id ?? 'workloads-host-filter'}
+ label={hostFilter().label ?? 'Agent'}
+ value={hostFilter().value}
+ onChange={(e) => hostFilter().onChange(e.currentTarget.value)}
+ selectClass="min-w-[8rem]"
+ >
+ <For each={hostFilter().options}>
+ {(option) => <option value={option.value}>{option.label}</option>}
+ </For>
+ </LabeledFilterSelect>
+ )}
+ </Show>
- <Show when={props.platformFilter}>
- {(platformFilter) => (
- <LabeledFilterSelect
- id={platformFilter().id ?? 'workloads-platform-filter'}
- label={platformFilter().label ?? 'Platform'}
- value={platformFilter().value}
- onChange={(e) => platformFilter().onChange(e.currentTarget.value)}
- selectClass="min-w-[8rem]"
- >
- <For each={platformFilter().options}>
- {(option) => <option value={option.value}>{option.label}</option>}
- </For>
- </LabeledFilterSelect>
- )}
- </Show>
+ <Show when={props.platformFilter}>
+ {(platformFilter) => (
+ <LabeledFilterSelect
+ id={platformFilter().id ?? 'workloads-platform-filter'}
+ label={platformFilter().label ?? 'Platform'}
+ value={platformFilter().value}
+ onChange={(e) => platformFilter().onChange(e.currentTarget.value)}
+ selectClass="min-w-[8rem]"
+ >
+ <For each={platformFilter().options}>
+ {(option) => <option value={option.value}>{option.label}</option>}
+ </For>
+ </LabeledFilterSelect>
+ )}
+ </Show>
- <Show when={props.namespaceFilter}>
- {(namespaceFilter) => (
- <LabeledFilterSelect
- id={namespaceFilter().id ?? 'workloads-namespace-filter'}
- label={namespaceFilter().label ?? 'Namespace'}
- value={namespaceFilter().value}
- onChange={(e) => namespaceFilter().onChange(e.currentTarget.value)}
- selectClass="min-w-[8rem]"
- >
- <For each={namespaceFilter().options}>
- {(option) => <option value={option.value}>{option.label}</option>}
- </For>
- </LabeledFilterSelect>
- )}
- </Show>
+ <Show when={props.namespaceFilter}>
+ {(namespaceFilter) => (
+ <LabeledFilterSelect
+ id={namespaceFilter().id ?? 'workloads-namespace-filter'}
+ label={namespaceFilter().label ?? 'Namespace'}
+ value={namespaceFilter().value}
+ onChange={(e) => namespaceFilter().onChange(e.currentTarget.value)}
+ selectClass="min-w-[8rem]"
+ >
+ <For each={namespaceFilter().options}>
+ {(option) => <option value={option.value}>{option.label}</option>}
+ </For>
+ </LabeledFilterSelect>
+ )}
+ </Show>
- <Show when={runtimeFilter()}>
- {(activeRuntimeFilter) => (
- <LabeledFilterSelect
- id={activeRuntimeFilter().id ?? 'workloads-runtime-filter'}
- label={activeRuntimeFilter().label ?? 'Runtime'}
- value={activeRuntimeFilter().value}
- onChange={(e) => activeRuntimeFilter().onChange(e.currentTarget.value)}
- selectClass="min-w-[7rem]"
- >
- <For each={activeRuntimeFilter().options}>
- {(option) => <option value={option.value}>{option.label}</option>}
- </For>
- </LabeledFilterSelect>
- )}
- </Show>
- </div>
- </Show>
- </div>
+ <Show when={runtimeFilter()}>
+ {(activeRuntimeFilter) => (
+ <LabeledFilterSelect
+ id={activeRuntimeFilter().id ?? 'workloads-runtime-filter'}
+ label={activeRuntimeFilter().label ?? 'Runtime'}
+ value={activeRuntimeFilter().value}
+ onChange={(e) => activeRuntimeFilter().onChange(e.currentTarget.value)}
+ selectClass="min-w-[7rem]"
+ >
+ <For each={activeRuntimeFilter().options}>
+ {(option) => <option value={option.value}>{option.label}</option>}
+ </For>
+ </LabeledFilterSelect>
+ )}
+ </Show>
+ </div>
+ </Show>
</PageControls>
</Card>
);
diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsFilter.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsFilter.test.tsx
index 50909200fe..a2fea02cee 100644
--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsFilter.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsFilter.test.tsx
@@ -175,7 +175,7 @@ describe('WorkloadsFilter', () => {
const secondaryControls = container.querySelector<HTMLElement>(
'.workloads-filter-secondary-controls',
);
- const controlDeck = container.querySelector<HTMLElement>('.workloads-filter-control-deck');
+ const controlDeck = container.querySelector<HTMLElement>('.page-controls-control-deck');
expect(primaryControls).not.toBeNull();
expect(secondaryControls).not.toBeNull();
expect(controlDeck).not.toBeNull();
@@ -201,10 +201,13 @@ describe('WorkloadsFilter', () => {
expect(controlDeck!).toContainElement(toolbarActions!);
expect(controlDeck!).toContainElement(primaryControls!);
expect(primaryControls!).toHaveClass('border');
+ expect(primaryControls!).toHaveClass('page-controls-filter-section');
expect(primaryControls!).toHaveClass('bg-surface');
expect(secondaryControls!).toHaveClass('border');
+ expect(secondaryControls!).toHaveClass('page-controls-filter-section');
expect(secondaryControls!).toHaveClass('bg-surface');
expect(toolbarActions!).toHaveClass('border');
+ expect(toolbarActions!).toHaveClass('page-controls-filter-section');
expect(toolbarActions!).toHaveClass('bg-surface');
expect(toolbarActions!).toHaveClass('xl:justify-self-end');
expect(toolbarActions!).not.toHaveClass('ml-auto');
diff --git a/frontend-modern/src/components/shared/PageControls.guardrails.test.ts b/frontend-modern/src/components/shared/PageControls.guardrails.test.ts
index 64b16533d5..8da5af2d8b 100644
--- a/frontend-modern/src/components/shared/PageControls.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/PageControls.guardrails.test.ts
@@ -129,10 +129,15 @@ describe('page controls guardrails', () => {
expect(infrastructurePageSurfaceSource).not.toContain('aria-label="Charts"');
expect(pageControlsSource).toContain('page-controls-filter-controls');
expect(pageControlsSource).toContain('page-controls-toolbar-actions ml-auto');
+ expect(pageControlsSource).toContain('pageControlsControlDeckClass');
+ expect(pageControlsSource).toContain('pageControlsFilterSectionClass');
+ expect(pageControlsSource).toContain('pageControlsSectionedFilterControlsClass');
+ expect(pageControlsSource).toContain('filterControlsVariant?:');
expect(pageControlsSource).toContain('actionsLayout?:');
expect(pageControlsSource).toContain('controlDeckClass?:');
expect(pageControlsSource).toContain('const toolbarControls = () => (');
expect(pageControlsSource).toContain("actionsLayout() === 'stacked'");
+ expect(pageControlsSource).toContain("local.actionsLayout ?? 'stacked'");
expect(pageControlsSource).toContain(
'shrink-0 flex-wrap items-center justify-end gap-2 self-start',
);
@@ -151,16 +156,16 @@ describe('page controls guardrails', () => {
expect(workloadsFilterSource).toContain('WORKLOAD_STATUS_FILTER_OPTIONS');
expect(workloadsFilterSource).toContain('workloads-filter-primary-controls');
expect(workloadsFilterSource).toContain('workloads-filter-secondary-controls');
- expect(workloadsFilterSource).toContain('workloads-filter-control-deck');
- expect(workloadsFilterSource).toContain('controlDeckClass=');
- expect(workloadsFilterSource).toContain('border border-border bg-surface-alt');
- expect(workloadsFilterSource).toContain('border border-border-subtle bg-surface');
- expect(workloadsFilterSource).toContain('xl:grid-cols-[minmax(0,1fr)_auto]');
- expect(workloadsFilterSource).toContain(
- 'xl:grid-cols-[max-content_minmax(16rem,1fr)]',
- );
- expect(workloadsFilterSource).toContain('actionsLayout="stacked"');
- expect(workloadsFilterSource).toContain('page-controls-toolbar-actions inline-flex');
+ expect(workloadsFilterSource).toContain('pageControlsFilterSectionClass');
+ expect(workloadsFilterSource).toContain('filterControlsVariant="sectioned-children"');
+ expect(workloadsFilterSource).not.toContain('workloads-filter-control-deck');
+ expect(workloadsFilterSource).not.toContain('controlDeckClass=');
+ expect(pageControlsSource).toContain('border border-border bg-surface-alt');
+ expect(pageControlsSource).toContain('border border-border-subtle bg-surface');
+ expect(pageControlsSource).toContain('xl:grid-cols-[minmax(0,1fr)_auto]');
+ expect(workloadsFilterSource).not.toContain('xl:grid-cols-[max-content_minmax(16rem,1fr)]');
+ expect(workloadsFilterSource).not.toContain('actionsLayout="stacked"');
+ expect(workloadsFilterSource).not.toContain('page-controls-toolbar-actions inline-flex');
expect(workloadsFilterSource).toContain('xl:flex-col xl:items-start');
expect(workloadsFilterSource).not.toContain(
'<LabeledFilterSelect\n id="workloads-type-filter"',
diff --git a/frontend-modern/src/components/shared/PageControls.test.tsx b/frontend-modern/src/components/shared/PageControls.test.tsx
index b2437f833f..49f236dffc 100644
--- a/frontend-modern/src/components/shared/PageControls.test.tsx
+++ b/frontend-modern/src/components/shared/PageControls.test.tsx
@@ -36,18 +36,26 @@ describe('PageControls', () => {
expect(columnsButton).toBeInTheDocument();
expect(resetButton).toBeInTheDocument();
const trailingActions = columnsButton.closest('.page-controls-toolbar-actions');
+ const deck = columnsButton.closest('.page-controls-control-deck');
expect(trailingActions).not.toBeNull();
+ expect(deck).not.toBeNull();
+ expect(deck!).toHaveClass('bg-surface-alt');
expect(trailingActions!).toContainElement(resetButton);
- expect(trailingActions!).toHaveClass('ml-auto');
- expect(trailingActions!).toHaveClass('shrink-0');
- expect(trailingActions!).toHaveClass('justify-end');
- expect(trailingActions!).toHaveClass('self-start');
+ expect(trailingActions!).toHaveClass('page-controls-filter-section');
+ expect(trailingActions!).toHaveClass('bg-surface');
+ expect(trailingActions!).toHaveClass('xl:justify-self-end');
+ expect(trailingActions!).not.toHaveClass('ml-auto');
expect(trailingActions!).not.toHaveClass('2xl:ml-auto');
const filterControls = screen
.getByText('Filters', { selector: 'div' })
- .closest('.page-controls-filter-controls');
+ .closest<HTMLElement>('.page-controls-filter-controls');
expect(filterControls).not.toBeNull();
+ expect(filterControls!).toHaveClass('page-controls-filter-section');
+ expect(filterControls!).toHaveClass('justify-self-start');
+ expect(filterControls!).toHaveClass('w-fit');
+ expect(filterControls!).not.toHaveClass('w-full');
expect(filterControls!).not.toContainElement(columnsButton);
+ expect(deck!).toContainElement(filterControls!);
fireEvent.click(screen.getByRole('button', { name: /filters/i }));
expect(onToggleFilters).toHaveBeenCalledTimes(1);
@@ -120,19 +128,50 @@ describe('PageControls', () => {
expect(trailingActions).not.toBeNull();
expect(trailingActions!).toContainElement(trailing);
expect(trailingActions!).toContainElement(columnsButton);
- expect(trailingActions!).toHaveClass('ml-auto');
- expect(trailingActions!).toHaveClass('shrink-0');
- expect(trailingActions!).toHaveClass('justify-end');
- expect(trailingActions!).toHaveClass('self-start');
+ expect(trailingActions!).toHaveClass('page-controls-filter-section');
+ expect(trailingActions!).toHaveClass('xl:justify-self-end');
+ expect(trailingActions!).not.toHaveClass('ml-auto');
const filterControls = screen
.getByText('Filters', { selector: 'div' })
- .closest('.page-controls-filter-controls');
+ .closest<HTMLElement>('.page-controls-filter-controls');
expect(filterControls).not.toBeNull();
+ expect(filterControls!).toHaveClass('page-controls-filter-section');
+ expect(filterControls!).toHaveClass('justify-self-start');
+ expect(filterControls!).toHaveClass('w-fit');
expect(filterControls!).not.toContainElement(trailing);
expect(filterControls!).not.toContainElement(columnsButton);
expect(screen.queryByTestId('desktop-utility')).not.toBeInTheDocument();
});
+ it('can opt into the inline action layout for narrow specialist controls', () => {
+ render(() => (
+ <PageControls
+ search={<div data-testid="search">Search</div>}
+ showFilters={true}
+ actionsLayout="inline"
+ toolbarTrailing={<div data-testid="toolbar-trailing">Grouped List</div>}
+ columnVisibility={{
+ availableToggles: () => [{ id: 'subject', label: 'Subject' }],
+ isHiddenByUser: () => false,
+ toggle: vi.fn(),
+ resetToDefaults: vi.fn(),
+ }}
+ >
+ <div>Filters</div>
+ </PageControls>
+ ));
+
+ const columnsButton = screen.getByRole('button', { name: /columns/i });
+ const trailingActions = columnsButton.closest('.page-controls-toolbar-actions');
+
+ expect(columnsButton.closest('.page-controls-control-deck')).toBeNull();
+ expect(trailingActions).not.toBeNull();
+ expect(trailingActions!).toHaveClass('ml-auto');
+ expect(trailingActions!).toHaveClass('shrink-0');
+ expect(trailingActions!).toHaveClass('justify-end');
+ expect(trailingActions!).toHaveClass('self-start');
+ });
+
it('can wrap filters and trailing actions in one compact control deck', () => {
render(() => (
<PageControls
diff --git a/frontend-modern/src/components/shared/PageControls.tsx b/frontend-modern/src/components/shared/PageControls.tsx
index edee809b40..a261b7554d 100644
--- a/frontend-modern/src/components/shared/PageControls.tsx
+++ b/frontend-modern/src/components/shared/PageControls.tsx
@@ -30,6 +30,15 @@ interface PageControlsMobileFilters {
onToggle: () => void;
}
+export const pageControlsControlDeckClass =
+ 'page-controls-control-deck grid w-full min-w-0 items-start gap-2 rounded-md border border-border bg-surface-alt p-1.5 shadow-sm xl:grid-cols-[minmax(0,1fr)_auto]';
+
+export const pageControlsFilterSectionClass =
+ 'page-controls-filter-section rounded-md border border-border-subtle bg-surface px-1.5 py-1 shadow-sm';
+
+export const pageControlsSectionedFilterControlsClass =
+ 'page-controls-filter-controls flex w-full min-w-0 flex-wrap items-start gap-2';
+
interface PageControlsProps extends JSX.HTMLAttributes<HTMLDivElement> {
searchLeading?: JSX.Element;
searchTrailing?: JSX.Element;
@@ -50,6 +59,7 @@ interface PageControlsProps extends JSX.HTMLAttributes<HTMLDivElement> {
actionsLayout?: 'inline' | 'stacked';
controlDeckClass?: string;
filterControlsClass?: string;
+ filterControlsVariant?: 'single-section' | 'sectioned-children';
toolbarActionsClass?: string;
}
@@ -74,6 +84,7 @@ export const PageControls: Component<PageControlsProps> = (props) => {
'actionsLayout',
'controlDeckClass',
'filterControlsClass',
+ 'filterControlsVariant',
'toolbarActionsClass',
'class',
]);
@@ -92,58 +103,76 @@ export const PageControls: Component<PageControlsProps> = (props) => {
const showColumnVisibility = () =>
Boolean(local.columnVisibility && local.columnVisibility.availableToggles().length > 0);
const showResetAction = () => local.resetAction?.show === true;
+ const showToolbarTrailing = () => Boolean(local.toolbarTrailing);
+ const showUtilityActions = () => Boolean(activeUtilityActions());
const hasTrailingActions = () =>
Boolean(
- local.toolbarTrailing ||
- activeUtilityActions() ||
- showColumnVisibility() ||
- showResetAction(),
+ showToolbarTrailing() || showUtilityActions() || showColumnVisibility() || showResetAction(),
);
- const actionsLayout = () => local.actionsLayout ?? 'inline';
+ const showDividerBeforeUtilityActions = () => showToolbarTrailing() && showUtilityActions();
+ const showDividerBeforeColumnVisibility = () =>
+ (showToolbarTrailing() || showUtilityActions()) && showColumnVisibility();
+ const showDividerBeforeResetAction = () =>
+ (showToolbarTrailing() || showUtilityActions() || showColumnVisibility()) && showResetAction();
+ const actionsLayout = () => local.actionsLayout ?? 'stacked';
+ const filtersUseSectionedChildren = () => local.filterControlsVariant === 'sectioned-children';
+ const resolvedControlDeckClass = () =>
+ local.controlDeckClass ??
+ (actionsLayout() === 'stacked' ? pageControlsControlDeckClass : undefined);
const filterControlsClass = () =>
local.filterControlsClass ??
(actionsLayout() === 'stacked'
- ? 'page-controls-filter-controls flex w-full min-w-0 flex-none basis-full flex-wrap items-center gap-2'
+ ? filtersUseSectionedChildren()
+ ? pageControlsSectionedFilterControlsClass
+ : `page-controls-filter-controls ${pageControlsFilterSectionClass} inline-flex w-fit max-w-full min-w-0 flex-wrap items-center gap-2 justify-self-start`
: 'page-controls-filter-controls flex min-w-0 flex-1 basis-0 flex-wrap items-center gap-2');
const toolbarActionsClass = () =>
local.toolbarActionsClass ??
(actionsLayout() === 'stacked'
- ? 'page-controls-toolbar-actions inline-flex w-full flex-wrap items-center gap-2 border-t border-border-subtle pt-2'
+ ? `page-controls-toolbar-actions ${pageControlsFilterSectionClass} inline-flex max-w-full flex-wrap items-center gap-2 xl:justify-self-end`
: 'page-controls-toolbar-actions ml-auto inline-flex shrink-0 flex-wrap items-center justify-end gap-2 self-start');
const toolbarControls = () => (
<>
<div class={filterControlsClass()}>{local.children}</div>
- <div class={toolbarActionsClass()}>
- <Show when={local.toolbarTrailing}>{local.toolbarTrailing}</Show>
+ <Show when={hasTrailingActions()}>
+ <div class={toolbarActionsClass()}>
+ <Show when={local.toolbarTrailing}>{local.toolbarTrailing}</Show>
- <Show when={activeUtilityActions()}>
- <FilterDivider />
- {activeUtilityActions()}
- </Show>
+ <Show when={activeUtilityActions()}>
+ <Show when={showDividerBeforeUtilityActions()}>
+ <FilterDivider />
+ </Show>
+ {activeUtilityActions()}
+ </Show>
- <Show when={showColumnVisibility()}>
- <FilterDivider />
- <ColumnPicker
- columns={local.columnVisibility!.availableToggles()}
- isHidden={local.columnVisibility!.isHiddenByUser}
- onToggle={local.columnVisibility!.toggle}
- onReset={local.columnVisibility!.resetToDefaults}
- />
- </Show>
+ <Show when={showColumnVisibility()}>
+ <Show when={showDividerBeforeColumnVisibility()}>
+ <FilterDivider />
+ </Show>
+ <ColumnPicker
+ columns={local.columnVisibility!.availableToggles()}
+ isHidden={local.columnVisibility!.isHiddenByUser}
+ onToggle={local.columnVisibility!.toggle}
+ onReset={local.columnVisibility!.resetToDefaults}
+ />
+ </Show>
- <Show when={showResetAction()}>
- <FilterDivider />
- <FilterActionButton
- onClick={() => local.resetAction?.onClick()}
- title={local.resetAction?.title}
- class={local.resetAction?.class}
- >
- {local.resetAction?.icon}
- {local.resetAction?.label ?? 'Reset'}
- </FilterActionButton>
- </Show>
- </div>
+ <Show when={showResetAction()}>
+ <Show when={showDividerBeforeResetAction()}>
+ <FilterDivider />
+ </Show>
+ <FilterActionButton
+ onClick={() => local.resetAction?.onClick()}
+ title={local.resetAction?.title}
+ class={local.resetAction?.class}
+ >
+ {local.resetAction?.icon}
+ {local.resetAction?.label ?? 'Reset'}
+ </FilterActionButton>
+ </Show>
+ </div>
+ </Show>
</>
);
@@ -162,13 +191,9 @@ export const PageControls: Component<PageControlsProps> = (props) => {
mobileTrailing={activeMobileTrailing()}
class={local.class}
>
- <Show when={hasTrailingActions()}>
- <Show when={local.controlDeckClass} fallback={toolbarControls()}>
- {(controlDeckClass) => <div class={controlDeckClass()}>{toolbarControls()}</div>}
- </Show>
+ <Show when={resolvedControlDeckClass()} fallback={toolbarControls()}>
+ {(controlDeckClass) => <div class={controlDeckClass()}>{toolbarControls()}</div>}
</Show>
-
- <Show when={!hasTrailingActions()}>{local.children}</Show>
</FilterHeader>
);
};