From cb8f225a7ff48a4e91df237650cf1977437a901b Mon Sep 17 00:00:00 2001 From: Peter Makowski Date: Mon, 11 Mar 2024 14:18:15 +0100 Subject: [PATCH] fix: change storage layout sidepanel MAASENG-2798 (#5335) --- src/app/machines/components/MachineForms/MachineForms.tsx | 2 +- src/app/machines/constants.ts | 2 +- .../ChangeStorageLayout/ChangeStorageLayout.test.tsx | 4 +++- .../ChangeStorageLayout/ChangeStorageLayout.tsx | 1 + .../ChangeStorageLayoutMenu/ChangeStorageLayoutMenu.tsx | 2 +- src/app/store/utils/node/base.ts | 2 ++ 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/machines/components/MachineForms/MachineForms.tsx b/src/app/machines/components/MachineForms/MachineForms.tsx index 2b518b00ed..a0565f4e60 100644 --- a/src/app/machines/components/MachineForms/MachineForms.tsx +++ b/src/app/machines/components/MachineForms/MachineForms.tsx @@ -69,7 +69,7 @@ export const MachineForms = ({ return ; case MachineSidePanelViews.ADD_MACHINE: return ; - case MachineSidePanelViews.CHANGE_STORAGE_LAYOUT: { + case MachineSidePanelViews.APPLY_STORAGE_LAYOUT: { if (!systemId || !selectedLayout) { return null; } diff --git a/src/app/machines/constants.ts b/src/app/machines/constants.ts index f34aa49cae..4e2be01430 100644 --- a/src/app/machines/constants.ts +++ b/src/app/machines/constants.ts @@ -38,7 +38,7 @@ export const MachineNonActionSidePanelViews = { ADD_MACHINE: ["machineNonActionForm", "addMachine"], ADD_SPECIAL_FILESYSTEM: ["machineNonActionForm", "addSpecialFilesystem"], ADD_VLAN: ["machineNonActionForm", "addVlan"], - CHANGE_STORAGE_LAYOUT: ["machineNonActionForm", "changeStorageLayout"], + APPLY_STORAGE_LAYOUT: ["machineNonActionForm", "applyStorageLayout"], CREATE_DATASTORE: ["machineNonActionForm", "createDatastore"], CREATE_RAID: ["machineNonActionForm", "createRaid"], CREATE_VOLUME_GROUP: ["machineNonActionForm", "createVolumeGroup"], diff --git a/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayout/ChangeStorageLayout.test.tsx b/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayout/ChangeStorageLayout.test.tsx index c4ee6252bd..4506554716 100644 --- a/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayout/ChangeStorageLayout.test.tsx +++ b/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayout/ChangeStorageLayout.test.tsx @@ -86,6 +86,7 @@ describe("ChangeStorageLayout", () => { }); it("correctly dispatches an action to update a machine's storage layout", async () => { + const handleClearSidePanelContent = vi.fn(); const state = rootStateFactory({ machine: machineStateFactory({ items: [machineDetailsFactory({ system_id: "abc123" })], @@ -97,7 +98,7 @@ describe("ChangeStorageLayout", () => { const store = mockStore(state); renderWithBrowserRouter( , @@ -128,5 +129,6 @@ describe("ChangeStorageLayout", () => { }, type: "machine/applyStorageLayout", }); + expect(handleClearSidePanelContent).toHaveBeenCalled(); }); }); diff --git a/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayout/ChangeStorageLayout.tsx b/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayout/ChangeStorageLayout.tsx index 753d31f16f..0ae796989a 100644 --- a/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayout/ChangeStorageLayout.tsx +++ b/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayout/ChangeStorageLayout.tsx @@ -49,6 +49,7 @@ export const ChangeStorageLayout = ({ storageLayout: selectedLayout.value, }) ); + clearSidePanelContent(); }} saved={saved} saving={saving} diff --git a/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayoutMenu/ChangeStorageLayoutMenu.tsx b/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayoutMenu/ChangeStorageLayoutMenu.tsx index 0efe769025..aea5b973d9 100644 --- a/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayoutMenu/ChangeStorageLayoutMenu.tsx +++ b/src/app/machines/views/MachineDetails/MachineStorage/ChangeStorageLayoutMenu/ChangeStorageLayoutMenu.tsx @@ -52,7 +52,7 @@ const ChangeStorageLayoutMenu = ({ systemId }: Props) => { children: option.label, onClick: () => setSidePanelContent({ - view: MachineSidePanelViews.CHANGE_STORAGE_LAYOUT, + view: MachineSidePanelViews.APPLY_STORAGE_LAYOUT, extras: { systemId, selectedLayout: option, diff --git a/src/app/store/utils/node/base.ts b/src/app/store/utils/node/base.ts index cdb24d42cf..b994d55fc7 100644 --- a/src/app/store/utils/node/base.ts +++ b/src/app/store/utils/node/base.ts @@ -218,6 +218,8 @@ export const getSidePanelTitle = ( return "Add VLAN"; case SidePanelViews.CHANGE_SOURCE[1]: return "Change source"; + case SidePanelViews.APPLY_STORAGE_LAYOUT[1]: + return "Change storage layout"; case SidePanelViews.CLEAR_ALL_DISCOVERIES[1]: return "Clear all discoveries"; case SidePanelViews.CREATE_DATASTORE[1]: