Skip to content

Commit

Permalink
fix: composing machine does not update list lp#1842524 (#5326)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski committed Mar 1, 2024
1 parent 6f76ba6 commit 447be38
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/kvm/components/KVMForms/ComposeForm/ComposeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { actions as fabricActions } from "@/app/store/fabric";
import fabricSelectors from "@/app/store/fabric/selectors";
import { actions as generalActions } from "@/app/store/general";
import { powerTypes as powerTypesSelectors } from "@/app/store/general/selectors";
import { actions as machineActions } from "@/app/store/machine";
import { actions as messageActions } from "@/app/store/message";
import { actions as podActions } from "@/app/store/pod";
import podSelectors from "@/app/store/pod/selectors";
Expand Down Expand Up @@ -498,10 +499,12 @@ const ComposeForm = ({ clearSidePanelContent, hostId }: Props): JSX.Element => {
NotificationSeverity.INFORMATION
)
);
dispatch(machineActions.invalidateQueries());
clearSidePanelContent();
}}
processingCount={composingPods.length}
selectedCount={1}
showProcessingCount={false}
validateOnMount
validationSchema={ComposeFormSchema}
>
Expand Down
53 changes: 53 additions & 0 deletions src/app/store/machine/reducers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,59 @@ describe("machine reducer", () => {
);
});

it("resets stale status on fetchSuccess", () => {
const initialState = machineStateFactory({
loading: false,
lists: {
[callId]: machineStateListFactory({ loaded: true, stale: true }),
},
});
const groups = [
{ collapsed: true, count: 0, items: [], name: "admin", value: "admin1" },
];
const fetchSuccessPayload = { count: 1, cur_page: 2, groups, num_pages: 3 };
const expectedState = {
lists: {
[callId]: {
...machineStateListFactory(),
...fetchSuccessPayload,
loaded: true,
loading: false,
stale: false,
},
},
};

expect(
reducers(initialState, actions.fetchSuccess(callId, fetchSuccessPayload))
).toEqual(machineStateFactory(expectedState));
});

it("resets stale status on countSuccess", () => {
const initialState = machineStateFactory({
loading: false,
counts: {
[callId]: machineStateCountFactory({
loaded: true,
stale: true,
}),
},
});
expect(
reducers(initialState, actions.countSuccess(callId, { count: 1 }))
).toEqual(
machineStateFactory({
counts: {
[callId]: machineStateCountFactory({
loaded: true,
stale: false,
count: 1,
}),
},
})
);
});

it("updates selected machines on delete notify", () => {
const initialState = machineStateFactory({
selected: { items: ["abc123"] },
Expand Down
2 changes: 2 additions & 0 deletions src/app/store/machine/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ const machineSlice = createSlice({
...(action.meta.callId in state.counts
? state.counts[action.meta.callId]
: DEFAULT_COUNT_STATE),
stale: false,
count: action.payload.count,
loading: false,
loaded: true,
Expand Down Expand Up @@ -979,6 +980,7 @@ const machineSlice = createSlice({
});
});
const { payload } = action;
state.lists[callId].stale = false;
state.lists[callId].count = payload.count;
state.lists[callId].cur_page = payload.cur_page;
state.lists[callId].groups = payload.groups.map((group) => ({
Expand Down

0 comments on commit 447be38

Please sign in to comment.