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.

Add Machines filter reset path

rcourtman53149ab6c241
diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
index 9ae4a2a149..28058e1782 100644
--- a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
@@ -129,10 +129,12 @@ describe('filterPlatformResources', () => {
expect(state.total()).toBe(resources.length);
expect(state.visible()).toBe(resources.length);
+ expect(state.hasActiveFilters()).toBe(false);
state.setSearch('gpu');
expect(state.filtered().map((r) => r.id)).toEqual(['host-with-tag']);
expect(state.visible()).toBe(1);
+ expect(state.hasActiveFilters()).toBe(true);
state.setSearch('host');
state.setStatus('offline');
@@ -142,6 +144,12 @@ describe('filterPlatformResources', () => {
.map((r) => r.id)
.sort(),
).toEqual(['host-delta', 'host-echo']);
+
+ state.resetFilters();
+ expect(state.search()).toBe('');
+ expect(state.status()).toBe('all');
+ expect(state.visible()).toBe(resources.length);
+ expect(state.hasActiveFilters()).toBe(false);
} finally {
dispose();
}
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index 1ebbb1d949..ae6b9775cd 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -1,4 +1,5 @@
import { A } from '@solidjs/router';
+import RotateCcwIcon from 'lucide-solid/icons/rotate-ccw';
import TriangleAlertIcon from 'lucide-solid/icons/triangle-alert';
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
import { EmptyState } from '@/components/shared/EmptyState';
@@ -252,6 +253,13 @@ export function createPlatformTableFilterState<Row, Status extends string | numb
const filtered = createMemo(() => props.filter(props.resources(), search(), status()));
const visible = createMemo(() => filtered().length);
const total = createMemo(() => props.resources().length);
+ const hasActiveFilters = createMemo(
+ () => search().trim().length > 0 || status() !== props.initialStatus,
+ );
+ const resetFilters = () => {
+ setSearch('');
+ setStatus(() => props.initialStatus);
+ };
return {
search,
@@ -261,9 +269,27 @@ export function createPlatformTableFilterState<Row, Status extends string | numb
filtered,
visible,
total,
+ hasActiveFilters,
+ resetFilters,
};
}
+export const PlatformTableResetFiltersButton: Component<{
+ onReset: () => void;
+ label?: string;
+}> = (props) => (
+ <button
+ type="button"
+ onClick={props.onReset}
+ class="inline-flex min-h-8 items-center justify-center gap-1.5 rounded-md border border-border bg-surface px-2.5 py-1 text-xs font-medium text-muted transition-colors hover:bg-surface-hover hover:text-base-content focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/60"
+ title={props.label ?? 'Reset filters'}
+ aria-label={props.label ?? 'Reset filters'}
+ >
+ <RotateCcwIcon class="h-3.5 w-3.5" aria-hidden="true" />
+ <span class="hidden sm:inline">{props.label ?? 'Reset filters'}</span>
+ </button>
+);
+
// Compact operator-facing counter shown at the right of the toolbar so
// users can read total / matching at a glance, mirroring v5's dense
// dashboard counters without spawning a card grid.
@@ -296,6 +322,8 @@ export function PlatformTableToolbar<T extends string | number>(props: {
visible: number;
total: number;
rowNoun: string;
+ hasActiveFilters?: boolean;
+ onResetFilters?: () => void;
}) {
return (
<div class="flex flex-wrap items-center gap-2">
@@ -315,6 +343,9 @@ export function PlatformTableToolbar<T extends string | number>(props: {
value={props.status}
onChange={props.onStatusChange}
/>
+ <Show when={props.hasActiveFilters && props.onResetFilters}>
+ <PlatformTableResetFiltersButton onReset={props.onResetFilters!} />
+ </Show>
<PlatformResourceCounter
visible={props.visible}
total={props.total}
@@ -361,6 +392,8 @@ export const PlatformResourceTable: Component<{
visible={tableState.visible()}
total={tableState.total()}
rowNoun="rows"
+ hasActiveFilters={tableState.hasActiveFilters()}
+ onResetFilters={tableState.resetFilters}
/>
<Show
when={tableState.filtered().length > 0}
@@ -369,6 +402,7 @@ export const PlatformResourceTable: Component<{
icon={props.emptyIcon}
title="No rows match current filters"
description="Adjust the search or status filter to see more rows."
+ actions={<PlatformTableResetFiltersButton onReset={tableState.resetFilters} />}
/>
}
>
diff --git a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
index e8e3033905..8127f262fc 100644
--- a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
+++ b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
@@ -40,6 +40,7 @@ import {
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
PlatformTableEmptyState,
+ PlatformTableResetFiltersButton,
PlatformTableToolbar,
createPlatformTableFilterState,
filterPlatformResources,
@@ -1143,6 +1144,8 @@ export const AgentsMachinesTable: Component<{
visible={tableState.visible()}
total={tableState.total()}
rowNoun="machines"
+ hasActiveFilters={tableState.hasActiveFilters()}
+ onResetFilters={tableState.resetFilters}
/>
</div>
<ColumnPicker
@@ -1160,6 +1163,7 @@ export const AgentsMachinesTable: Component<{
icon={props.emptyIcon}
title="No machines match current filters"
description="Adjust the search or status filter to see more Pulse Agent machines."
+ actions={<PlatformTableResetFiltersButton onReset={tableState.resetFilters} />}
/>
}
>
diff --git a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
index cce24a4758..87b927ac32 100644
--- a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
+++ b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
@@ -253,6 +253,35 @@ describe('AgentsMachinesTable', () => {
).toBeInTheDocument();
});
+ it('resets active filters from the Machines empty state', async () => {
+ render(() => (
+ <AgentsMachinesTable
+ resources={[
+ resource({ id: 'mac-mini', name: 'Mac Mini', status: 'online' }),
+ resource({ id: 'windows-runner', name: 'Windows Runner', status: 'offline' }),
+ ]}
+ emptyIcon={emptyIcon}
+ emptyTitle="No machines"
+ emptyDescription="Install Pulse Agent."
+ />
+ ));
+
+ const search = screen.getByPlaceholderText('Search machines') as HTMLInputElement;
+
+ await fireEvent.input(search, { target: { value: 'does-not-exist' } });
+
+ expect(screen.getByText('No machines match current filters')).toBeInTheDocument();
+ expect(screen.queryByText('Mac Mini')).not.toBeInTheDocument();
+ expect(screen.queryByText('Windows Runner')).not.toBeInTheDocument();
+
+ await fireEvent.click(screen.getAllByRole('button', { name: 'Reset filters' })[0]);
+
+ expect(search.value).toBe('');
+ expect(screen.queryByText('No machines match current filters')).not.toBeInTheDocument();
+ expect(screen.getByText('Mac Mini')).toBeInTheDocument();
+ expect(screen.getByText('Windows Runner')).toBeInTheDocument();
+ });
+
it('preserves last-seen context in the machine subtitle when that column is hidden', async () => {
vi.spyOn(Date, 'now').mockReturnValue(1_700_000_600_000);