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.

Share platform table toolbar

rcourtmane803e823b729
diff --git a/frontend-modern/src/features/docker/DockerHostsTable.tsx b/frontend-modern/src/features/docker/DockerHostsTable.tsx
index ffb8673f38..88cef19866 100644
--- a/frontend-modern/src/features/docker/DockerHostsTable.tsx
+++ b/frontend-modern/src/features/docker/DockerHostsTable.tsx
@@ -1,6 +1,4 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
-import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
-import { SearchInput } from '@/components/shared/SearchInput';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
@@ -18,6 +16,8 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableToolbar,
PlatformTableEmptyState,
filterPlatformResources,
getPlatformTableCellClass,
@@ -35,13 +35,6 @@ import type { Resource } from '@/types/resource';
// any other agent. This bespoke table reuses canonical shared
// primitives and surfaces the Docker-native columns.
-const STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
- { value: 'all', label: 'All' },
- { value: 'online', label: 'Healthy' },
- { value: 'degraded', label: 'Degraded' },
- { value: 'offline', label: 'Offline' },
-];
-
const formatPercent = (percent?: number): JSX.Element => {
if (typeof percent !== 'number' || Number.isNaN(percent))
return <span class="text-muted">—</span>;
@@ -98,21 +91,17 @@ export const DockerHostsTable: Component<{
>
<div class="space-y-3">
<Show when={props.showToolbar !== false}>
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[200px] flex-1 sm:max-w-xs">
- <SearchInput value={search} onChange={setSearch} placeholder="Search Docker hosts" />
- </div>
- <FilterButtonGroup
- options={STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={visible() !== total()} fallback={<>{total()} hosts</>}>
- {visible()} of {total()} hosts
- </Show>
- </span>
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder="Search Docker hosts"
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={visible()}
+ total={total()}
+ rowNoun="hosts"
+ />
</Show>
<Show
diff --git a/frontend-modern/src/features/docker/DockerServicesTable.tsx b/frontend-modern/src/features/docker/DockerServicesTable.tsx
index d64f8b2278..a3993ee7a9 100644
--- a/frontend-modern/src/features/docker/DockerServicesTable.tsx
+++ b/frontend-modern/src/features/docker/DockerServicesTable.tsx
@@ -1,6 +1,4 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
-import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
-import { SearchInput } from '@/components/shared/SearchInput';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
@@ -18,6 +16,8 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableToolbar,
PlatformTableEmptyState,
filterPlatformResources,
getPlatformTableCellClass,
@@ -35,13 +35,6 @@ import type { Resource } from '@/types/resource';
// FilterButtonGroup, StatusDot) but surfaces operator columns that the
// data actually backs: image, mode, replica counts, ports, host.
-const STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
- { value: 'all', label: 'All' },
- { value: 'online', label: 'Healthy' },
- { value: 'degraded', label: 'Degraded' },
- { value: 'offline', label: 'Offline' },
-];
-
const formatPorts = (ports: Resource['docker'] extends infer T ? T : never): string => {
const entries =
(
@@ -97,25 +90,17 @@ export const DockerServicesTable: Component<{
>
<div class="space-y-3">
<Show when={props.showToolbar !== false}>
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[200px] flex-1 sm:max-w-xs">
- <SearchInput
- value={search}
- onChange={setSearch}
- placeholder="Search Swarm services"
- />
- </div>
- <FilterButtonGroup
- options={STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={visible() !== total()} fallback={<>{total()} services</>}>
- {visible()} of {total()} services
- </Show>
- </span>
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder="Search Swarm services"
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={visible()}
+ total={total()}
+ rowNoun="services"
+ />
</Show>
<Show
diff --git a/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx
index a530c283c7..95fa5ce7cf 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx
@@ -1,6 +1,4 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
-import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
-import { SearchInput } from '@/components/shared/SearchInput';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
@@ -18,6 +16,8 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableToolbar,
PlatformTableEmptyState,
filterPlatformResources,
getPlatformTableCellClass,
@@ -36,13 +36,6 @@ import type { Resource } from '@/types/resource';
// CPU/Memory utilisation. It reuses the same shared primitives every
// other platform-page table uses.
-const STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
- { value: 'all', label: 'All' },
- { value: 'online', label: 'Healthy' },
- { value: 'degraded', label: 'Degraded' },
- { value: 'offline', label: 'Offline' },
-];
-
const formatPercent = (percent?: number): JSX.Element => {
if (typeof percent !== 'number' || Number.isNaN(percent))
return <span class="text-muted">—</span>;
@@ -118,21 +111,17 @@ export const KubernetesClustersTable: Component<{
>
<div class="space-y-3">
<Show when={props.showToolbar !== false}>
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[200px] flex-1 sm:max-w-xs">
- <SearchInput value={search} onChange={setSearch} placeholder="Search clusters" />
- </div>
- <FilterButtonGroup
- options={STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={visible() !== total()} fallback={<>{total()} clusters</>}>
- {visible()} of {total()} clusters
- </Show>
- </span>
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder="Search clusters"
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={visible()}
+ total={total()}
+ rowNoun="clusters"
+ />
</Show>
<Show
diff --git a/frontend-modern/src/features/kubernetes/KubernetesDeploymentsTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesDeploymentsTable.tsx
index 0e546b4f66..b36c77661f 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesDeploymentsTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesDeploymentsTable.tsx
@@ -1,6 +1,4 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
-import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
-import { SearchInput } from '@/components/shared/SearchInput';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
@@ -18,6 +16,8 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableToolbar,
PlatformTableEmptyState,
filterPlatformResources,
getPlatformTableCellClass,
@@ -34,13 +34,6 @@ import type { Resource } from '@/types/resource';
// surfaces deployment-meaningful columns only: namespace, cluster,
// desired / updated / ready / available replicas.
-const STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
- { value: 'all', label: 'All' },
- { value: 'online', label: 'Healthy' },
- { value: 'degraded', label: 'Degraded' },
- { value: 'offline', label: 'Offline' },
-];
-
const replicaCount = (value: number | undefined): JSX.Element => (
<span class="tabular-nums">{value ?? 0}</span>
);
@@ -73,21 +66,17 @@ export const KubernetesDeploymentsTable: Component<{
>
<div class="space-y-3">
<Show when={props.showToolbar !== false}>
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[200px] flex-1 sm:max-w-xs">
- <SearchInput value={search} onChange={setSearch} placeholder="Search deployments" />
- </div>
- <FilterButtonGroup
- options={STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={visible() !== total()} fallback={<>{total()} deployments</>}>
- {visible()} of {total()} deployments
- </Show>
- </span>
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder="Search deployments"
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={visible()}
+ total={total()}
+ rowNoun="deployments"
+ />
</Show>
<Show
diff --git a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
index a44459b26c..5fc9bc79c5 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
@@ -1,6 +1,4 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
-import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
-import { SearchInput } from '@/components/shared/SearchInput';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
@@ -18,6 +16,8 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableToolbar,
PlatformTableEmptyState,
filterPlatformResources,
getPlatformTableCellClass,
@@ -36,13 +36,6 @@ import type { Resource } from '@/types/resource';
// primitives and surfaces the Kubelet-native columns alongside the
// usual CPU/Memory utilisation.
-const STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
- { value: 'all', label: 'All' },
- { value: 'online', label: 'Healthy' },
- { value: 'degraded', label: 'Degraded' },
- { value: 'offline', label: 'Offline' },
-];
-
const formatPercent = (percent?: number): JSX.Element => {
if (typeof percent !== 'number' || Number.isNaN(percent))
return <span class="text-muted">—</span>;
@@ -104,21 +97,17 @@ export const KubernetesNodesTable: Component<{
>
<div class="space-y-3">
<Show when={props.showToolbar !== false}>
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[200px] flex-1 sm:max-w-xs">
- <SearchInput value={search} onChange={setSearch} placeholder="Search nodes" />
- </div>
- <FilterButtonGroup
- options={STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={visible() !== total()} fallback={<>{total()} nodes</>}>
- {visible()} of {total()} nodes
- </Show>
- </span>
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder="Search nodes"
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={visible()}
+ total={total()}
+ rowNoun="nodes"
+ />
</Show>
<Show
diff --git a/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts b/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts
index 744f5c987b..c66c5a741c 100644
--- a/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts
@@ -29,6 +29,18 @@ const platformTableSources = [
vsphereDatastoresTableSource,
];
+const platformToolbarTableSources = [
+ dockerHostsTableSource,
+ dockerServicesTableSource,
+ kubernetesClustersTableSource,
+ kubernetesNodesTableSource,
+ kubernetesDeploymentsTableSource,
+ truenasSystemsTableSource,
+ truenasDisksTableSource,
+ vsphereHostsTableSource,
+ vsphereDatastoresTableSource,
+];
+
const overviewSurfaceSources = [
proxmoxPageSurfaceSource,
dockerPageSurfaceSource,
@@ -44,6 +56,8 @@ describe('platform overview layout guardrails', () => {
expect(sharedPlatformPageSource).toContain('PLATFORM_TABLE_BODY_CLASS');
expect(sharedPlatformPageSource).toContain('getPlatformTableHeadClass');
expect(sharedPlatformPageSource).toContain('getPlatformTableCellClass');
+ expect(sharedPlatformPageSource).toContain('PlatformTableToolbar');
+ expect(sharedPlatformPageSource).toContain('PLATFORM_HEALTH_FILTER_OPTIONS');
for (const source of platformTableSources) {
expect(source).toContain('TableCard');
@@ -54,6 +68,13 @@ describe('platform overview layout guardrails', () => {
expect(source).toContain('getPlatformTableHeadClass');
expect(source).toContain('getPlatformTableCellClass');
}
+
+ for (const source of platformToolbarTableSources) {
+ expect(source).toContain('PlatformTableToolbar');
+ expect(source).toContain('PLATFORM_HEALTH_FILTER_OPTIONS');
+ expect(source).not.toContain("from '@/components/shared/SearchInput'");
+ expect(source).not.toContain("from '@/components/shared/FilterButtonGroup'");
+ }
});
it('keeps provider overview pages in the parent-table plus child-inventory stack', () => {
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index 460b400b7f..d596834c7d 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -109,13 +109,20 @@ export function PlatformErrorState(props: {
// 'running' vs 'online', 'stopped' vs 'offline') collapse to one chip set.
export type PlatformResourceStatusFilter = 'all' | 'online' | 'degraded' | 'offline';
-const PLATFORM_STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
+export const PLATFORM_STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
{ value: 'all', label: 'All' },
{ value: 'online', label: 'Online' },
{ value: 'degraded', label: 'Degraded' },
{ value: 'offline', label: 'Offline' },
];
+export const PLATFORM_HEALTH_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
+ { value: 'all', label: 'All' },
+ { value: 'online', label: 'Healthy' },
+ { value: 'degraded', label: 'Degraded' },
+ { value: 'offline', label: 'Offline' },
+];
+
const ONLINE_STATUSES = new Set<ResourceStatus>(['online', 'running']);
const OFFLINE_STATUSES = new Set<ResourceStatus>(['offline', 'stopped']);
const DEGRADED_STATUSES = new Set<ResourceStatus>(['degraded', 'paused']);
@@ -167,14 +174,57 @@ export const filterPlatformResources = (
// 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.
-const PlatformResourceCounter: Component<{ visible: number; total: number }> = (props) => (
+const PlatformResourceCounter: Component<{ visible: number; total: number; rowNoun: string }> = (
+ props,
+) => (
<span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={props.visible !== props.total} fallback={<>{props.total} rows</>}>
- {props.visible} of {props.total} rows
+ <Show
+ when={props.visible !== props.total}
+ fallback={
+ <>
+ {props.total} {props.rowNoun}
+ </>
+ }
+ >
+ {props.visible} of {props.total} {props.rowNoun}
</Show>
</span>
);
+export function PlatformTableToolbar<T extends string | number>(props: {
+ search: () => string;
+ onSearchChange: (value: string) => void;
+ searchPlaceholder: string;
+ status: T;
+ onStatusChange: (value: T) => void;
+ statusOptions: FilterOption<T>[];
+ visible: number;
+ total: number;
+ rowNoun: string;
+}) {
+ return (
+ <div class="flex flex-wrap items-center gap-2">
+ <div class="min-w-[200px] flex-1 sm:max-w-xs">
+ <SearchInput
+ value={props.search}
+ onChange={props.onSearchChange}
+ placeholder={props.searchPlaceholder}
+ />
+ </div>
+ <FilterButtonGroup
+ options={props.statusOptions}
+ value={props.status}
+ onChange={props.onStatusChange}
+ />
+ <PlatformResourceCounter
+ visible={props.visible}
+ total={props.total}
+ rowNoun={props.rowNoun}
+ />
+ </div>
+ );
+}
+
export const PlatformResourceTable: Component<{
resources: Resource[];
emptyIcon: JSX.Element;
@@ -206,21 +256,17 @@ export const PlatformResourceTable: Component<{
}
>
<div class="space-y-3">
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[180px] flex-1 sm:max-w-xs">
- <SearchInput
- value={search}
- onChange={setSearch}
- placeholder={props.searchPlaceholder ?? 'Search rows'}
- />
- </div>
- <FilterButtonGroup
- options={PLATFORM_STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <PlatformResourceCounter visible={visibleCount()} total={totalCount()} />
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder={props.searchPlaceholder ?? 'Search rows'}
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_STATUS_FILTER_OPTIONS}
+ visible={visibleCount()}
+ total={totalCount()}
+ rowNoun="rows"
+ />
<Show
when={filteredResources().length > 0}
fallback={
diff --git a/frontend-modern/src/features/truenas/TrueNASDisksTable.tsx b/frontend-modern/src/features/truenas/TrueNASDisksTable.tsx
index eb405a346b..6f2c919080 100644
--- a/frontend-modern/src/features/truenas/TrueNASDisksTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASDisksTable.tsx
@@ -1,6 +1,4 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
-import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
-import { SearchInput } from '@/components/shared/SearchInput';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
@@ -17,6 +15,8 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableToolbar,
PlatformTableEmptyState,
filterPlatformResources,
getPlatformTableCellClass,
@@ -32,13 +32,6 @@ import type { Resource } from '@/types/resource';
// This bespoke table surfaces those from the canonical `physicalDisk`
// payload already attached to each row.
-const STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
- { value: 'all', label: 'All' },
- { value: 'online', label: 'Healthy' },
- { value: 'degraded', label: 'Degraded' },
- { value: 'offline', label: 'Offline' },
-];
-
const formatBytes = (bytes: number | undefined): string => {
if (!bytes || bytes <= 0) return '—';
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
@@ -99,21 +92,17 @@ export const TrueNASDisksTable: Component<{
>
<div class="space-y-3">
<Show when={props.showToolbar !== false}>
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[200px] flex-1 sm:max-w-xs">
- <SearchInput value={search} onChange={setSearch} placeholder="Search disks" />
- </div>
- <FilterButtonGroup
- options={STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={visible() !== total()} fallback={<>{total()} disks</>}>
- {visible()} of {total()} disks
- </Show>
- </span>
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder="Search disks"
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={visible()}
+ total={total()}
+ rowNoun="disks"
+ />
</Show>
<Show
diff --git a/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx b/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx
index de8a134974..1be500b168 100644
--- a/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx
@@ -1,6 +1,4 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
-import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
-import { SearchInput } from '@/components/shared/SearchInput';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
@@ -18,6 +16,8 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableToolbar,
PlatformTableEmptyState,
filterPlatformResources,
getPlatformTableCellClass,
@@ -36,13 +36,6 @@ import type { Resource } from '@/types/resource';
// client-side from the same TrueNAS resource scope already fetched by
// the page (no extra API calls).
-const STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
- { value: 'all', label: 'All' },
- { value: 'online', label: 'Healthy' },
- { value: 'degraded', label: 'Degraded' },
- { value: 'offline', label: 'Offline' },
-];
-
const formatUptime = (seconds: number | undefined): string => {
if (!seconds || seconds <= 0) return '—';
const days = Math.floor(seconds / 86_400);
@@ -123,25 +116,17 @@ export const TrueNASSystemsTable: Component<{
>
<div class="space-y-3">
<Show when={props.showToolbar !== false}>
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[200px] flex-1 sm:max-w-xs">
- <SearchInput
- value={search}
- onChange={setSearch}
- placeholder="Search TrueNAS systems"
- />
- </div>
- <FilterButtonGroup
- options={STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={visible() !== total()} fallback={<>{total()} systems</>}>
- {visible()} of {total()} systems
- </Show>
- </span>
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder="Search TrueNAS systems"
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={visible()}
+ total={total()}
+ rowNoun="systems"
+ />
</Show>
<Show
diff --git a/frontend-modern/src/features/vmware/VsphereDatastoresTable.tsx b/frontend-modern/src/features/vmware/VsphereDatastoresTable.tsx
index 5a3385e184..1f1efbc85e 100644
--- a/frontend-modern/src/features/vmware/VsphereDatastoresTable.tsx
+++ b/frontend-modern/src/features/vmware/VsphereDatastoresTable.tsx
@@ -1,6 +1,4 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
-import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
-import { SearchInput } from '@/components/shared/SearchInput';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
@@ -19,6 +17,8 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableToolbar,
PlatformTableEmptyState,
getPlatformTableCellClass,
getPlatformTableHeadClass,
@@ -38,13 +38,6 @@ import type { Resource } from '@/types/resource';
type DatastoreStatusFilter = 'all' | 'online' | 'degraded' | 'offline';
-const STATUS_FILTER_OPTIONS: FilterOption<DatastoreStatusFilter>[] = [
- { value: 'all', label: 'All' },
- { value: 'online', label: 'Online' },
- { value: 'degraded', label: 'Degraded' },
- { value: 'offline', label: 'Offline' },
-];
-
function indicatorFor(resource: Resource): {
variant: StatusIndicatorVariant;
label: string;
@@ -183,25 +176,17 @@ export const VsphereDatastoresTable: Component<{
>
<div class="space-y-3">
<Show when={props.showToolbar !== false}>
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[200px] flex-1 sm:max-w-xs">
- <SearchInput
- value={search}
- onChange={setSearch}
- placeholder="Search datastores, datacenters, hosts"
- />
- </div>
- <FilterButtonGroup
- options={STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={visible() !== total()} fallback={<>{total()} datastores</>}>
- {visible()} of {total()} datastores
- </Show>
- </span>
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder="Search datastores, datacenters, hosts"
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={visible()}
+ total={total()}
+ rowNoun="datastores"
+ />
</Show>
<Show
diff --git a/frontend-modern/src/features/vmware/VsphereHostsTable.tsx b/frontend-modern/src/features/vmware/VsphereHostsTable.tsx
index dd355faf27..e9e429a2cc 100644
--- a/frontend-modern/src/features/vmware/VsphereHostsTable.tsx
+++ b/frontend-modern/src/features/vmware/VsphereHostsTable.tsx
@@ -1,6 +1,4 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
-import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
-import { SearchInput } from '@/components/shared/SearchInput';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
@@ -18,6 +16,8 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableToolbar,
PlatformTableEmptyState,
filterPlatformResources,
getPlatformTableCellClass,
@@ -36,13 +36,6 @@ import type { Resource } from '@/types/resource';
// those ESXi-native columns. Per-host VM count is computed from the
// page scope client-side (no extra API calls).
-const STATUS_FILTER_OPTIONS: FilterOption<PlatformResourceStatusFilter>[] = [
- { value: 'all', label: 'All' },
- { value: 'online', label: 'Healthy' },
- { value: 'degraded', label: 'Degraded' },
- { value: 'offline', label: 'Offline' },
-];
-
const formatPercent = (percent?: number): JSX.Element => {
if (typeof percent !== 'number' || Number.isNaN(percent))
return <span class="text-muted">—</span>;
@@ -110,21 +103,17 @@ export const VsphereHostsTable: Component<{
>
<div class="space-y-3">
<Show when={props.showToolbar !== false}>
- <div class="flex flex-wrap items-center gap-2">
- <div class="min-w-[200px] flex-1 sm:max-w-xs">
- <SearchInput value={search} onChange={setSearch} placeholder="Search ESXi hosts" />
- </div>
- <FilterButtonGroup
- options={STATUS_FILTER_OPTIONS}
- value={status()}
- onChange={setStatus}
- />
- <span class="ml-auto whitespace-nowrap text-xs font-medium text-muted">
- <Show when={visible() !== total()} fallback={<>{total()} hosts</>}>
- {visible()} of {total()} hosts
- </Show>
- </span>
- </div>
+ <PlatformTableToolbar
+ search={search}
+ onSearchChange={setSearch}
+ searchPlaceholder="Search ESXi hosts"
+ status={status()}
+ onStatusChange={setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={visible()}
+ total={total()}
+ rowNoun="hosts"
+ />
</Show>
<Show