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.

refactor(proxmox): extract Restore-points table into ProxmoxRecoverableTable

rcourtman77fe1a210d7b
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
index 3b5f7ca183..55d2400878 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
@@ -121,8 +121,10 @@ import {
SNAPSHOT_FILTERS,
SortableHead,
TASK_STATUS_FILTERS,
+ artifactStateLabel,
} from './proxmoxBackupsTableShared';
import { ProxmoxBackupsCoverageStrip } from './ProxmoxBackupsCoverageStrip';
+import { ProxmoxRecoverableTable } from './ProxmoxRecoverableTable';
// Proxmox backups are intentionally organized around operator questions, not
// storage-source mechanics:
@@ -514,14 +516,6 @@ export const ProxmoxBackupsTable: Component<{
),
);
- const artifactStateLabel = (artifact: RecoverableArtifact): string => {
- if (artifact.sourceKind === 'snapshot') return 'Snapshot';
- if (artifact.protected) return 'Protected';
- if (artifact.verified === true) return 'Verified';
- if (artifact.verified === false) return 'Unverified';
- return 'Archive';
- };
-
const coveragePostureVariant = (
posture: WorkloadCoverageRow['posture'],
): StatusIndicatorVariant => {
@@ -1846,167 +1840,17 @@ export const ProxmoxBackupsTable: Component<{
</Show>
<Show when={tab() === 'recoverable'}>
- <Show
- when={filteredRecoverableArtifacts().length > 0}
- fallback={
- <Card padding="lg">
- <EmptyState
- icon={props.emptyIcon}
- title={
- recoveryModel().recoverableArtifacts.length === 0
- ? tabSpecFor('recoverable').emptyTitle
- : 'No recoverable artifacts match current filters'
- }
- description={
- recoveryModel().recoverableArtifacts.length === 0
- ? tabSpecFor('recoverable').emptyDescription
- : 'Adjust the search, source filter, or selected day to see more artifacts.'
- }
- />
- </Card>
- }
- >
- <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
- <Table class="min-w-[1150px] text-xs">
- <TableHeader>
- <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
- <SortableHead
- label="Workload"
- sortKey="workload"
- currentSort={recoverableSortKey}
- direction={recoverableSortDirection}
- onSort={handleRecoverableSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('name')}
- />
- <SortableHead
- label="Source"
- sortKey="source"
- currentSort={recoverableSortKey}
- direction={recoverableSortDirection}
- onSort={handleRecoverableSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Location"
- sortKey="location"
- currentSort={recoverableSortKey}
- direction={recoverableSortDirection}
- onSort={handleRecoverableSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Created"
- sortKey="created"
- currentSort={recoverableSortKey}
- direction={recoverableSortDirection}
- onSort={handleRecoverableSort}
- align="right"
- headClass={getPlatformTableHeadClassForKind('numeric-value')}
- />
- <SortableHead
- label="Size"
- sortKey="size"
- currentSort={recoverableSortKey}
- direction={recoverableSortDirection}
- onSort={handleRecoverableSort}
- align="center"
- headClass={getPlatformTableHeadClassForKind('metric-bar')}
- />
- <SortableHead
- label="State"
- sortKey="state"
- currentSort={recoverableSortKey}
- direction={recoverableSortDirection}
- onSort={handleRecoverableSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <TableHead class={getPlatformTableHeadClassForKind('text')}>
- Details
- </TableHead>
- </TableRow>
- </TableHeader>
- <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
- <For each={filteredRecoverableArtifacts()}>
- {(artifact) => (
- <TableRow class="hover:bg-surface-hover">
- <TableCell
- class={`${getPlatformTableCellClassForKind('name')} text-base-content`}
- >
- <div class="min-w-0">
- <div class="font-semibold">{artifact.workload.label}</div>
- <div class="font-mono text-[10px] uppercase text-muted">
- {artifact.workload.typeLabel} {artifact.workload.vmid}
- </div>
- </div>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <ArtifactSourceBadge artifact={artifact} />
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <span
- class="inline-block max-w-[16rem] truncate"
- title={artifact.location}
- >
- {artifact.location}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
- >
- {formatRelativeTime(artifact.createdAt, { compact: true })}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('metric-bar')} text-base-content`}
- >
- <Show
- when={artifact.size && artifact.size > 0}
- fallback={<span class="text-muted">No size</span>}
- >
- <RowMetricBar
- valuePct={
- recoverableSizeMaxBytes() > 0 && artifact.size
- ? (artifact.size / recoverableSizeMaxBytes()) * 100
- : 0
- }
- fillClass="bg-blue-500/40 dark:bg-blue-500/40"
- label={formatBytes(artifact.size ?? 0)}
- tooltip={`${formatBytes(artifact.size ?? 0)} (relative to largest artifact in view)`}
- />
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <ArtifactStateBadge
- artifact={artifact}
- label={artifactStateLabel(artifact)}
- />
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <span
- class="inline-block max-w-[20rem] truncate"
- title={artifact.detail}
- >
- {artifact.detail || '—'}
- </span>
- </TableCell>
- </TableRow>
- )}
- </For>
- </TableBody>
- </Table>
- </TableCard>
- </Show>
+ <ProxmoxRecoverableTable
+ artifacts={filteredRecoverableArtifacts()}
+ hasAnyArtifacts={recoveryModel().recoverableArtifacts.length > 0}
+ emptyIcon={props.emptyIcon}
+ emptyTitle={tabSpecFor('recoverable').emptyTitle}
+ emptyDescription={tabSpecFor('recoverable').emptyDescription}
+ sortKey={recoverableSortKey}
+ sortDirection={recoverableSortDirection}
+ onSort={handleRecoverableSort}
+ sizeMaxBytes={recoverableSizeMaxBytes()}
+ />
</Show>
<Show when={tab() === 'sources' && sourceDetailTab() === 'pbs'}>
diff --git a/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
new file mode 100644
index 0000000000..abc3400050
--- /dev/null
+++ b/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
@@ -0,0 +1,199 @@
+import { For, Show, type Accessor, type JSX } from 'solid-js';
+
+import { Card } from '@/components/shared/Card';
+import { EmptyState } from '@/components/shared/EmptyState';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/shared/Table';
+import { TableCard } from '@/components/shared/TableCard';
+import { formatBytes, formatRelativeTime } from '@/utils/format';
+import {
+ PLATFORM_TABLE_BODY_CLASS,
+ PLATFORM_TABLE_CARD_CLASS,
+ PLATFORM_TABLE_HEADER_ROW_CLASS,
+ getPlatformTableCellClassForKind,
+ getPlatformTableHeadClassForKind,
+} from '@/features/platformPage/sharedPlatformPage';
+
+import type { RecoverableArtifact } from './proxmoxBackupRecoveryModel';
+import type { RecoverableSortKey } from './proxmoxBackupsTableModel';
+import {
+ ArtifactSourceBadge,
+ ArtifactStateBadge,
+ RowMetricBar,
+ SortableHead,
+ artifactStateLabel,
+} from './proxmoxBackupsTableShared';
+
+// "Restore points" table: every recoverable artifact (PBS / archive / snapshot)
+// across sources in one flat, sortable list. Presentational only — the parent
+// owns the filtered + sorted memo and the shared search / day / source filters.
+export function ProxmoxRecoverableTable(props: {
+ artifacts: RecoverableArtifact[];
+ hasAnyArtifacts: boolean;
+ emptyIcon: JSX.Element;
+ emptyTitle: string;
+ emptyDescription: string;
+ sortKey: Accessor<RecoverableSortKey>;
+ sortDirection: Accessor<'asc' | 'desc'>;
+ onSort: (key: RecoverableSortKey) => void;
+ sizeMaxBytes: number;
+}) {
+ return (
+ <Show
+ when={props.artifacts.length > 0}
+ fallback={
+ <Card padding="lg">
+ <EmptyState
+ icon={props.emptyIcon}
+ title={
+ !props.hasAnyArtifacts
+ ? props.emptyTitle
+ : 'No recoverable artifacts match current filters'
+ }
+ description={
+ !props.hasAnyArtifacts
+ ? props.emptyDescription
+ : 'Adjust the search, source filter, or selected day to see more artifacts.'
+ }
+ />
+ </Card>
+ }
+ >
+ <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
+ <Table class="min-w-[1150px] text-xs">
+ <TableHeader>
+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
+ <SortableHead
+ label="Workload"
+ sortKey="workload"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('name')}
+ />
+ <SortableHead
+ label="Source"
+ sortKey="source"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <SortableHead
+ label="Location"
+ sortKey="location"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <SortableHead
+ label="Created"
+ sortKey="created"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="right"
+ headClass={getPlatformTableHeadClassForKind('numeric-value')}
+ />
+ <SortableHead
+ label="Size"
+ sortKey="size"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="center"
+ headClass={getPlatformTableHeadClassForKind('metric-bar')}
+ />
+ <SortableHead
+ label="State"
+ sortKey="state"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <TableHead class={getPlatformTableHeadClassForKind('text')}>Details</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
+ <For each={props.artifacts}>
+ {(artifact) => (
+ <TableRow class="hover:bg-surface-hover">
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('name')} text-base-content`}
+ >
+ <div class="min-w-0">
+ <div class="font-semibold">{artifact.workload.label}</div>
+ <div class="font-mono text-[10px] uppercase text-muted">
+ {artifact.workload.typeLabel} {artifact.workload.vmid}
+ </div>
+ </div>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <ArtifactSourceBadge artifact={artifact} />
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span class="inline-block max-w-[16rem] truncate" title={artifact.location}>
+ {artifact.location}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
+ >
+ {formatRelativeTime(artifact.createdAt, { compact: true })}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('metric-bar')} text-base-content`}
+ >
+ <Show
+ when={artifact.size && artifact.size > 0}
+ fallback={<span class="text-muted">No size</span>}
+ >
+ <RowMetricBar
+ valuePct={
+ props.sizeMaxBytes > 0 && artifact.size
+ ? (artifact.size / props.sizeMaxBytes) * 100
+ : 0
+ }
+ fillClass="bg-blue-500/40 dark:bg-blue-500/40"
+ label={formatBytes(artifact.size ?? 0)}
+ tooltip={`${formatBytes(artifact.size ?? 0)} (relative to largest artifact in view)`}
+ />
+ </Show>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <ArtifactStateBadge artifact={artifact} label={artifactStateLabel(artifact)} />
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span class="inline-block max-w-[20rem] truncate" title={artifact.detail}>
+ {artifact.detail || '—'}
+ </span>
+ </TableCell>
+ </TableRow>
+ )}
+ </For>
+ </TableBody>
+ </Table>
+ </TableCard>
+ </Show>
+ );
+}
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
index c6f3cff2dd..38c9311e96 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
@@ -141,6 +141,16 @@ export function RecoverySourceSummary(props: {
);
}
+// Short state label for a recoverable artifact, paired with ArtifactStateBadge
+// for colour. Snapshot and protected take precedence over verification state.
+export function artifactStateLabel(artifact: RecoverableArtifact): string {
+ if (artifact.sourceKind === 'snapshot') return 'Snapshot';
+ if (artifact.protected) return 'Protected';
+ if (artifact.verified === true) return 'Verified';
+ if (artifact.verified === false) return 'Unverified';
+ return 'Archive';
+}
+
export function ArtifactStateBadge(props: { artifact: RecoverableArtifact; label: string }) {
if (props.artifact.sourceKind === 'snapshot') {
return (