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.

Split dashboard filter runtime owners

rcourtman5eaf1e22c340
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 f40a6102a4..247787a462 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -27,25 +27,30 @@ regression protection.
5. `internal/api/slo_bench_test.go`
6. `frontend-modern/src/components/Dashboard/Dashboard.tsx`
7. `frontend-modern/src/components/Dashboard/useDashboardState.ts`
-8. `frontend-modern/src/components/Dashboard/DiskList.tsx`
-9. `frontend-modern/src/components/Dashboard/diskListModel.ts`
-10. `frontend-modern/src/components/Dashboard/useDiskListState.ts`
-11. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
-12. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
-13. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
-14. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
-15. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
-16. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
-17. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
-18. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
-19. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
-20. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
-21. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
-22. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
-23. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
-24. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
-25. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
-26. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
+8. `frontend-modern/src/components/Dashboard/DashboardFilter.tsx`
+9. `frontend-modern/src/components/Dashboard/dashboardFilterModel.ts`
+10. `frontend-modern/src/components/Dashboard/useDashboardFilterState.ts`
+11. `frontend-modern/src/components/Dashboard/DiskList.tsx`
+12. `frontend-modern/src/components/Dashboard/diskListModel.ts`
+13. `frontend-modern/src/components/Dashboard/useDiskListState.ts`
+14. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
+15. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
+16. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
+17. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
+18. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
+19. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
+20. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
+21. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
+22. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+23. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
+24. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
+25. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
+26. `frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx`
+27. `frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts`
+28. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
+29. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
+30. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
+31. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
## Shared Boundaries
@@ -68,6 +73,7 @@ regression protection.
9. Extend dashboard row contract and per-row hot-path derivations through `frontend-modern/src/components/Dashboard/guestRowModel.tsx` and `frontend-modern/src/components/Dashboard/useGuestRowState.ts` rather than rebuilding column metadata, row identity, or anomaly correlation inside `frontend-modern/src/components/Dashboard/GuestRow.tsx`
10. Extend dashboard drawer derivations and runtime wiring through `frontend-modern/src/components/Dashboard/guestDrawerModel.ts` and `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts` rather than rebuilding canonical guest identity, discovery routing, or drawer-local normalization inside `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
11. Extend dashboard disk-list derivations and fallback runtime wiring through `frontend-modern/src/components/Dashboard/diskListModel.ts` and `frontend-modern/src/components/Dashboard/useDiskListState.ts` rather than rebuilding usage math, progress-state mapping, or tooltip fallback logic inside `frontend-modern/src/components/Dashboard/DiskList.tsx`
+12. Extend dashboard filter defaults, active-filter counting, reset semantics, and mobile toolbar state through `frontend-modern/src/components/Dashboard/dashboardFilterModel.ts` and `frontend-modern/src/components/Dashboard/useDashboardFilterState.ts`, and keep dashboard-owned filter-config assembly in `frontend-modern/src/components/Dashboard/useDashboardState.ts`, rather than rebuilding filter-local state inside `frontend-modern/src/components/Dashboard/DashboardFilter.tsx` or inline config IIFEs in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
## Forbidden Paths
@@ -122,6 +128,16 @@ presentation derivations and fallback tooltip/runtime wiring live in
`frontend-modern/src/components/Dashboard/useDiskListState.ts`. Future disk
usage math, threshold-color routing, and fallback handling must extend
through those owners instead of accreting back into the shell.
+The dashboard filter now follows that same ownership rule: the shell
+stays in `frontend-modern/src/components/Dashboard/DashboardFilter.tsx`, while
+toolbar defaults, active-filter counting, and reset semantics live in
+`frontend-modern/src/components/Dashboard/dashboardFilterModel.ts` and
+`frontend-modern/src/components/Dashboard/useDashboardFilterState.ts`.
+The dashboard-owned filter-config assembly now lives in
+`frontend-modern/src/components/Dashboard/useDashboardState.ts`, so future
+filter runtime changes must extend through those owners instead of
+reintroducing dashboard-local state, reset drift, or inline config assembly
+into the shell.
The unified resource table hot path is now also governed as explicit
performance-owned runtime, with shared ownership against the unified-resource
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 9b4b76ec6f..9b83ec5cce 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2518,12 +2518,15 @@
],
"owned_files": [
"frontend-modern/src/components/Dashboard/Dashboard.tsx",
+ "frontend-modern/src/components/Dashboard/DashboardFilter.tsx",
+ "frontend-modern/src/components/Dashboard/dashboardFilterModel.ts",
"frontend-modern/src/components/Dashboard/DiskList.tsx",
"frontend-modern/src/components/Dashboard/diskListModel.ts",
"frontend-modern/src/components/Dashboard/GuestDrawer.tsx",
"frontend-modern/src/components/Dashboard/guestDrawerModel.ts",
"frontend-modern/src/components/Dashboard/GuestRow.tsx",
"frontend-modern/src/components/Dashboard/guestRowModel.tsx",
+ "frontend-modern/src/components/Dashboard/useDashboardFilterState.ts",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
"frontend-modern/src/components/Dashboard/useDiskListState.ts",
"frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
@@ -2542,7 +2545,9 @@
"test_prefixes": [],
"exact_files": [
"frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts",
"internal/api/router_bench_test.go",
"internal/api/slo_bench_test.go",
"pkg/metrics/store_bench_test.go",
@@ -2573,12 +2578,15 @@
"match_prefixes": [],
"match_files": [
"frontend-modern/src/components/Dashboard/Dashboard.tsx",
+ "frontend-modern/src/components/Dashboard/DashboardFilter.tsx",
+ "frontend-modern/src/components/Dashboard/dashboardFilterModel.ts",
"frontend-modern/src/components/Dashboard/DiskList.tsx",
"frontend-modern/src/components/Dashboard/diskListModel.ts",
"frontend-modern/src/components/Dashboard/GuestDrawer.tsx",
"frontend-modern/src/components/Dashboard/guestDrawerModel.ts",
"frontend-modern/src/components/Dashboard/GuestRow.tsx",
"frontend-modern/src/components/Dashboard/guestRowModel.tsx",
+ "frontend-modern/src/components/Dashboard/useDashboardFilterState.ts",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
"frontend-modern/src/components/Dashboard/useDiskListState.ts",
"frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
@@ -2593,8 +2601,10 @@
"test_prefixes": [],
"exact_files": [
"frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts",
"frontend-modern/src/components/Dashboard/__tests__/workloadSelectors.test.ts",
"frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx",
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx"
diff --git a/frontend-modern/src/components/Dashboard/Dashboard.tsx b/frontend-modern/src/components/Dashboard/Dashboard.tsx
index 23e120ecff..c04c1a7e53 100644
--- a/frontend-modern/src/components/Dashboard/Dashboard.tsx
+++ b/frontend-modern/src/components/Dashboard/Dashboard.tsx
@@ -28,10 +28,9 @@ export function Dashboard(props: DashboardProps) {
alertsEnabled,
allGuests,
bottomSpacerHeight,
- columnVisibility,
connected,
- containerRuntime,
- containerRuntimeOptions,
+ containerRuntimeFilterConfig,
+ dashboardFilterColumnVisibility,
dashboardDisconnectedState,
dashboardGuestsEmptyState,
dashboardInfrastructureEmptyState,
@@ -47,31 +46,25 @@ export function Dashboard(props: DashboardProps) {
handleNodeSelect,
handleSort,
handleTagClick,
+ hostFilterConfig,
hoveredWorkloadId,
initialDataReceived,
isMobile,
- isSearchLocked,
isWorkloadsRoute,
kioskMode,
- kubernetesContextOptions,
- kubernetesNamespaceOptions,
mobileVisibleColumnIds,
mobileVisibleColumns,
navigate,
+ namespaceFilterConfig,
nodeByInstance,
reconnect,
search,
selectedGuestId,
- selectedKubernetesContext,
- selectedKubernetesNamespace,
selectedNode,
- setContainerRuntime,
setGroupingMode,
setHoveredWorkloadId,
setSearch,
setSelectedGuestId,
- setSelectedKubernetesContext,
- setSelectedKubernetesNamespace,
setSortDirection,
setSortKey,
setStatusMode,
@@ -91,7 +84,6 @@ export function Dashboard(props: DashboardProps) {
visibleGroupKeys,
windowedGroupedGuests,
workloadIOEmphasis,
- workloadNodeOptions,
workloads,
workloadsSummaryCollapsed,
workloadsSummaryFallbackCounts,
@@ -245,7 +237,6 @@ export function Dashboard(props: DashboardProps) {
<DashboardFilter
search={search}
setSearch={setSearch}
- isSearchLocked={isSearchLocked}
viewMode={viewMode}
setViewMode={setViewMode}
statusMode={statusMode}
@@ -255,73 +246,14 @@ export function Dashboard(props: DashboardProps) {
setSortKey={setSortKey}
setSortDirection={setSortDirection}
onBeforeAutoFocus={handleBeforeAutoFocus}
- availableColumns={columnVisibility.availableToggles()}
- isColumnHidden={columnVisibility.isHiddenByUser}
- onColumnToggle={columnVisibility.toggle}
- onColumnReset={columnVisibility.resetToDefaults}
+ columnVisibility={dashboardFilterColumnVisibility()}
chartsCollapsed={isWorkloadsRoute() ? workloadsSummaryCollapsed : undefined}
onChartsToggle={
isWorkloadsRoute() ? () => setWorkloadsSummaryCollapsed((c) => !c) : undefined
}
- containerRuntimeFilter={(() => {
- if (!isWorkloadsRoute()) return undefined;
- if (viewMode() !== 'app-container') return undefined;
- const options = containerRuntimeOptions();
- if (options.length === 0) return undefined;
- return {
- id: 'workloads-container-runtime-filter',
- label: 'Runtime',
- value: containerRuntime(),
- options: [
- { value: '', label: 'All runtimes' },
- ...options.map((value) => ({ value, label: value })),
- ],
- onChange: (value: string) => setContainerRuntime(value),
- };
- })()}
- hostFilter={(() => {
- if (!isWorkloadsRoute()) return undefined;
- if (viewMode() === 'pod') {
- return {
- id: 'workloads-k8s-context-filter',
- label: 'Cluster',
- value: selectedKubernetesContext() ?? '',
- options: [
- { value: '', label: 'All clusters' },
- ...kubernetesContextOptions().map((context) => ({
- value: context,
- label: context,
- })),
- ],
- onChange: (value: string) => setSelectedKubernetesContext(value || null),
- };
- }
- return {
- id: 'workloads-node-filter',
- label: 'Node',
- value: selectedNode() ?? '',
- options: [{ value: '', label: 'All nodes' }, ...workloadNodeOptions()],
- onChange: (value: string) => {
- handleNodeSelect(value || null, value ? 'pve' : null);
- },
- };
- })()}
- namespaceFilter={(() => {
- if (!isWorkloadsRoute()) return undefined;
- if (viewMode() !== 'pod') return undefined;
- const options = kubernetesNamespaceOptions();
- if (options.length === 0) return undefined;
- return {
- id: 'workloads-k8s-namespace-filter',
- label: 'Namespace',
- value: selectedKubernetesNamespace() ?? '',
- options: [
- { value: '', label: 'All namespaces' },
- ...options.map((value) => ({ value, label: value })),
- ],
- onChange: (value: string) => setSelectedKubernetesNamespace(value || null),
- };
- })()}
+ containerRuntimeFilter={containerRuntimeFilterConfig()}
+ hostFilter={hostFilterConfig()}
+ namespaceFilter={namespaceFilterConfig()}
/>
</Show>
diff --git a/frontend-modern/src/components/Dashboard/DashboardFilter.tsx b/frontend-modern/src/components/Dashboard/DashboardFilter.tsx
index 3ad02e6670..32f6cc33e3 100644
--- a/frontend-modern/src/components/Dashboard/DashboardFilter.tsx
+++ b/frontend-modern/src/components/Dashboard/DashboardFilter.tsx
@@ -1,4 +1,4 @@
-import { Component, For, Show, createMemo, createSignal } from 'solid-js';
+import { Component, For, Show } from 'solid-js';
import { Card } from '@/components/shared/Card';
import {
FilterSegmentedControl,
@@ -6,67 +6,20 @@ import {
} from '@/components/shared/FilterToolbar';
import { PageControls } from '@/components/shared/PageControls';
import { SearchInput } from '@/components/shared/SearchInput';
-import type { ColumnDef } from '@/hooks/useColumnVisibility';
-import { useBreakpoint } from '@/hooks/useBreakpoint';
-import type { ViewMode } from '@/types/workloads';
import { STORAGE_KEYS } from '@/utils/localStorage';
-
-interface DashboardFilterProps {
- search: () => string;
- setSearch: (value: string) => void;
- isSearchLocked: () => boolean;
- viewMode: () => ViewMode;
- setViewMode: (value: ViewMode) => void;
- statusMode: () => 'all' | 'running' | 'degraded' | 'stopped';
- setStatusMode: (value: 'all' | 'running' | 'degraded' | 'stopped') => void;
- groupingMode: () => 'grouped' | 'flat';
- setGroupingMode: (value: 'grouped' | 'flat') => void;
- setSortKey: (value: string) => void;
- setSortDirection: (value: string) => void;
- onBeforeAutoFocus?: () => boolean;
- // Column visibility
- availableColumns?: ColumnDef[];
- isColumnHidden?: (id: string) => boolean;
- onColumnToggle?: (id: string) => void;
- onColumnReset?: () => void;
- hostFilter?: {
- id?: string;
- label?: string;
- value: string;
- options: { value: string; label: string }[];
- onChange: (value: string) => void;
- };
- namespaceFilter?: {
- id?: string;
- label?: string;
- value: string;
- options: { value: string; label: string }[];
- onChange: (value: string) => void;
- };
- containerRuntimeFilter?: {
- id?: string;
- label?: string;
- value: string;
- options: { value: string; label: string }[];
- onChange: (value: string) => void;
- };
- chartsCollapsed?: () => boolean;
- onChartsToggle?: () => void;
-}
+import type { DashboardFilterProps } from './dashboardFilterModel';
+import { useDashboardFilterState } from './useDashboardFilterState';
export const DashboardFilter: Component<DashboardFilterProps> = (props) => {
- const { isMobile } = useBreakpoint();
- const [filtersOpen, setFiltersOpen] = createSignal(false);
-
- const activeFilterCount = createMemo(() => {
- let count = 0;
- if (props.search().trim() !== '') count++;
- if (props.viewMode() !== 'all') count++;
- if (props.statusMode() !== 'all') count++;
- if (props.hostFilter && props.hostFilter.value !== '') count++;
- if (props.namespaceFilter && props.namespaceFilter.value !== '') count++;
- return count;
- });
+ const {
+ activeFilterCount,
+ isMobile,
+ pageControlsColumnVisibility,
+ resetFilters,
+ showReset,
+ showToolbarFilters,
+ toggleFilters,
+ } = useDashboardFilterState(props);
return (
<Card class="dashboard-filter mb-4" padding="sm">
@@ -84,41 +37,13 @@ export const DashboardFilter: Component<DashboardFilterProps> = (props) => {
}
mobileFilters={{
enabled: isMobile(),
- onToggle: () => setFiltersOpen((o) => !o),
+ onToggle: toggleFilters,
count: activeFilterCount(),
}}
- columnVisibility={
- props.availableColumns && props.isColumnHidden && props.onColumnToggle
- ? {
- availableToggles: () => props.availableColumns!,
- isHiddenByUser: props.isColumnHidden!,
- toggle: props.onColumnToggle!,
- resetToDefaults: props.onColumnReset ?? (() => undefined),
- }
- : undefined
- }
+ columnVisibility={pageControlsColumnVisibility()}
resetAction={{
- show:
- props.search().trim() !== '' ||
- props.viewMode() !== 'all' ||
- props.statusMode() !== 'all' ||
- props.groupingMode() !== 'grouped' ||
- (props.hostFilter ? props.hostFilter.value !== '' : false) ||
- (props.namespaceFilter ? props.namespaceFilter.value !== '' : false),
- onClick: () => {
- props.setSearch('');
- props.setSortKey('name');
- props.setSortDirection('asc');
- props.setViewMode('all');
- props.setStatusMode('all');
- props.setGroupingMode('grouped');
- if (props.hostFilter) {
- props.hostFilter.onChange('');
- }
- if (props.namespaceFilter) {
- props.namespaceFilter.onChange('');
- }
- },
+ show: showReset(),
+ onClick: resetFilters,
title: 'Reset all filters',
class: 'ml-auto text-base-content',
icon: (
@@ -137,7 +62,7 @@ export const DashboardFilter: Component<DashboardFilterProps> = (props) => {
</svg>
),
}}
- showFilters={!isMobile() || filtersOpen()}
+ showFilters={showToolbarFilters()}
toolbarClass="lg:flex-nowrap"
>
<Show when={props.hostFilter}>
diff --git a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
index 536e3dac81..52965f7410 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
@@ -4,7 +4,10 @@ import { createSignal, onCleanup, onMount } from 'solid-js';
import type { Resource } from '@/types/resource';
import { Dashboard } from '../Dashboard';
import dashboardSource from '../Dashboard.tsx?raw';
+import dashboardFilterSource from '../DashboardFilter.tsx?raw';
+import dashboardFilterModelSource from '../dashboardFilterModel.ts?raw';
import dashboardStateSource from '../useDashboardState.ts?raw';
+import dashboardFilterStateSource from '../useDashboardFilterState.ts?raw';
import diskListSource from '../DiskList.tsx?raw';
import diskListModelSource from '../diskListModel.ts?raw';
import diskListStateSource from '../useDiskListState.ts?raw';
@@ -476,6 +479,21 @@ describe('Dashboard performance contract', () => {
expect(dashboardStateSource).not.toContain('const guestId = () => {');
});
+ it('keeps dashboard filter state in canonical dashboard filter owners', () => {
+ expect(dashboardFilterSource).toContain('useDashboardFilterState');
+ expect(dashboardFilterSource).not.toContain('const [filtersOpen, setFiltersOpen] =');
+ expect(dashboardFilterSource).not.toContain('useBreakpoint');
+ expect(dashboardFilterSource).not.toContain("props.setSortKey('name')");
+ expect(dashboardFilterStateSource).toContain('countActiveDashboardFilters');
+ expect(dashboardFilterStateSource).not.toContain('props.containerRuntimeFilter?.onChange');
+ expect(dashboardFilterStateSource).toContain('useBreakpoint');
+ expect(dashboardFilterModelSource).toContain('export const countActiveDashboardFilters');
+ expect(dashboardFilterModelSource).toContain('export const hasActiveDashboardFilters');
+ expect(dashboardStateSource).toContain('containerRuntimeFilterConfig');
+ expect(dashboardStateSource).toContain('hostFilterConfig');
+ expect(dashboardStateSource).toContain('namespaceFilterConfig');
+ });
+
it('keeps guest row contract and hot-path state in canonical row owners', () => {
expect(guestRowSource).toContain('useGuestRowState');
expect(guestRowSource).not.toContain('export const GUEST_COLUMNS');
diff --git a/frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx
index 64896569d0..6e91038d1a 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx
@@ -1,6 +1,7 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render, screen, cleanup, fireEvent } from '@solidjs/testing-library';
import { DashboardFilter } from '../DashboardFilter';
+import type { DashboardFilterProps } from '../dashboardFilterModel';
// Mock useBreakpoint — hoist so tests can control isMobile
const { isMobileMock } = vi.hoisted(() => {
@@ -37,11 +38,10 @@ vi.mock('@/components/shared/ColumnPicker', () => ({
}));
/** Helper to build default required props, with optional overrides. */
-function makeProps(overrides: Partial<Parameters<typeof DashboardFilter>[0]> = {}) {
+function makeProps(overrides: Partial<DashboardFilterProps> = {}): DashboardFilterProps {
return {
search: vi.fn(() => ''),
setSearch: vi.fn(),
- isSearchLocked: vi.fn(() => false),
viewMode: vi.fn(() => 'all' as const),
setViewMode: vi.fn(),
statusMode: vi.fn(() => 'all' as const),
@@ -234,9 +234,7 @@ describe('DashboardFilter', () => {
expect(namespaceOnChange).toHaveBeenCalledWith('');
});
- it('does not reset containerRuntimeFilter on reset (current behavior)', () => {
- // NOTE: The reset handler does not clear containerRuntimeFilter.
- // This test documents the current behavior.
+ it('does not reset containerRuntimeFilter when clicked', () => {
const runtimeOnChange = vi.fn();
const props = makeProps({
search: vi.fn(() => 'test'),
@@ -254,9 +252,24 @@ describe('DashboardFilter', () => {
fireEvent.click(screen.getByText('Reset'));
- // containerRuntimeFilter.onChange is NOT called by reset
expect(runtimeOnChange).not.toHaveBeenCalled();
});
+
+ it('shows when a container runtime filter is active', () => {
+ const props = makeProps({
+ viewMode: vi.fn(() => 'app-container' as const),
+ containerRuntimeFilter: {
+ value: 'podman',
+ options: [
+ { value: '', label: 'All Runtimes' },
+ { value: 'podman', label: 'Podman' },
+ ],
+ onChange: vi.fn(),
+ },
+ });
+ render(() => <DashboardFilter {...props} />);
+ expect(screen.getByText('Reset')).toBeInTheDocument();
+ });
});
// --- Host filter ---
@@ -439,9 +452,11 @@ describe('DashboardFilter', () => {
describe('column picker', () => {
it('renders ColumnPicker when all column props are provided', () => {
const props = makeProps({
- availableColumns: [{ id: 'cpu', label: 'CPU' }],
- isColumnHidden: vi.fn(() => false),
- onColumnToggle: vi.fn(),
+ columnVisibility: {
+ availableColumns: [{ id: 'cpu', label: 'CPU' }],
+ isColumnHidden: vi.fn(() => false),
+ onColumnToggle: vi.fn(),
+ },
});
render(() => <DashboardFilter {...props} />);
expect(screen.getByTestId('column-picker')).toBeInTheDocument();
@@ -546,6 +561,23 @@ describe('DashboardFilter', () => {
expect(screen.getByText('5')).toBeInTheDocument();
});
+ it('does not count container runtime as an active filter', () => {
+ isMobileMock.mockReturnValue(true);
+ const props = makeProps({
+ viewMode: vi.fn(() => 'app-container' as const),
+ containerRuntimeFilter: {
+ value: 'docker',
+ options: [
+ { value: '', label: 'All runtimes' },
+ { value: 'docker', label: 'Docker' },
+ ],
+ onChange: vi.fn(),
+ },
+ });
+ render(() => <DashboardFilter {...props} />);
+ expect(screen.getByText('1')).toBeInTheDocument();
+ });
+
it('does not count whitespace-only search as active', () => {
isMobileMock.mockReturnValue(true);
const props = makeProps({ search: vi.fn(() => ' ') });
diff --git a/frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts b/frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts
new file mode 100644
index 0000000000..d70b40c8f3
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts
@@ -0,0 +1,80 @@
+import { renderHook } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { describe, expect, it, vi } from 'vitest';
+import { useDashboardFilterState } from '@/components/Dashboard/useDashboardFilterState';
+
+vi.mock('@/hooks/useBreakpoint', () => ({
+ useBreakpoint: () => ({
+ isMobile: () => false,
+ }),
+}));
+
+describe('useDashboardFilterState', () => {
+ it('centralizes dashboard filter state and reset behavior', () => {
+ const [search, setSearch] = createSignal('query');
+ const [viewMode, setViewMode] = createSignal<
+ 'all' | 'vm' | 'system-container' | 'app-container' | 'pod'
+ >('vm');
+ const [statusMode, setStatusMode] = createSignal<'all' | 'running' | 'degraded' | 'stopped'>(
+ 'running',
+ );
+ const [groupingMode, setGroupingMode] = createSignal<'grouped' | 'flat'>('flat');
+ const [sortKey, setSortKey] = createSignal('cpu');
+ const [sortDirection, setSortDirection] = createSignal('desc');
+ const hostOnChange = vi.fn();
+ const namespaceOnChange = vi.fn();
+ const runtimeOnChange = vi.fn();
+
+ const { result } = renderHook(() =>
+ useDashboardFilterState({
+ search,
+ setSearch,
+ viewMode,
+ setViewMode,
+ statusMode,
+ setStatusMode,
+ groupingMode,
+ setGroupingMode,
+ setSortKey,
+ setSortDirection,
+ hostFilter: {
+ value: 'host-1',
+ options: [{ value: 'host-1', label: 'Host 1' }],
+ onChange: hostOnChange,
+ },
+ namespaceFilter: {
+ value: 'ns-1',
+ options: [{ value: 'ns-1', label: 'NS 1' }],
+ onChange: namespaceOnChange,
+ },
+ containerRuntimeFilter: {
+ value: 'docker',
+ options: [{ value: 'docker', label: 'Docker' }],
+ onChange: runtimeOnChange,
+ },
+ }),
+ );
+
+ expect(result.activeFilterCount()).toBe(5);
+ expect(result.showReset()).toBe(true);
+ expect(result.showToolbarFilters()).toBe(true);
+ expect(result.filtersOpen()).toBe(false);
+ expect(result.isMobile()).toBe(false);
+
+ result.setFiltersOpen(true);
+ expect(result.filtersOpen()).toBe(true);
+ expect(result.showToolbarFilters()).toBe(true);
+
+ result.resetFilters();
+
+ expect(search()).toBe('');
+ expect(viewMode()).toBe('all');
+ expect(statusMode()).toBe('all');
+ expect(groupingMode()).toBe('grouped');
+ expect(sortKey()).toBe('name');
+ expect(sortDirection()).toBe('asc');
+ expect(hostOnChange).toHaveBeenCalledWith('');
+ expect(namespaceOnChange).toHaveBeenCalledWith('');
+ expect(runtimeOnChange).not.toHaveBeenCalled();
+ });
+});
diff --git a/frontend-modern/src/components/Dashboard/dashboardFilterModel.ts b/frontend-modern/src/components/Dashboard/dashboardFilterModel.ts
new file mode 100644
index 0000000000..b351ea070e
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/dashboardFilterModel.ts
@@ -0,0 +1,81 @@
+import type { ColumnDef } from '@/hooks/useColumnVisibility';
+import type { ViewMode } from '@/types/workloads';
+
+export type DashboardStatusMode = 'all' | 'running' | 'degraded' | 'stopped';
+export type DashboardGroupingMode = 'grouped' | 'flat';
+
+export interface DashboardFilterSelectOption {
+ value: string;
+ label: string;
+}
+
+export interface DashboardToolbarFilterConfig {
+ id?: string;
+ label?: string;
+ value: string;
+ options: DashboardFilterSelectOption[];
+ onChange: (value: string) => void;
+}
+
+export interface DashboardFilterProps {
+ search: () => string;
+ setSearch: (value: string) => void;
+ viewMode: () => ViewMode;
+ setViewMode: (value: ViewMode) => void;
+ statusMode: () => DashboardStatusMode;
+ setStatusMode: (value: DashboardStatusMode) => void;
+ groupingMode: () => DashboardGroupingMode;
+ setGroupingMode: (value: DashboardGroupingMode) => void;
+ setSortKey: (value: string) => void;
+ setSortDirection: (value: string) => void;
+ onBeforeAutoFocus?: () => boolean;
+ columnVisibility?: {
+ availableColumns: ColumnDef[];
+ isColumnHidden: (id: string) => boolean;
+ onColumnToggle: (id: string) => void;
+ onColumnReset?: () => void;
+ };
+ hostFilter?: DashboardToolbarFilterConfig;
+ namespaceFilter?: DashboardToolbarFilterConfig;
+ containerRuntimeFilter?: DashboardToolbarFilterConfig;
+ chartsCollapsed?: () => boolean;
+ onChartsToggle?: () => void;
+}
+
+export interface CountActiveDashboardFiltersOptions {
+ search: string;
+ viewMode: ViewMode;
+ statusMode: DashboardStatusMode;
+ hostFilterValue?: string;
+ namespaceFilterValue?: string;
+}
+
+export interface HasActiveDashboardFiltersOptions extends CountActiveDashboardFiltersOptions {
+ groupingMode: DashboardGroupingMode;
+}
+
+export const DEFAULT_DASHBOARD_SORT_KEY = 'name';
+export const DEFAULT_DASHBOARD_SORT_DIRECTION = 'asc';
+export const DEFAULT_DASHBOARD_VIEW_MODE: ViewMode = 'all';
+export const DEFAULT_DASHBOARD_STATUS_MODE: DashboardStatusMode = 'all';
+export const DEFAULT_DASHBOARD_GROUPING_MODE: DashboardGroupingMode = 'grouped';
+
+export const countActiveDashboardFilters = (
+ options: CountActiveDashboardFiltersOptions,
+): number => {
+ let count = 0;
+
+ if (options.search.trim() !== '') count++;
+ if (options.viewMode !== DEFAULT_DASHBOARD_VIEW_MODE) count++;
+ if (options.statusMode !== DEFAULT_DASHBOARD_STATUS_MODE) count++;
+ if ((options.hostFilterValue ?? '') !== '') count++;
+ if ((options.namespaceFilterValue ?? '') !== '') count++;
+
+ return count;
+};
+
+export const hasActiveDashboardFilters = (
+ options: HasActiveDashboardFiltersOptions,
+): boolean =>
+ countActiveDashboardFilters(options) > 0 ||
+ options.groupingMode !== DEFAULT_DASHBOARD_GROUPING_MODE;
diff --git a/frontend-modern/src/components/Dashboard/useDashboardFilterState.ts b/frontend-modern/src/components/Dashboard/useDashboardFilterState.ts
new file mode 100644
index 0000000000..f4cf3cc2b6
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/useDashboardFilterState.ts
@@ -0,0 +1,79 @@
+import { createMemo, createSignal } from 'solid-js';
+
+import { useBreakpoint } from '@/hooks/useBreakpoint';
+
+import {
+ countActiveDashboardFilters,
+ DEFAULT_DASHBOARD_GROUPING_MODE,
+ DEFAULT_DASHBOARD_SORT_DIRECTION,
+ DEFAULT_DASHBOARD_SORT_KEY,
+ DEFAULT_DASHBOARD_STATUS_MODE,
+ DEFAULT_DASHBOARD_VIEW_MODE,
+ hasActiveDashboardFilters,
+ type DashboardFilterProps,
+} from './dashboardFilterModel';
+
+export const useDashboardFilterState = (props: DashboardFilterProps) => {
+ const { isMobile } = useBreakpoint();
+ const [filtersOpen, setFiltersOpen] = createSignal(false);
+
+ const activeFilterCount = createMemo(() =>
+ countActiveDashboardFilters({
+ search: props.search(),
+ viewMode: props.viewMode(),
+ statusMode: props.statusMode(),
+ hostFilterValue: props.hostFilter?.value,
+ namespaceFilterValue: props.namespaceFilter?.value,
+ }),
+ );
+
+ const showReset = createMemo(() =>
+ hasActiveDashboardFilters({
+ search: props.search(),
+ viewMode: props.viewMode(),
+ statusMode: props.statusMode(),
+ groupingMode: props.groupingMode(),
+ hostFilterValue: props.hostFilter?.value,
+ namespaceFilterValue: props.namespaceFilter?.value,
+ }),
+ );
+
+ const pageControlsColumnVisibility = createMemo(() =>
+ props.columnVisibility
+ ? {
+ availableToggles: () => props.columnVisibility!.availableColumns,
+ isHiddenByUser: props.columnVisibility!.isColumnHidden,
+ toggle: props.columnVisibility!.onColumnToggle,
+ resetToDefaults: props.columnVisibility!.onColumnReset ?? (() => undefined),
+ }
+ : undefined,
+ );
+
+ const toggleFilters = () => {
+ setFiltersOpen((open) => !open);
+ };
+
+ const resetFilters = () => {
+ props.setSearch('');
+ props.setSortKey(DEFAULT_DASHBOARD_SORT_KEY);
+ props.setSortDirection(DEFAULT_DASHBOARD_SORT_DIRECTION);
+ props.setViewMode(DEFAULT_DASHBOARD_VIEW_MODE);
+ props.setStatusMode(DEFAULT_DASHBOARD_STATUS_MODE);
+ props.setGroupingMode(DEFAULT_DASHBOARD_GROUPING_MODE);
+
+ props.hostFilter?.onChange('');
+ props.namespaceFilter?.onChange('');
+ };
+
+ return {
+ activeFilterCount,
+ filtersOpen,
+ isMobile,
+ pageControlsColumnVisibility,
+ resetFilters,
+ setFiltersOpen,
+ showReset,
+ showToolbarFilters: createMemo(() => !isMobile() || filtersOpen()),
+ toggleFilters,
+ };
+};
diff --git a/frontend-modern/src/components/Dashboard/useDashboardState.ts b/frontend-modern/src/components/Dashboard/useDashboardState.ts
index e6575b6f8e..95bdd56333 100644
--- a/frontend-modern/src/components/Dashboard/useDashboardState.ts
+++ b/frontend-modern/src/components/Dashboard/useDashboardState.ts
@@ -56,6 +56,7 @@ import {
} from './workloadSelectors';
import { useGroupedTableWindowing } from './useGroupedTableWindowing';
import type { WorkloadSummarySnapshot } from '@/components/Workloads/WorkloadsSummary';
+import type { DashboardToolbarFilterConfig } from './dashboardFilterModel';
export interface DashboardProps {
vms: VM[];
@@ -1253,6 +1254,81 @@ export function useDashboardState(props: DashboardProps) {
}
};
+ const dashboardFilterColumnVisibility = createMemo(() => ({
+ availableColumns: columnVisibility.availableToggles(),
+ isColumnHidden: columnVisibility.isHiddenByUser,
+ onColumnToggle: columnVisibility.toggle,
+ onColumnReset: columnVisibility.resetToDefaults,
+ }));
+
+ const containerRuntimeFilterConfig = createMemo<DashboardToolbarFilterConfig | undefined>(() => {
+ if (!isWorkloadsRoute()) return undefined;
+ if (viewMode() !== 'app-container') return undefined;
+
+ const options = containerRuntimeOptions();
+ if (options.length === 0) return undefined;
+
+ return {
+ id: 'workloads-container-runtime-filter',
+ label: 'Runtime',
+ value: containerRuntime(),
+ options: [
+ { value: '', label: 'All runtimes' },
+ ...options.map((value) => ({ value, label: value })),
+ ],
+ onChange: (value: string) => setContainerRuntime(value),
+ };
+ });
+
+ const hostFilterConfig = createMemo<DashboardToolbarFilterConfig | undefined>(() => {
+ if (!isWorkloadsRoute()) return undefined;
+
+ if (viewMode() === 'pod') {
+ return {
+ id: 'workloads-k8s-context-filter',
+ label: 'Cluster',
+ value: selectedKubernetesContext() ?? '',
+ options: [
+ { value: '', label: 'All clusters' },
+ ...kubernetesContextOptions().map((context) => ({
+ value: context,
+ label: context,
+ })),
+ ],
+ onChange: (value: string) => setSelectedKubernetesContext(value || null),
+ };
+ }
+
+ return {
+ id: 'workloads-node-filter',
+ label: 'Node',
+ value: selectedNode() ?? '',
+ options: [{ value: '', label: 'All nodes' }, ...workloadNodeOptions()],
+ onChange: (value: string) => {
+ handleNodeSelect(value || null, value ? 'pve' : null);
+ },
+ };
+ });
+
+ const namespaceFilterConfig = createMemo<DashboardToolbarFilterConfig | undefined>(() => {
+ if (!isWorkloadsRoute()) return undefined;
+ if (viewMode() !== 'pod') return undefined;
+
+ const options = kubernetesNamespaceOptions();
+ if (options.length === 0) return undefined;
+
+ return {
+ id: 'workloads-k8s-namespace-filter',
+ label: 'Namespace',
+ value: selectedKubernetesNamespace() ?? '',
+ options: [
+ { value: '', label: 'All namespaces' },
+ ...options.map((value) => ({ value, label: value })),
+ ],
+ onChange: (value: string) => setSelectedKubernetesNamespace(value || null),
+ };
+ });
+
return {
activeAlerts,
alertsEnabled,
@@ -1261,7 +1337,9 @@ export function useDashboardState(props: DashboardProps) {
columnVisibility,
connected,
containerRuntime,
+ containerRuntimeFilterConfig,
containerRuntimeOptions,
+ dashboardFilterColumnVisibility,
dashboardDisconnectedState,
dashboardGuestsEmptyState,
dashboardInfrastructureEmptyState,
@@ -1277,6 +1355,7 @@ export function useDashboardState(props: DashboardProps) {
handleNodeSelect,
handleSort,
handleTagClick,
+ hostFilterConfig,
hoveredWorkloadId,
initialDataReceived,
isMobile,
@@ -1289,6 +1368,7 @@ export function useDashboardState(props: DashboardProps) {
mobileVisibleColumns,
navigate,
nodeByInstance,
+ namespaceFilterConfig,
reconnect,
search,
selectedGuestId,
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 464bddf800..e5fc14e554 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -79,7 +79,10 @@ import recoveryTablePresentationSource from '@/utils/recoveryTablePresentation.t
import recoveryTimelineChartPresentationSource from '@/utils/recoveryTimelineChartPresentation.ts?raw';
import recoveryTimelinePresentationSource from '@/utils/recoveryTimelinePresentation.ts?raw';
import dashboardSource from '@/components/Dashboard/Dashboard.tsx?raw';
+import dashboardFilterSource from '@/components/Dashboard/DashboardFilter.tsx?raw';
+import dashboardFilterModelSource from '@/components/Dashboard/dashboardFilterModel.ts?raw';
import dashboardStateSource from '@/components/Dashboard/useDashboardState.ts?raw';
+import dashboardFilterStateSource from '@/components/Dashboard/useDashboardFilterState.ts?raw';
import workloadsSummarySource from '@/components/Workloads/WorkloadsSummary.tsx?raw';
import dashboardRouteSource from '@/pages/Dashboard.tsx?raw';
import dashboardHelpersSource from '@/pages/DashboardPanels/dashboardHelpers.ts?raw';
@@ -496,6 +499,18 @@ describe('frontend resource type boundaries', () => {
expect(dashboardStateSource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");
expect(dashboardStateSource).not.toContain('const normalizeOrgScope =');
expect(dashboardStateSource).not.toContain('const guestId = () => {');
+ expect(dashboardFilterSource).toContain('useDashboardFilterState');
+ expect(dashboardFilterSource).not.toContain('const [filtersOpen, setFiltersOpen] =');
+ expect(dashboardFilterSource).not.toContain('useBreakpoint');
+ expect(dashboardFilterSource).not.toContain("props.setSortKey('name')");
+ expect(dashboardFilterStateSource).toContain('countActiveDashboardFilters');
+ expect(dashboardFilterStateSource).not.toContain('props.containerRuntimeFilter?.onChange');
+ expect(dashboardFilterStateSource).toContain('useBreakpoint');
+ expect(dashboardFilterModelSource).toContain('export const countActiveDashboardFilters');
+ expect(dashboardFilterModelSource).toContain('export const hasActiveDashboardFilters');
+ expect(dashboardStateSource).toContain('containerRuntimeFilterConfig');
+ expect(dashboardStateSource).toContain('hostFilterConfig');
+ expect(dashboardStateSource).toContain('namespaceFilterConfig');
expect(workloadsSummarySource).toContain('normalizeOrgScope(getOrgID())');
expect(workloadsSummarySource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");
expect(workloadsSummarySource).not.toContain('const normalizeOrgScope =');
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index dd07d813ba..35ac7794b7 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -1856,6 +1856,36 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["id"],
"dashboard-workload-hot-path",
)
+
+ def test_lookup_paths_assigns_dashboard_filter_runtime_to_performance_and_scalability(self) -> None:
+ result = lookup_paths(
+ [
+ "frontend-modern/src/components/Dashboard/DashboardFilter.tsx",
+ "frontend-modern/src/components/Dashboard/dashboardFilterModel.ts",
+ "frontend-modern/src/components/Dashboard/useDashboardFilterState.ts",
+ ]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+ self.assertEqual(
+ {item["subsystem"] for item in result["impacted_subsystems"]},
+ {"performance-and-scalability"},
+ )
+ for file_entry in result["files"]:
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(
+ {match["subsystem"] for match in file_entry["matches"]},
+ {"performance-and-scalability"},
+ )
+ match = file_entry["matches"][0]
+ self.assertEqual(
+ match["contract"],
+ "docs/release-control/v6/internal/subsystems/performance-and-scalability.md",
+ )
+ self.assertEqual(match["lane_context"]["lane_id"], "L10")
+ self.assertEqual(
+ match["verification_requirement"]["id"],
+ "dashboard-workload-hot-path",
+ )
self.assertEqual(
match["verification_requirement"]["id"],
"dashboard-workload-hot-path",