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.

Normalize platform loading states

rcourtmanb94c6164d729
diff --git a/frontend-modern/src/features/docker/DockerPageSurface.tsx b/frontend-modern/src/features/docker/DockerPageSurface.tsx
index e57f287665..b8f229202d 100644
--- a/frontend-modern/src/features/docker/DockerPageSurface.tsx
+++ b/frontend-modern/src/features/docker/DockerPageSurface.tsx
@@ -9,6 +9,7 @@ import {
PlatformErrorState,
PlatformSectionTabs,
PlatformTableEmptyState,
+ PlatformTableLoadingState,
} from '@/features/platformPage/sharedPlatformPage';
import { DockerHostsTable } from './DockerHostsTable';
import { DockerServicesTable } from './DockerServicesTable';
@@ -92,17 +93,12 @@ export function DockerPageSurface() {
return (
<div data-testid="docker-page" class="space-y-3">
- <PlatformSectionTabs
- tabs={DOCKER_TAB_SPECS}
- active="overview"
- ariaLabel="Docker sections"
- />
+ <PlatformSectionTabs tabs={DOCKER_TAB_SPECS} active="overview" ariaLabel="Docker sections" />
<Show
when={!loading() || model().resources.length > 0}
fallback={
- <PlatformTableEmptyState
- icon={dockerIcon()}
+ <PlatformTableLoadingState
title="Loading Docker resources"
description="Pulse is loading the Docker / Podman resource snapshot."
/>
diff --git a/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx b/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
index 5afddb3e1b..06c5304734 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
@@ -10,6 +10,7 @@ import {
PlatformErrorState,
PlatformSectionTabs,
PlatformTableEmptyState,
+ PlatformTableLoadingState,
} from '@/features/platformPage/sharedPlatformPage';
import { KubernetesClustersTable } from './KubernetesClustersTable';
import { KubernetesDeploymentsTable } from './KubernetesDeploymentsTable';
@@ -56,8 +57,7 @@ export function KubernetesPageSurface() {
<Show
when={!loading() || model().resources.length > 0}
fallback={
- <PlatformTableEmptyState
- icon={k8sIcon()}
+ <PlatformTableLoadingState
title="Loading Kubernetes resources"
description="Pulse is loading the Kubernetes resource snapshot."
/>
@@ -128,9 +128,9 @@ function KubernetesOverview(props: KubernetesOverviewProps) {
});
const filteredDeployments = createMemo(() => {
if (!searchTerm()) return props.model().deployments;
- return props.model().deployments.filter((deployment) =>
- resourceMatchesSearch(deployment, searchTerm()),
- );
+ return props
+ .model()
+ .deployments.filter((deployment) => resourceMatchesSearch(deployment, searchTerm()));
});
return (
@@ -166,8 +166,7 @@ function KubernetesOverview(props: KubernetesOverviewProps) {
forcedPlatform={KUBERNETES_PLATFORM_FILTER}
pinnedSelectionActive={() =>
Boolean(
- workloadsState.selectedGuestId() ||
- workloadsState.focusedSummaryWorkloadGroupId(),
+ workloadsState.selectedGuestId() || workloadsState.focusedSummaryWorkloadGroupId(),
)
}
onClearPinnedSelection={workloadsState.clearPinnedSummaryScope}
diff --git a/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx b/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx
index 16535c87ce..bab1b33360 100644
--- a/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx
+++ b/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx
@@ -1,10 +1,12 @@
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@solidjs/testing-library';
+import { Route, Router } from '@solidjs/router';
import type { WorkloadsSurfaceProps } from '@/components/Workloads/WorkloadsSurface';
import { KubernetesPageSurface } from '../KubernetesPageSurface';
const mockUseUnifiedResources = vi.fn();
+const mockUseWorkloadsState = vi.fn();
const mockWorkloadsSurface = vi.fn((props: WorkloadsSurfaceProps) => (
<div
data-testid="kubernetes-workloads-surface"
@@ -20,6 +22,10 @@ vi.mock('@/hooks/useUnifiedResources', () => ({
useUnifiedResources: (...args: unknown[]) => mockUseUnifiedResources(...args),
}));
+vi.mock('@/components/Workloads/useWorkloadsState', () => ({
+ useWorkloadsState: (...args: unknown[]) => mockUseWorkloadsState(...args),
+}));
+
vi.mock('@/components/Workloads/WorkloadsSurface', () => ({
WorkloadsSurface: (props: WorkloadsSurfaceProps) => mockWorkloadsSurface(props),
}));
@@ -28,6 +34,7 @@ vi.mock('@/features/platformPage/sharedPlatformPage', () => ({
PlatformErrorState: () => <div data-testid="platform-error-state" />,
PlatformSectionTabs: () => <div data-testid="platform-section-tabs" />,
PlatformTableEmptyState: () => <div data-testid="platform-table-empty-state" />,
+ PlatformTableLoadingState: () => <div data-testid="platform-table-loading-state" />,
}));
vi.mock('../KubernetesClustersTable', () => ({
@@ -63,8 +70,37 @@ describe('KubernetesPageSurface contract', () => {
error: () => null,
refetch: vi.fn(),
});
+ mockUseWorkloadsState.mockReturnValue({
+ allGuests: () => [],
+ clearPinnedSummaryScope: vi.fn(),
+ containerRuntimeFilterConfig: () => undefined,
+ focusedSummaryWorkloadGroupId: () => null,
+ groupingMode: () => 'grouped',
+ handleBeforeAutoFocus: vi.fn(),
+ search: () => '',
+ selectedGuestId: () => null,
+ setGroupingMode: vi.fn(),
+ setMetricDisplayMode: vi.fn(),
+ setSearch: vi.fn(),
+ setSortDirection: vi.fn(),
+ setSortKey: vi.fn(),
+ setStatusMode: vi.fn(),
+ setViewMode: vi.fn(),
+ setWorkloadMetricHistoryRange: vi.fn(),
+ statusMode: () => 'all',
+ surfaceConnected: () => false,
+ surfaceInitialDataReceived: () => false,
+ viewMode: () => 'pod',
+ workloadMetricDisplayMode: () => 'bars',
+ workloadMetricHistoryRange: () => '1h',
+ workloadsFilterColumnVisibility: () => undefined,
+ });
- render(() => <KubernetesPageSurface />);
+ render(() => (
+ <Router>
+ <Route path="/" component={KubernetesPageSurface} />
+ </Router>
+ ));
expect(screen.getByTestId('kubernetes-workloads-surface')).toHaveAttribute(
'data-forced-platform',
@@ -74,17 +110,13 @@ describe('KubernetesPageSurface contract', () => {
'data-forced-view-mode',
'pod',
);
- expect(screen.getByTestId('kubernetes-workloads-surface')).toHaveAttribute(
- 'data-column-scope',
- 'kubernetes-pods',
- );
- expect(screen.getByTestId('kubernetes-workloads-surface')).toHaveAttribute(
- 'data-allow-scope-filters',
- 'true',
- );
- expect(screen.getByTestId('kubernetes-workloads-surface')).toHaveAttribute(
- 'data-filter-placeholder',
- 'Search pods by name, namespace, image, cluster, or node',
+ expect(mockUseWorkloadsState).toHaveBeenCalledWith(
+ expect.objectContaining({
+ allowEmbeddedScopeFilters: true,
+ columnVisibilityStorageScope: 'kubernetes-pods',
+ forcedPlatform: 'kubernetes',
+ forcedViewMode: 'pod',
+ }),
);
});
});
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 f6a1e8b25e..47a8077e93 100644
--- a/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts
@@ -60,6 +60,7 @@ describe('platform overview layout guardrails', () => {
expect(sharedPlatformPageSource).toContain('getPlatformTableHeadClass');
expect(sharedPlatformPageSource).toContain('getPlatformTableCellClass');
expect(sharedPlatformPageSource).toContain('PlatformTableToolbar');
+ expect(sharedPlatformPageSource).toContain('PlatformTableLoadingState');
expect(sharedPlatformPageSource).toContain('createPlatformTableFilterState');
expect(sharedPlatformPageSource).toContain('PLATFORM_HEALTH_FILTER_OPTIONS');
@@ -103,6 +104,7 @@ describe('platform overview layout guardrails', () => {
for (const source of overviewSurfaceSources) {
expect(source).toContain('<div class="space-y-4">');
expect(source).toContain('<PlatformSectionTabs');
+ expect(source).toContain('<PlatformTableLoadingState');
expect(source).toContain('PlatformTableEmptyState');
expect(source).toContain('PlatformErrorState');
}
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index 5cae45c912..39c3ddf544 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -7,10 +7,7 @@ import { SearchInput } from '@/components/shared/SearchInput';
import { TableCard } from '@/components/shared/TableCard';
import { UnifiedResourceTable } from '@/components/Infrastructure/UnifiedResourceTable';
import type { Resource, ResourceStatus } from '@/types/resource';
-import {
- getPlatformColumnAlign,
- type PlatformTableColumnKind,
-} from './columnAlignment';
+import { getPlatformColumnAlign, type PlatformTableColumnKind } from './columnAlignment';
export type PlatformTabSpec<TabId extends string> = {
id: TabId;
@@ -61,6 +58,17 @@ export function PlatformTableEmptyState(props: {
);
}
+export function PlatformTableLoadingState(props: { title: string; description: string }) {
+ return (
+ <TableCard>
+ <div class="px-3 py-2 text-xs text-muted" role="status">
+ <span class="font-medium text-base-content">{props.title}</span>{' '}
+ <span class="ml-2">{props.description}</span>
+ </div>
+ </TableCard>
+ );
+}
+
export type PlatformTableCellAlign = 'left' | 'right' | 'center';
export const PLATFORM_TABLE_CARD_CLASS = 'rounded-md';
diff --git a/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx b/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
index cd38436ddb..24e31283a8 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
@@ -22,6 +22,7 @@ import {
PlatformErrorState,
PlatformSectionTabs,
PlatformTableEmptyState,
+ PlatformTableLoadingState,
} from '@/features/platformPage/sharedPlatformPage';
import { ProxmoxBackupsTable } from './ProxmoxBackupsTable';
import { ProxmoxCephTable } from './ProxmoxCephTable';
@@ -108,8 +109,7 @@ export function ProxmoxPageSurface() {
<Show
when={!loading() || model().resources.length > 0}
fallback={
- <PlatformTableEmptyState
- icon={proxmoxIcon()}
+ <PlatformTableLoadingState
title="Loading Proxmox resources"
description="Pulse is loading the Proxmox resource snapshot."
/>
@@ -259,8 +259,7 @@ function ProxmoxOverview(props: ProxmoxOverviewProps) {
forcedPlatform={PROXMOX_PLATFORM_FILTER}
pinnedSelectionActive={() =>
Boolean(
- workloadsState.selectedGuestId() ||
- workloadsState.focusedSummaryWorkloadGroupId(),
+ workloadsState.selectedGuestId() || workloadsState.focusedSummaryWorkloadGroupId(),
)
}
onClearPinnedSelection={workloadsState.clearPinnedSummaryScope}
diff --git a/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx b/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx
index 887960da50..91c8ed5395 100644
--- a/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx
@@ -12,6 +12,7 @@ import {
PlatformErrorState,
PlatformSectionTabs,
PlatformTableEmptyState,
+ PlatformTableLoadingState,
} from '@/features/platformPage/sharedPlatformPage';
import { TrueNASSystemsTable } from './TrueNASSystemsTable';
import {
@@ -62,8 +63,7 @@ export function TrueNASPageSurface() {
<Show
when={!loading() || model().resources.length > 0}
fallback={
- <PlatformTableEmptyState
- icon={truenasIcon()}
+ <PlatformTableLoadingState
title="Loading TrueNAS resources"
description="Pulse is loading the TrueNAS resource snapshot."
/>
@@ -175,8 +175,7 @@ function TrueNASOverview(props: TrueNASOverviewProps) {
forcedPlatform={TRUENAS_PLATFORM_FILTER}
pinnedSelectionActive={() =>
Boolean(
- workloadsState.selectedGuestId() ||
- workloadsState.focusedSummaryWorkloadGroupId(),
+ workloadsState.selectedGuestId() || workloadsState.focusedSummaryWorkloadGroupId(),
)
}
onClearPinnedSelection={workloadsState.clearPinnedSummaryScope}
diff --git a/frontend-modern/src/features/vmware/VmwarePageSurface.tsx b/frontend-modern/src/features/vmware/VmwarePageSurface.tsx
index 1ef7618f7f..93ac8b2005 100644
--- a/frontend-modern/src/features/vmware/VmwarePageSurface.tsx
+++ b/frontend-modern/src/features/vmware/VmwarePageSurface.tsx
@@ -12,6 +12,7 @@ import {
PlatformErrorState,
PlatformSectionTabs,
PlatformTableEmptyState,
+ PlatformTableLoadingState,
} from '@/features/platformPage/sharedPlatformPage';
import { VsphereHostsTable } from './VsphereHostsTable';
import {
@@ -60,8 +61,7 @@ export function VmwarePageSurface() {
<Show
when={!loading() || model().resources.length > 0}
fallback={
- <PlatformTableEmptyState
- icon={vmwareIcon()}
+ <PlatformTableLoadingState
title="Loading VMware resources"
description="Pulse is loading the VMware vSphere resource snapshot."
/>
@@ -172,8 +172,7 @@ function VmwareOverview(props: VmwareOverviewProps) {
forcedPlatform={VMWARE_PLATFORM_FILTER}
pinnedSelectionActive={() =>
Boolean(
- workloadsState.selectedGuestId() ||
- workloadsState.focusedSummaryWorkloadGroupId(),
+ workloadsState.selectedGuestId() || workloadsState.focusedSummaryWorkloadGroupId(),
)
}
onClearPinnedSelection={workloadsState.clearPinnedSummaryScope}