diff --git a/frontend-modern/src/components/Alerts/ThresholdsTable.tsx b/frontend-modern/src/components/Alerts/ThresholdsTable.tsx index 578477a9d..1f7f724ca 100644 --- a/frontend-modern/src/components/Alerts/ThresholdsTable.tsx +++ b/frontend-modern/src/components/Alerts/ThresholdsTable.tsx @@ -258,7 +258,8 @@ export function ThresholdsTable(props: ThresholdsTableProps) { } else if (resource.type === 'storage') { groupKey = 'Storage'; } else { - groupKey = 'node' in resource ? resource.node : 'Unknown'; + // Group all guests together, but we'll show the node within the row + groupKey = 'Guests'; } if (!groups[groupKey]) { @@ -270,9 +271,27 @@ export function ThresholdsTable(props: ThresholdsTableProps) { // Sort resources within each group Object.keys(groups).forEach(key => { groups[key] = groups[key].sort((a, b) => { - if (a.type === 'node' && b.type !== 'node') return -1; - if (a.type !== 'node' && b.type === 'node') return 1; - if ('vmid' in a && 'vmid' in b && a.vmid && b.vmid) return a.vmid - b.vmid; + // For nodes, just sort by name + if (a.type === 'node' && b.type === 'node') { + return a.name.localeCompare(b.name); + } + + // For guests, sort by node first, then by vmid + if (a.type === 'guest' && b.type === 'guest') { + const nodeCompare = (a.node || '').localeCompare(b.node || ''); + if (nodeCompare !== 0) return nodeCompare; + if ('vmid' in a && 'vmid' in b && a.vmid && b.vmid) return a.vmid - b.vmid; + return a.name.localeCompare(b.name); + } + + // For storage, sort by node first, then by name + if (a.type === 'storage' && b.type === 'storage') { + const nodeCompare = (a.node || '').localeCompare(b.node || ''); + if (nodeCompare !== 0) return nodeCompare; + return a.name.localeCompare(b.name); + } + + // Default comparison return a.name.localeCompare(b.name); }); }); @@ -899,8 +918,21 @@ export function ThresholdsTable(props: ThresholdsTableProps) {