From 4b38ee1039b263f321b8a2cfe464c67a10121b8b Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 8 Oct 2025 13:59:43 +0000 Subject: [PATCH] frontend: fix list view parent node detection --- .../src/components/Dashboard/Dashboard.tsx | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/frontend-modern/src/components/Dashboard/Dashboard.tsx b/frontend-modern/src/components/Dashboard/Dashboard.tsx index 6da11a1b7..172014c0b 100644 --- a/frontend-modern/src/components/Dashboard/Dashboard.tsx +++ b/frontend-modern/src/components/Dashboard/Dashboard.tsx @@ -16,6 +16,7 @@ import { Card } from '@/components/shared/Card'; import { EmptyState } from '@/components/shared/EmptyState'; import { NodeGroupHeader } from '@/components/shared/NodeGroupHeader'; import { ProxmoxSectionNav } from '@/components/Proxmox/ProxmoxSectionNav'; +import { isNodeOnline } from '@/utils/status'; interface DashboardProps { vms: VM[]; @@ -106,6 +107,28 @@ export function Dashboard(props: DashboardProps) { return map; }); + const resolveParentNode = (guest: VM | Container): Node | undefined => { + if (!guest) return undefined; + const nodes = nodeByInstance(); + + if (guest.id) { + const lastDash = guest.id.lastIndexOf('-'); + if (lastDash > 0) { + const nodeId = guest.id.slice(0, lastDash); + if (nodes[nodeId]) { + return nodes[nodeId]; + } + } + } + + const compositeKey = `${guest.instance}-${guest.node}`; + if (nodes[compositeKey]) { + return nodes[compositeKey]; + } + + return undefined; + }; + // Persist filter states to localStorage createEffect(() => { @@ -947,7 +970,6 @@ export function Dashboard(props: DashboardProps) { > {([instanceId, guests]) => { const node = nodeByInstance()[instanceId]; - const isNodeOnline = !!(node && node.status === 'online' && (node.uptime || 0) > 0); return ( <> @@ -967,6 +989,8 @@ export function Dashboard(props: DashboardProps) { const metadata = guestMetadata()[guestId] || guestMetadata()[`${guest.node}-${guest.vmid}`]; + const parentNode = node ?? resolveParentNode(guest); + const parentNodeOnline = parentNode ? isNodeOnline(parentNode) : true; return ( ); })()}