Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: composing machine does not update list lp#1842524 #5326

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading