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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Add sortable storage table headers
rcourtman1ce47e21a098
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex d01a4959a9..817b431f3f 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -242,6 +242,11 @@ Feature-owned table drawers use shared disclosure and inline-detail primitivesas local interaction state. Unless a surface has a separately governed deep-linkwrite contract, opening or closing a row drawer must preserve the currentdocument and URL instead of writing route state or reloading the page shell.+Feature-owned sortable table headers must render real button controls inside+the shared `TableHead` primitive and expose column state through `aria-sort`;+the feature owner may define the sort keys and data comparator, but the header+interaction must update that canonical owner state rather than forking+table-local sort state or making header labels look clickable while inert.Shared filter/search primitives may provide the common shell, keyboard behavior,history, and reset mechanics, but the owning page or table must supplydiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex b5eb266b00..c50bc3a983 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -230,6 +230,14 @@ bypass the API fail-closed execution gate.render the storage empty state instead of a synthetic empty "All" group.Subtabs (Pools / Physical Disks) sit above the bar as navigation, notfilters.+ Storage pool table header sorting is storage/recovery-owned and must bind+ visible pool columns to the canonical storage sort state instead of+ introducing platform-local or table-local sort state. Header clicks must+ update the same `sort` / `order` model as the toolbar select, expose+ `aria-sort` on the active column, and cover displayed pool columns+ including state, source, type, host, protection, usage, and growth. Growth+ sorting may consume summary delta data, but non-growth sorts must not track+ chart delta maps or re-render row order when chart data refreshes.Platform-page storage and recovery section tabsare still capability-gated navigation: Proxmox Storage,Backups, Ceph, Replication, and adjacent recovery sections may appear onlydiff --git a/frontend-modern/src/components/Storage/Storage.tsx b/frontend-modern/src/components/Storage/Storage.tsxindex adf9b10978..adde3d6be6 100644--- a/frontend-modern/src/components/Storage/Storage.tsx+++ b/frontend-modern/src/components/Storage/Storage.tsx@@ -235,6 +235,10 @@ const Storage: Component<StorageProps> = (props) => {search={search}groupedRecords={groupedRecords}groupBy={groupBy}+ sortKey={sortKey}+ setSortKey={setSortKey}+ sortDirection={sortDirection}+ setSortDirection={setSortDirection}expandedGroups={expandedGroups}toggleGroup={toggleGroup}expandedPoolId={expandedPoolId}diff --git a/frontend-modern/src/components/Storage/StorageContentCard.tsx b/frontend-modern/src/components/Storage/StorageContentCard.tsxindex 384a4c575c..3de0d0604e 100644--- a/frontend-modern/src/components/Storage/StorageContentCard.tsx+++ b/frontend-modern/src/components/Storage/StorageContentCard.tsx@@ -7,7 +7,7 @@ import { STORAGE_CONTENT_CARD_BODY_CLASS } from '@/features/storageBackups/storaimport type { StorageCapacityDeltaPresentation } from '@/features/storageBackups/storageCapacityDeltaPresentation';import type { Resource } from '@/types/resource';import type { StorageHealthFilter } from '@/features/storageBackups/models';-import type { StorageGroupKey, StorageGroupedRecords } from './useStorageModel';+import type { StorageGroupKey, StorageGroupedRecords, StorageSortKey } from './useStorageModel';import type { StorageAlertRowState } from '@/features/storageBackups/storageAlertState';import type { StorageView } from './storagePageState';import { useStorageContentCardModel } from './useStorageContentCardModel';@@ -25,6 +25,10 @@ type StorageContentCardProps = {search: () => string;groupedRecords: () => StorageGroupedRecords[];groupBy: () => StorageGroupKey;+ sortKey: () => StorageSortKey;+ setSortKey: (value: StorageSortKey) => void;+ sortDirection: () => 'asc' | 'desc';+ setSortDirection: (value: 'asc' | 'desc') => void;expandedGroups: () => Set<string>;toggleGroup: (key: string) => void;expandedPoolId: () => string | null;@@ -93,6 +97,10 @@ export const StorageContentCard: Component<StorageContentCardProps> = (props) =><StoragePoolsTablegroupedRecords={props.groupedRecords()}groupBy={props.groupBy()}+ sortKey={props.sortKey()}+ setSortKey={props.setSortKey}+ sortDirection={props.sortDirection()}+ setSortDirection={props.setSortDirection}expandedGroups={props.expandedGroups()}toggleGroup={props.toggleGroup}expandedPoolId={props.expandedPoolId()}diff --git a/frontend-modern/src/components/Storage/StoragePageControls.tsx b/frontend-modern/src/components/Storage/StoragePageControls.tsxindex 263d07a1cc..d393e7867e 100644--- a/frontend-modern/src/components/Storage/StoragePageControls.tsx+++ b/frontend-modern/src/components/Storage/StoragePageControls.tsx@@ -26,6 +26,7 @@ import {DEFAULT_STORAGE_SORT_OPTIONS,DEFAULT_STORAGE_SOURCE_FILTER,DEFAULT_STORAGE_STATUS_FILTER,+ getDefaultStorageSortDirection,hasActiveStorageFilters,normalizeStorageSortKey,STORAGE_GROUP_BY_OPTIONS,@@ -131,6 +132,15 @@ export const StoragePageControls: Component<StoragePageControlsProps> = (props)props.setSelectedNodeId(DEFAULT_STORAGE_SELECTED_NODE_ID);};+ const handleSortKeyChange = (value: string) => {+ const nextSortKey = normalizeStorageSortKey(value) as StorageSortKey;+ const previousSortKey = props.sortKey();+ props.setSortKey(nextSortKey);+ if (nextSortKey !== previousSortKey) {+ props.setSortDirection(getDefaultStorageSortDirection(nextSortKey));+ }+ };+const buildFilters = (): FilterDef[] => {const filters: FilterDef[] = [{@@ -286,11 +296,7 @@ export const StoragePageControls: Component<StoragePageControlsProps> = (props)<div class={STORAGE_FILTER_SORT_WRAP_CLASS}><selectvalue={props.sortKey()}- onChange={(event) =>- props.setSortKey(- normalizeStorageSortKey(event.currentTarget.value) as StorageSortKey,- )- }+ onChange={(event) => handleSortKeyChange(event.currentTarget.value)}disabled={sortDisabled()}aria-label="Sort by"class={STORAGE_FILTER_SORT_SELECT_CLASS}diff --git a/frontend-modern/src/components/Storage/StoragePoolsTable.tsx b/frontend-modern/src/components/Storage/StoragePoolsTable.tsxindex a3363a1b80..5ce0e48ba8 100644--- a/frontend-modern/src/components/Storage/StoragePoolsTable.tsx+++ b/frontend-modern/src/components/Storage/StoragePoolsTable.tsx@@ -1,4 +1,7 @@import { Component, For, Index, Show } from 'solid-js';+import ArrowDownIcon from 'lucide-solid/icons/arrow-down';+import ArrowUpIcon from 'lucide-solid/icons/arrow-up';+import ArrowUpDownIcon from 'lucide-solid/icons/arrow-up-down';import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/shared/Table';import {getStoragePoolTableColumns,@@ -16,7 +19,8 @@ import type { StorageAlertRowState } from '@/features/storageBackups/storageAlerimport type { Resource } from '@/types/resource';import { StorageGroupRow } from './StorageGroupRow';import { StoragePoolRow } from './StoragePoolRow';-import type { StorageGroupedRecords, StorageGroupKey } from './useStorageModel';+import { getDefaultStorageSortDirection } from './storagePageState';+import type { StorageGroupedRecords, StorageGroupKey, StorageSortKey } from './useStorageModel';import { useStoragePoolsTableModel } from './useStoragePoolsTableModel';import type { SummarySeriesGroupScope } from '@/components/shared/summaryCardInteraction';import { resolveSummaryGroupMemberInteractionState } from '@/components/shared/summaryCardInteraction';@@ -25,6 +29,10 @@ import { buildStorageSummaryGroupScope } from './storageSummaryGroups';type StoragePoolsTableProps = {groupedRecords: StorageGroupedRecords[];groupBy: StorageGroupKey;+ sortKey: StorageSortKey;+ setSortKey: (value: StorageSortKey) => void;+ sortDirection: 'asc' | 'desc';+ setSortDirection: (value: 'asc' | 'desc') => void;expandedGroups: Set<string>;toggleGroup: (key: string) => void;expandedPoolId: string | null;@@ -46,6 +54,30 @@ type StoragePoolsTableProps = {onHoverChange?: (recordId: string | null) => void;};+const STORAGE_POOL_HEADER_SORT_BUTTON_CLASS =+ 'inline-flex min-w-0 max-w-full items-center gap-1 rounded-sm text-left outline-none transition-colors hover:text-base-content focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1 focus-visible:ring-offset-surface';+const STORAGE_POOL_HEADER_SORT_ICON_CLASS = 'h-3 w-3 shrink-0';++const getNextStorageColumnSortDirection = (+ currentSortKey: StorageSortKey,+ currentSortDirection: 'asc' | 'desc',+ columnSortKey: StorageSortKey,+): 'asc' | 'desc' => {+ if (currentSortKey !== columnSortKey) {+ return getDefaultStorageSortDirection(columnSortKey);+ }+ return currentSortDirection === 'asc' ? 'desc' : 'asc';+};++const getStorageColumnSortButtonLabel = (+ label: string,+ isSorted: boolean,+ direction: 'asc' | 'desc',+): string => {+ if (!isSorted) return `Sort ${label} column`;+ return `Sort ${label} column ${direction === 'asc' ? 'descending' : 'ascending'}`;+};+export const StoragePoolsTable: Component<StoragePoolsTableProps> = (props) => {const model = useStoragePoolsTableModel({groupedRecords: () => props.groupedRecords,@@ -58,6 +90,13 @@ export const StoragePoolsTable: Component<StoragePoolsTableProps> = (props) => {setExpandedPoolId: props.setExpandedPoolId,});+ const handleSort = (sortKey: StorageSortKey) => {+ props.setSortDirection(+ getNextStorageColumnSortDirection(props.sortKey, props.sortDirection, sortKey),+ );+ props.setSortKey(sortKey);+ };+return (<Showwhen={props.isLoading}@@ -81,14 +120,57 @@ export const StoragePoolsTable: Component<StoragePoolsTableProps> = (props) => {<TableHeadclass={column.className}aria-label={column.label}+ aria-sort={+ props.sortKey === column.sortKey+ ? props.sortDirection === 'asc'+ ? 'ascending'+ : 'descending'+ : undefined+ }title={column.label}>- <span aria-hidden="true" class="hidden xl:inline">- {column.label}- </span>- <span aria-hidden="true" class="xl:hidden">- {column.compactLabel}- </span>+ <button+ type="button"+ class={STORAGE_POOL_HEADER_SORT_BUTTON_CLASS}+ onClick={() => handleSort(column.sortKey)}+ aria-label={getStorageColumnSortButtonLabel(+ column.label,+ props.sortKey === column.sortKey,+ props.sortDirection,+ )}+ title={getStorageColumnSortButtonLabel(+ column.label,+ props.sortKey === column.sortKey,+ props.sortDirection,+ )}+ >+ <span class="hidden min-w-0 truncate xl:inline">{column.label}</span>+ <span class="min-w-0 truncate xl:hidden">{column.compactLabel}</span>+ <Show+ when={props.sortKey === column.sortKey}+ fallback={+ <ArrowUpDownIcon+ aria-hidden="true"+ class={`${STORAGE_POOL_HEADER_SORT_ICON_CLASS} text-muted/70`}+ />+ }+ >+ <Show+ when={props.sortDirection === 'asc'}+ fallback={+ <ArrowDownIcon+ aria-hidden="true"+ class={`${STORAGE_POOL_HEADER_SORT_ICON_CLASS} text-base-content`}+ />+ }+ >+ <ArrowUpIcon+ aria-hidden="true"+ class={`${STORAGE_POOL_HEADER_SORT_ICON_CLASS} text-base-content`}+ />+ </Show>+ </Show>+ </button></TableHead>)}</For>diff --git a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsxindex 797f225ce4..db6159dcb8 100644--- a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx+++ b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx@@ -733,10 +733,14 @@ describe('Storage', () => {.some((element) => element.getAttribute('title') === 'Pool redundancy is reduced.'),).toBe(true);- fireEvent.change(screen.getByLabelText('Sort by'), {- target: { value: 'usage' },- });- fireEvent.click(screen.getByRole('button', { name: 'Sort direction' }));+ const usageHeader = screen.getByRole('columnheader', { name: 'Usage' });+ fireEvent.click(within(usageHeader).getByRole('button', { name: 'Sort Usage column' }));+ expect(usageHeader).toHaveAttribute('aria-sort', 'descending');+ expect((screen.getByLabelText('Sort by') as HTMLSelectElement).value).toBe('usage');++ fireEvent.click(+ within(usageHeader).getByRole('button', { name: 'Sort Usage column ascending' }),+ );await waitFor(() => {const orderedRowIds = Array.from(document.querySelectorAll('tr[data-row-id]')).map((row) =>diff --git a/frontend-modern/src/components/Storage/__tests__/storagePageState.test.ts b/frontend-modern/src/components/Storage/__tests__/storagePageState.test.tsindex 012091a599..2c3344f509 100644--- a/frontend-modern/src/components/Storage/__tests__/storagePageState.test.ts+++ b/frontend-modern/src/components/Storage/__tests__/storagePageState.test.ts@@ -21,6 +21,7 @@ import {DEFAULT_STORAGE_STATUS_FILTER,DEFAULT_STORAGE_VIEW,filterStorageDiskNodeOptions,+ getDefaultStorageSortDirection,getStorageFilterGroupBy,getStorageNodeFilterLabel,getStorageStatusFilterValue,@@ -103,7 +104,11 @@ describe('storagePageState', () => {expect(normalizeStorageHealthFilter('needs-attention')).toBe('attention');expect(normalizeStorageSortKey(' usage ')).toBe('usage');expect(normalizeStorageSortKey('usage')).toBe('usage');+ expect(normalizeStorageSortKey(' state ')).toBe('state');+ expect(normalizeStorageSortKey('growth')).toBe('growth');expect(normalizeStorageSortKey('weird')).toBe('priority');+ expect(getDefaultStorageSortDirection('name')).toBe('asc');+ expect(getDefaultStorageSortDirection('usage')).toBe('desc');expect(normalizeStorageGroupKey(' status ')).toBe('status');expect(normalizeStorageGroupKey('status')).toBe('status');expect(normalizeStorageGroupKey('weird')).toBe('none');@@ -131,8 +136,13 @@ describe('storagePageState', () => {expect(DEFAULT_STORAGE_SORT_OPTIONS.map((option) => option.value)).toEqual(['priority','name',+ 'state',+ 'source','usage','type',+ 'host',+ 'protection',+ 'growth',]);expect(STORAGE_STATUS_FILTER_OPTIONS.map((option) => option.value)).toEqual(['all',diff --git a/frontend-modern/src/components/Storage/storagePageState.ts b/frontend-modern/src/components/Storage/storagePageState.tsindex 4ce0ebaec6..d5c8ce83be 100644--- a/frontend-modern/src/components/Storage/storagePageState.ts+++ b/frontend-modern/src/components/Storage/storagePageState.ts@@ -59,9 +59,14 @@ export type StoragePageNodeOption = {export const DEFAULT_STORAGE_SORT_OPTIONS: Array<{ value: StorageSortKey; label: string }> = [{ value: 'priority', label: 'Priority' },- { value: 'name', label: 'Name' },+ { value: 'name', label: 'Storage' },+ { value: 'state', label: 'State' },+ { value: 'source', label: 'Source' },{ value: 'usage', label: 'Usage %' },{ value: 'type', label: 'Type' },+ { value: 'host', label: 'Host' },+ { value: 'protection', label: 'Protection' },+ { value: 'growth', label: 'Growth' },];export const STORAGE_STATUS_FILTER_OPTIONS: StorageOption[] = [@@ -117,14 +122,24 @@ export const normalizeStorageSortKey = (value: string): StorageSortKey => {if (normalized === 'priority' ||normalized === 'name' ||+ normalized === 'state' ||+ normalized === 'source' ||normalized === 'usage' ||- normalized === 'type'+ normalized === 'type' ||+ normalized === 'host' ||+ normalized === 'protection' ||+ normalized === 'growth') {return normalized;}return 'priority';};+export const getDefaultStorageSortDirection = (+ sortKey: StorageSortKey,+): 'asc' | 'desc' =>+ sortKey === 'priority' || sortKey === 'usage' || sortKey === 'growth' ? 'desc' : 'asc';+export const normalizeStorageGroupKey = (value: string): StorageGroupKey => {const normalized = normalizeStorageRouteToken(value);if (diff --git a/frontend-modern/src/components/Storage/useStorageModel.ts b/frontend-modern/src/components/Storage/useStorageModel.tsindex dde10fc6ea..2b3de424bb 100644--- a/frontend-modern/src/components/Storage/useStorageModel.ts+++ b/frontend-modern/src/components/Storage/useStorageModel.ts@@ -1,5 +1,6 @@import { Accessor, createMemo } from 'solid-js';import type { StorageHealthFilter, StorageRecord } from '@/features/storageBackups/models';+import type { StorageCapacityDeltaPresentation } from '@/features/storageBackups/storageCapacityDeltaPresentation';import {buildStorageSourceOptions,filterStorageRecords,@@ -31,6 +32,7 @@ type UseStorageModelOptions = {nodeOptions: Accessor<StorageNodeOption[]>;sortKey: Accessor<StorageSortKey>;sortDirection: Accessor<'asc' | 'desc'>;+ storageGrowthBySeriesId?: Accessor<ReadonlyMap<string, StorageCapacityDeltaPresentation>>;groupBy: Accessor<StorageGroupKey>;};@@ -51,7 +53,10 @@ export const useStorageModel = (options: UseStorageModelOptions) => {});const sortedRecords = createMemo(() =>- sortStorageRecords(filteredRecords(), options.sortKey(), options.sortDirection()),+ sortStorageRecords(filteredRecords(), options.sortKey(), options.sortDirection(), {+ growthBySeriesId:+ options.sortKey() === 'growth' ? options.storageGrowthBySeriesId?.() : undefined,+ }),);const groupedRecords = createMemo<StorageGroupedRecords[]>(() =>diff --git a/frontend-modern/src/components/Storage/useStoragePageData.ts b/frontend-modern/src/components/Storage/useStoragePageData.tsindex e0ef5a7100..85725c564b 100644--- a/frontend-modern/src/components/Storage/useStoragePageData.ts+++ b/frontend-modern/src/components/Storage/useStoragePageData.ts@@ -1,6 +1,7 @@import { Accessor, createMemo } from 'solid-js';import { buildStorageRecords } from '@/features/storageBackups/storageAdapters';import type { StorageHealthFilter } from '@/features/storageBackups/models';+import type { StorageCapacityDeltaPresentation } from '@/features/storageBackups/storageCapacityDeltaPresentation';import {buildPhysicalDiskGroupFilterOptions,buildPhysicalDiskRoleFilterOptions,@@ -32,6 +33,7 @@ type UseStoragePageDataOptions = {selectedNodeId: Accessor<string>;sortKey: Accessor<StorageSortKey>;sortDirection: Accessor<'asc' | 'desc'>;+ storageGrowthBySeriesId?: Accessor<ReadonlyMap<string, StorageCapacityDeltaPresentation>>;groupBy: Accessor<StorageGroupKey>;};@@ -69,6 +71,7 @@ export const useStoragePageData = (options: UseStoragePageDataOptions) => {nodeOptions,sortKey: options.sortKey,sortDirection: options.sortDirection,+ storageGrowthBySeriesId: options.storageGrowthBySeriesId,groupBy: options.groupBy,});diff --git a/frontend-modern/src/components/Storage/useStoragePageModel.ts b/frontend-modern/src/components/Storage/useStoragePageModel.tsindex 7e95219dc4..0c5b873fb2 100644--- a/frontend-modern/src/components/Storage/useStoragePageModel.ts+++ b/frontend-modern/src/components/Storage/useStoragePageModel.ts@@ -105,6 +105,26 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>location,navigate,});+ const storageSummaryCharts = useStorageSummaryCharts({+ timeRange: summaryTimeRange,+ nodeId: selectedNodeId,+ caller: 'useStoragePageModel',+ });+ const storageGrowthRangeLabel = createMemo(+ () => SUMMARY_TIME_RANGE_LABEL[summaryTimeRange()] ?? summaryTimeRange(),+ );+ const storageGrowthColumnLabel = createMemo(() => `Growth (${storageGrowthRangeLabel()})`);+ const storageGrowthBySeriesId = createMemo(() => {+ const growth = new Map<string, ReturnType<typeof buildStorageCapacityDeltaPresentation>>();+ const pools = storageSummaryCharts.data()?.pools ?? {};+ for (const [seriesId, pool] of Object.entries(pools)) {+ growth.set(+ seriesId,+ buildStorageCapacityDeltaPresentation(pool.used ?? [], storageGrowthRangeLabel()),+ );+ }+ return growth;+ });const {records,@@ -133,6 +153,7 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>selectedNodeId,sortKey,sortDirection,+ storageGrowthBySeriesId,groupBy,});@@ -152,12 +173,6 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>void storageRecoveryResources.refetch();reconnect();};- const storageSummaryCharts = useStorageSummaryCharts({- timeRange: summaryTimeRange,- nodeId: selectedNodeId,- caller: 'useStoragePageModel',- });-const {expandedGroups,expandedPoolId,@@ -181,21 +196,6 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>}return ids;});- const storageGrowthRangeLabel = createMemo(- () => SUMMARY_TIME_RANGE_LABEL[summaryTimeRange()] ?? summaryTimeRange(),- );- const storageGrowthColumnLabel = createMemo(() => `Growth (${storageGrowthRangeLabel()})`);- const storageGrowthBySeriesId = createMemo(() => {- const growth = new Map<string, ReturnType<typeof buildStorageCapacityDeltaPresentation>>();- const pools = storageSummaryCharts.data()?.pools ?? {};- for (const [seriesId, pool] of Object.entries(pools)) {- growth.set(- seriesId,- buildStorageCapacityDeltaPresentation(pool.used ?? [], storageGrowthRangeLabel()),- );- }- return growth;- });const hoveredStorageResourceId = createMemo(() => {const hoveredId = hoveredStorageRowId();if (!hoveredId) return null;diff --git a/frontend-modern/src/features/storageBackups/__tests__/storageModelCore.test.ts b/frontend-modern/src/features/storageBackups/__tests__/storageModelCore.test.tsindex d809aaaf60..8227dde8e8 100644--- a/frontend-modern/src/features/storageBackups/__tests__/storageModelCore.test.ts+++ b/frontend-modern/src/features/storageBackups/__tests__/storageModelCore.test.ts@@ -120,6 +120,76 @@ describe('storageModelCore', () => {});});+ it('sorts storage records by the visible pool-table columns', () => {+ const alpha = makeRecord({+ id: 'storage-alpha',+ name: 'Alpha',+ platformLabel: 'Zeta source',+ topologyLabel: 'Dataset',+ hostLabel: 'node-b',+ protectionLabel: 'Mirror',+ details: { status: 'online', type: 'dir' },+ capacity: { totalBytes: 100, usedBytes: 20, freeBytes: 80, usagePercent: 20 },+ });+ const beta = makeRecord({+ id: 'storage-beta',+ name: 'Beta',+ platformLabel: 'Alpha source',+ topologyLabel: 'Block',+ hostLabel: 'node-a',+ protectionLabel: 'Raidz',+ details: { status: 'degraded', type: 'zfspool' },+ capacity: { totalBytes: 100, usedBytes: 80, freeBytes: 20, usagePercent: 80 },+ });+ const gamma = makeRecord({+ id: 'storage-gamma',+ name: 'Gamma',+ platformLabel: 'Beta source',+ topologyLabel: 'File',+ hostLabel: 'node-c',+ protectionLabel: 'Archive',+ details: { status: 'unknown', type: 'nfs' },+ capacity: { totalBytes: 0, usedBytes: 0, freeBytes: 0, usagePercent: 0 },+ });+ const records = [alpha, beta, gamma];+ const growthBySeriesId = new Map([+ [+ 'storage-alpha',+ { deltaBytes: 200, label: '+200 B', title: 'Growth', toneClass: 'text-muted' },+ ],+ [+ 'storage-beta',+ { deltaBytes: 800, label: '+800 B', title: 'Growth', toneClass: 'text-muted' },+ ],+ ]);++ expect(sortStorageRecords(records, 'source', 'asc').map((record) => record.id)).toEqual([+ 'storage-beta',+ 'storage-gamma',+ 'storage-alpha',+ ]);+ expect(sortStorageRecords(records, 'host', 'asc').map((record) => record.id)).toEqual([+ 'storage-beta',+ 'storage-alpha',+ 'storage-gamma',+ ]);+ expect(sortStorageRecords(records, 'state', 'asc').map((record) => record.id)).toEqual([+ 'storage-beta',+ 'storage-alpha',+ 'storage-gamma',+ ]);+ expect(sortStorageRecords(records, 'protection', 'desc').map((record) => record.id)).toEqual([+ 'storage-beta',+ 'storage-alpha',+ 'storage-gamma',+ ]);+ expect(+ sortStorageRecords(records, 'growth', 'desc', { growthBySeriesId }).map(+ (record) => record.id,+ ),+ ).toEqual(['storage-beta', 'storage-alpha', 'storage-gamma']);+ });+it('does not synthesize an empty group when filters remove every storage record', () => {expect(groupStorageRecords([], 'none')).toEqual([]);expect(groupStorageRecords([], 'status')).toEqual([]);diff --git a/frontend-modern/src/features/storageBackups/storageModelCore.ts b/frontend-modern/src/features/storageBackups/storageModelCore.tsindex 68f47bc136..fa1c19c18e 100644--- a/frontend-modern/src/features/storageBackups/storageModelCore.ts+++ b/frontend-modern/src/features/storageBackups/storageModelCore.ts@@ -1,6 +1,8 @@import type { NormalizedHealth, StorageHealthFilter, StorageRecord } from './models';import { normalizeStorageSourceKey, orderStorageSourceKeys } from '@/utils/storageSources';import { matchesStorageNodeTerms, parseStorageSearchQuery } from './storageSearchQuery';+import type { StorageCapacityDeltaPresentation } from './storageCapacityDeltaPresentation';+import { resolveStorageRecordMetricResourceId } from './storageMetricsIdentity';import {getStorageRecordActionSummary,getStorageRecordContent,@@ -18,10 +20,27 @@ import {getStorageRecordType,getStorageRecordUsagePercent,} from './recordPresentation';+import {+ getCompactStoragePoolProtectionLabel,+ getStoragePoolStateLabel,+} from './rowPresentation';-export type StorageSortKey = 'priority' | 'name' | 'usage' | 'type';+export type StorageSortKey =+ | 'priority'+ | 'name'+ | 'state'+ | 'source'+ | 'type'+ | 'host'+ | 'protection'+ | 'usage'+ | 'growth';export type StorageGroupKey = 'node' | 'type' | 'status' | 'none';+export type StorageSortContext = {+ growthBySeriesId?: ReadonlyMap<string, StorageCapacityDeltaPresentation>;+};+export type StorageNodeOption = {id: string;label: string;@@ -151,29 +170,51 @@ export const sortStorageRecords = (records: StorageRecord[],sortKey: StorageSortKey,sortDirection: 'asc' | 'desc',+ context: StorageSortContext = {},): StorageRecord[] => {const numericCompare = (a: number, b: number): number => {if (a === b) return 0;return a < b ? -1 : 1;};+ const textCompare = (a: string, b: string): number =>+ a.localeCompare(b, undefined, { sensitivity: 'base', numeric: true });++ const growthDeltaBytes = (record: StorageRecord): number | null =>+ context.growthBySeriesId?.get(resolveStorageRecordMetricResourceId(record))?.deltaBytes ?? null;+return [...records].sort((a, b) => {let comparison = 0;if (sortKey === 'usage') {comparison = numericCompare(getStorageRecordUsagePercent(a), getStorageRecordUsagePercent(b));+ } else if (sortKey === 'growth') {+ const left = growthDeltaBytes(a);+ const right = growthDeltaBytes(b);+ if (left === null && right !== null) return 1;+ if (left !== null && right === null) return -1;+ comparison = left === null || right === null ? 0 : numericCompare(left, right);} else if (sortKey === 'priority') {comparison = numericCompare(a.incidentPriority || 0, b.incidentPriority || 0);+ } else if (sortKey === 'state') {+ comparison = textCompare(getStoragePoolStateLabel(a), getStoragePoolStateLabel(b));+ } else if (sortKey === 'source') {+ comparison = textCompare(getStorageRecordPlatformLabel(a), getStorageRecordPlatformLabel(b));} else if (sortKey === 'type') {- comparison = getStorageRecordType(a).localeCompare(getStorageRecordType(b), undefined, {- sensitivity: 'base',- });+ comparison = textCompare(getStorageRecordTopologyLabel(a), getStorageRecordTopologyLabel(b));+ } else if (sortKey === 'host') {+ comparison = textCompare(getStorageRecordHostLabel(a), getStorageRecordHostLabel(b));+ } else if (sortKey === 'protection') {+ comparison = textCompare(+ getCompactStoragePoolProtectionLabel(a),+ getCompactStoragePoolProtectionLabel(b),+ );} else {- comparison = a.name.localeCompare(b.name, undefined, { sensitivity: 'base' });+ comparison = textCompare(a.name, b.name);}if (comparison === 0) {- comparison = a.name.localeCompare(b.name, undefined, { sensitivity: 'base' });+ comparison = textCompare(a.name, b.name);}return sortDirection === 'asc' ? comparison : -comparison;diff --git a/frontend-modern/src/features/storageBackups/storagePagePresentation.ts b/frontend-modern/src/features/storageBackups/storagePagePresentation.tsindex 41393ed279..c4ab568cf6 100644--- a/frontend-modern/src/features/storageBackups/storagePagePresentation.ts+++ b/frontend-modern/src/features/storageBackups/storagePagePresentation.ts@@ -1,6 +1,7 @@import { formatBytes, formatPercent } from '@/utils/format';import type { StorageRecord } from './models';import type { CephSummaryStats } from './cephSummaryPresentation';+import type { StorageSortKey } from './storageModelCore';export type StoragePageBannerKind =| 'reconnecting'@@ -16,6 +17,7 @@ export type StorageViewOption = {export type StoragePoolTableColumn = {label: string;compactLabel: string;+ sortKey: StorageSortKey;className: string;colClassName: string;};@@ -34,48 +36,56 @@ export const getStoragePoolTableColumns = ({label: 'Storage',compactLabel: 'Storage',+ sortKey: 'name',className: `${STORAGE_POOL_TABLE_HEADER_CLASS} w-[34%] sm:w-[26%] md:w-[23%] xl:w-[18%]`,colClassName: 'w-[34%] sm:w-[26%] md:w-[23%] xl:w-[18%]',},{label: 'State',compactLabel: 'State',+ sortKey: 'state',className: `${STORAGE_POOL_TABLE_HEADER_CLASS} w-[24%] sm:w-[20%] md:w-[17%] xl:w-[14%]`,colClassName: 'w-[24%] sm:w-[20%] md:w-[17%] xl:w-[14%]',},{label: 'Source',compactLabel: 'Src',+ sortKey: 'source',className: `${STORAGE_POOL_TABLE_HEADER_CLASS} w-[13%] sm:w-[10%] md:w-[8%]`,colClassName: 'w-[13%] sm:w-[10%] md:w-[8%]',},{label: 'Type',compactLabel: 'Type',+ sortKey: 'type',className: `${STORAGE_POOL_TABLE_HEADER_CLASS} hidden xl:table-cell xl:w-[8%]`,colClassName: 'hidden xl:table-column xl:w-[8%]',},{label: 'Host',compactLabel: 'Host',+ sortKey: 'host',className: `${STORAGE_POOL_TABLE_HEADER_CLASS} hidden sm:table-cell sm:w-[13%] md:w-[12%] xl:w-[10%]`,colClassName: 'hidden sm:table-column sm:w-[13%] md:w-[12%] xl:w-[10%]',},{label: 'Protection',compactLabel: 'Prot',+ sortKey: 'protection',className: `${STORAGE_POOL_TABLE_HEADER_CLASS} hidden sm:table-cell sm:w-[15%] md:w-[15%] xl:w-[13%]`,colClassName: 'hidden sm:table-column sm:w-[15%] md:w-[15%] xl:w-[13%]',},{label: 'Usage',compactLabel: 'Used',+ sortKey: 'usage',className: `${STORAGE_POOL_TABLE_HEADER_CLASS} w-[29%] sm:w-[16%] md:w-[25%] xl:w-[18%]`,colClassName: 'w-[29%] sm:w-[16%] md:w-[25%] xl:w-[18%]',},{label: growthColumnLabel,compactLabel: growthColumnLabel.replace(/^Growth\s*\((.+)\)$/i, '$1'),+ sortKey: 'growth',className: `${STORAGE_POOL_TABLE_HEADER_CLASS} hidden xl:table-cell xl:w-[11%]`,colClassName: 'hidden xl:table-column xl:w-[11%]',},