Skip to content

Commit

Permalink
fix: change storage layout sidepanel MAASENG-2798 (#5335)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski committed Mar 11, 2024
1 parent 38fc68e commit cb8f225
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/machines/components/MachineForms/MachineForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const MachineForms = ({
return <AddChassisForm clearSidePanelContent={clearSidePanelContent} />;
case MachineSidePanelViews.ADD_MACHINE:
return <AddMachineForm clearSidePanelContent={clearSidePanelContent} />;
case MachineSidePanelViews.CHANGE_STORAGE_LAYOUT: {
case MachineSidePanelViews.APPLY_STORAGE_LAYOUT: {
if (!systemId || !selectedLayout) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/machines/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" })],
Expand All @@ -97,7 +98,7 @@ describe("ChangeStorageLayout", () => {
const store = mockStore(state);
renderWithBrowserRouter(
<ChangeStorageLayout
clearSidePanelContent={vi.fn()}
clearSidePanelContent={handleClearSidePanelContent}
selectedLayout={sampleStoragelayout}
systemId="abc123"
/>,
Expand Down Expand Up @@ -128,5 +129,6 @@ describe("ChangeStorageLayout", () => {
},
type: "machine/applyStorageLayout",
});
expect(handleClearSidePanelContent).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const ChangeStorageLayout = ({
storageLayout: selectedLayout.value,
})
);
clearSidePanelContent();
}}
saved={saved}
saving={saving}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/app/store/utils/node/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit cb8f225

Please sign in to comment.