Skip to content

Self-hosted homelab infrastructure visualizer — interactive network diagram with live status monitoring

feat(docker): allow vm and proxmox as parent for docker_container

Pouzor43426e96aca5
diff --git a/frontend/src/utils/__tests__/virtualEdgeParent.test.ts b/frontend/src/utils/__tests__/virtualEdgeParent.test.ts
index 66f638b..6308866 100644
--- a/frontend/src/utils/__tests__/virtualEdgeParent.test.ts
+++ b/frontend/src/utils/__tests__/virtualEdgeParent.test.ts
@@ -42,7 +42,23 @@ describe('resolveVirtualEdgeParent', () => {
expect(res).toEqual({ childId: 'dc1', parentId: 'lxc1' })
})
- it('returns null when docker_container links to non-host/lxc target', () => {
+ it('nests docker_container under vm', () => {
+ const res = resolveVirtualEdgeParent(
+ { id: 'dc1', type: 'docker_container' },
+ { id: 'vm1', type: 'vm' },
+ )
+ expect(res).toEqual({ childId: 'dc1', parentId: 'vm1' })
+ })
+
+ it('nests docker_container under proxmox (reverse direction)', () => {
+ const res = resolveVirtualEdgeParent(
+ { id: 'px1', type: 'proxmox' },
+ { id: 'dc1', type: 'docker_container' },
+ )
+ expect(res).toEqual({ childId: 'dc1', parentId: 'px1' })
+ })
+
+ it('returns null when docker_container links to unsupported parent type', () => {
const res = resolveVirtualEdgeParent(
{ id: 'dc1', type: 'docker_container' },
{ id: 'srv1', type: 'server' },
diff --git a/frontend/src/utils/virtualEdgeParent.ts b/frontend/src/utils/virtualEdgeParent.ts
index 924e8f9..b239822 100644
--- a/frontend/src/utils/virtualEdgeParent.ts
+++ b/frontend/src/utils/virtualEdgeParent.ts
@@ -3,6 +3,7 @@ import type { NodeData } from '@/types'
export type NodeType = NodeData['type']
const CONTAINER_MODE_TYPES = new Set<NodeType>(['proxmox', 'vm', 'lxc', 'docker_host'])
+const DOCKER_CONTAINER_PARENT_TYPES = new Set<NodeType>(['docker_host', 'lxc', 'vm', 'proxmox'])
export interface VirtualEdgeEndpoint {
id: string
@@ -27,10 +28,10 @@ export function resolveVirtualEdgeParent(
if (CONTAINER_MODE_TYPES.has(srcType) && (tgtType === 'lxc' || tgtType === 'vm')) {
return { childId: tgtId, parentId: srcId }
}
- if (srcType === 'docker_container' && (tgtType === 'docker_host' || tgtType === 'lxc')) {
+ if (srcType === 'docker_container' && DOCKER_CONTAINER_PARENT_TYPES.has(tgtType)) {
return { childId: srcId, parentId: tgtId }
}
- if (tgtType === 'docker_container' && (srcType === 'docker_host' || srcType === 'lxc')) {
+ if (tgtType === 'docker_container' && DOCKER_CONTAINER_PARENT_TYPES.has(srcType)) {
return { childId: tgtId, parentId: srcId }
}
return null