feat: add docker_container node type and fix container mode for non-proxmox types
- Add docker_container node type (Package icon, sky-blue accent) as child of docker_host - Parent selector for docker_container filters to docker_host only via nodeType field - Virtual edge drag-connect syncs parent_id for docker_container <-> docker_host - Fix setProxmoxContainerMode: remove proxmox-only guard so width/height are properly set/cleared for all container-capable types (docker_host, vm, lxc) - Fix handleAddNode: only give group size when container_mode=true, making create and reload behavior consistent (was giving size unconditionally for CONTAINER_MODE_TYPES) - Add regression tests for docker_host container mode toggle and docker_container nesting
This commit is contained in:
@@ -64,6 +64,17 @@ describe('canvasStore', () => {
|
||||
expect(nested?.extent).toBe('parent')
|
||||
})
|
||||
|
||||
it('docker_container nests under docker_host with container_mode on', () => {
|
||||
const host = { ...makeNode('dh1', { type: 'docker_host', container_mode: true }), position: { x: 100, y: 100 } }
|
||||
const container = { ...makeNode('dc1', { type: 'docker_container' }), position: { x: 160, y: 180 } }
|
||||
useCanvasStore.getState().addNode(host)
|
||||
useCanvasStore.getState().addNode(container)
|
||||
useCanvasStore.getState().updateNode('dc1', { parent_id: 'dh1' })
|
||||
const node = useCanvasStore.getState().nodes.find((n) => n.id === 'dc1')
|
||||
expect(node?.parentId).toBe('dh1')
|
||||
expect(node?.extent).toBe('parent')
|
||||
})
|
||||
|
||||
it('updateNode updates data fields', () => {
|
||||
useCanvasStore.getState().addNode(makeNode('n1', { label: 'old' }))
|
||||
useCanvasStore.getState().updateNode('n1', { label: 'new', ip: '10.0.0.1' })
|
||||
@@ -437,6 +448,26 @@ describe('canvasStore', () => {
|
||||
expect(hasUnsavedChanges).toBe(true)
|
||||
})
|
||||
|
||||
it('setProxmoxContainerMode ON sets width/height for docker_host (not just proxmox)', () => {
|
||||
const host: Node<NodeData> = { id: 'dh', type: 'docker_host', position: { x: 0, y: 0 }, data: { label: 'dh', type: 'docker_host', status: 'unknown', services: [], container_mode: false } }
|
||||
useCanvasStore.setState({ nodes: [host] })
|
||||
useCanvasStore.getState().setProxmoxContainerMode('dh', true)
|
||||
const updated = useCanvasStore.getState().nodes.find((n) => n.id === 'dh')
|
||||
expect(updated?.data.container_mode).toBe(true)
|
||||
expect(updated?.width).toBe(300)
|
||||
expect(updated?.height).toBe(200)
|
||||
})
|
||||
|
||||
it('setProxmoxContainerMode OFF clears width/height for docker_host', () => {
|
||||
const host: Node<NodeData> = { id: 'dh', type: 'docker_host', position: { x: 0, y: 0 }, width: 300, height: 200, data: { label: 'dh', type: 'docker_host', status: 'unknown', services: [], container_mode: true } }
|
||||
useCanvasStore.setState({ nodes: [host] })
|
||||
useCanvasStore.getState().setProxmoxContainerMode('dh', false)
|
||||
const updated = useCanvasStore.getState().nodes.find((n) => n.id === 'dh')
|
||||
expect(updated?.data.container_mode).toBe(false)
|
||||
expect(updated?.width).toBeUndefined()
|
||||
expect(updated?.height).toBeUndefined()
|
||||
})
|
||||
|
||||
it('setProxmoxContainerMode ON nests children inside proxmox', () => {
|
||||
const proxmox: Node<NodeData> = { id: 'px', type: 'proxmox', position: { x: 0, y: 0 }, data: { label: 'px', type: 'proxmox', status: 'unknown', services: [], container_mode: false } }
|
||||
const child = makeNode('vm1', { parent_id: 'px', type: 'vm' })
|
||||
|
||||
@@ -297,7 +297,6 @@ export const useCanvasStore = create<CanvasState>((set) => ({
|
||||
let nodes = state.nodes.map((n) => {
|
||||
if (n.id === proxmoxId) {
|
||||
const withMode = { ...n, data: { ...n.data, container_mode: enabled } }
|
||||
if (n.data.type !== 'proxmox') return withMode
|
||||
return enabled
|
||||
? { ...withMode, width: n.width ?? 300, height: n.height ?? 200 }
|
||||
: { ...withMode, width: undefined, height: undefined }
|
||||
|
||||
Reference in New Issue
Block a user