Skip to content

Commit

Permalink
fix: soft power off lp#2058662 (#5371)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski committed Mar 26, 2024
1 parent e6ef966 commit a370a7d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("PowerOffForm", () => {
type: "machine/softOff",
meta: {
model: "machine",
method: "soft_power_off",
method: "action",
},
payload: {
params: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/machine/reducers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,7 @@ describe("machine reducer", () => {
).toEqual(
factory.machineState({
items: [machine],
statuses: { abc123: factory.machineStatus({ turningOff: true }) },
statuses: { abc123: factory.machineStatus() },
})
);
});
Expand Down
42 changes: 2 additions & 40 deletions src/app/store/machine/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ const machineSlice = createSlice({
return {
meta: {
model: MachineMeta.MODEL,
method: "soft_power_off",
method: "action",
},
payload: {
params: actionParams,
Expand All @@ -1546,45 +1546,7 @@ const machineSlice = createSlice({
},
},
softOffError: statusHandlers.softOff.error,
softOffStart: {
prepare: (params) => {
if ("filter" in params) {
return {
meta: {
item: { filter: { id: params.filter.id } },
},
payload: null,
};
} else {
return {
meta: {
item: { filter: { id: [params.system_id] } },
},
payload: null,
};
}
},
reducer: (
state: MachineState,
action: PayloadAction<
null,
string,
GenericItemMeta<
{ filter: { id: Machine[MachineMeta.PK][] } } | { system_id: never }
>
>
) => {
if ("filter" in action.meta.item) {
action.meta.item.filter.id.forEach((id) => {
if (state.statuses[id]) {
state.statuses[id].turningOff = true;
}
});
} else {
state.statuses[action.meta.item.system_id].turningOff = true;
}
},
},
softOffStart: statusHandlers.softOff.start,
softOffSuccess: statusHandlers.softOff.success,
suppressScriptResults: {
prepare: (
Expand Down

0 comments on commit a370a7d

Please sign in to comment.