feat: edit container parent in the node modal instead of detail panel
Replaces the detail-panel container selector with the existing "Parent
Container" dropdown in the edit modal (double-click). The selector now
shows for any node that is nested in — or can nest into — a container_mode
node, not just lxc/vm/docker_container, so a dragged-in node can be
re-targeted or detached ("None") from the modal.
- NodeModal: container_mode candidates count as valid parents; selector
shown for nested nodes; submit/type-change keep valid container parents
- App: pass container_mode in parentCandidates
- revert detail-panel selector + setNodeParent store action (updateNode
already handles parent attach/detach)
ha-relevant: yes
This commit is contained in:
@@ -43,7 +43,6 @@ const mockStore = {
|
||||
createGroup: vi.fn(),
|
||||
ungroup: vi.fn(),
|
||||
removeFromGroup: vi.fn(),
|
||||
setNodeParent: vi.fn(),
|
||||
}
|
||||
|
||||
function setupStore(overrides = {}) {
|
||||
@@ -139,50 +138,6 @@ describe('MultiSelectPanel', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('DetailPanel container selector', () => {
|
||||
beforeEach(() => vi.clearAllMocks())
|
||||
|
||||
function makeContainer(id: string, label: string) {
|
||||
return { id, type: 'proxmox', position: { x: 0, y: 0 }, data: { label, type: 'proxmox', status: 'online', services: [], container_mode: true } }
|
||||
}
|
||||
|
||||
it('does not show the container selector for a top-level node', () => {
|
||||
const n1 = makeNode('n1')
|
||||
setupStore({ nodes: [n1], selectedNodeId: 'n1', selectedNodeIds: ['n1'] })
|
||||
renderPanel()
|
||||
expect(screen.queryByLabelText('Container')).toBeNull()
|
||||
})
|
||||
|
||||
it('shows the container selector for a nested node, defaulting to its parent', () => {
|
||||
const px = makeContainer('px1', 'Proxmox')
|
||||
const child = makeNode('n1', { parentId: 'px1' })
|
||||
setupStore({ nodes: [px, child], selectedNodeId: 'n1', selectedNodeIds: ['n1'] })
|
||||
renderPanel()
|
||||
expect((screen.getByLabelText('Container') as HTMLSelectElement).value).toBe('px1')
|
||||
})
|
||||
|
||||
it('detaches the node when "None" is selected', () => {
|
||||
const setNodeParent = vi.fn()
|
||||
const px = makeContainer('px1', 'Proxmox')
|
||||
const child = makeNode('n1', { parentId: 'px1' })
|
||||
setupStore({ nodes: [px, child], selectedNodeId: 'n1', selectedNodeIds: ['n1'], setNodeParent })
|
||||
renderPanel()
|
||||
fireEvent.change(screen.getByLabelText('Container'), { target: { value: '' } })
|
||||
expect(setNodeParent).toHaveBeenCalledWith('n1', null)
|
||||
})
|
||||
|
||||
it('re-parents the node when another container is selected', () => {
|
||||
const setNodeParent = vi.fn()
|
||||
const px1 = makeContainer('px1', 'Proxmox A')
|
||||
const px2 = makeContainer('px2', 'Proxmox B')
|
||||
const child = makeNode('n1', { parentId: 'px1' })
|
||||
setupStore({ nodes: [px1, px2, child], selectedNodeId: 'n1', selectedNodeIds: ['n1'], setNodeParent })
|
||||
renderPanel()
|
||||
fireEvent.change(screen.getByLabelText('Container'), { target: { value: 'px2' } })
|
||||
expect(setNodeParent).toHaveBeenCalledWith('n1', 'px2')
|
||||
})
|
||||
})
|
||||
|
||||
describe('GroupDetailPanel', () => {
|
||||
beforeEach(() => vi.clearAllMocks())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user