Skip to content

Commit

Permalink
refactor: generate common reducers (#5429)
Browse files Browse the repository at this point in the history
- remove redundant skipped state changes comments
  • Loading branch information
petermakowski authored May 9, 2024
1 parent f2b18aa commit b4df79e
Show file tree
Hide file tree
Showing 36 changed files with 291 additions and 487 deletions.
12 changes: 3 additions & 9 deletions src/app/store/auth/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ const authSlice = createSlice<UserState, Reducers>({
params,
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
adminChangePasswordStart: (state: UserState) => {
state.auth.saved = false;
Expand Down Expand Up @@ -82,9 +80,7 @@ const authSlice = createSlice<UserState, Reducers>({
params,
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
changePasswordStart: (state: UserState) => {
state.auth.saved = false;
Expand Down Expand Up @@ -116,9 +112,7 @@ const authSlice = createSlice<UserState, Reducers>({
},
payload: null,
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
fetchStart: (state: UserState) => {
state.auth.loading = true;
Expand Down
28 changes: 7 additions & 21 deletions src/app/store/bootresource/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ const bootResourceSlice = createSlice({
params,
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
deleteImageError: (
state: BootResourceState,
Expand Down Expand Up @@ -83,9 +81,7 @@ const bootResourceSlice = createSlice({
params,
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
fetchError: (
state: BootResourceState,
Expand Down Expand Up @@ -116,9 +112,7 @@ const bootResourceSlice = createSlice({
},
payload: null,
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
pollError: (
state: BootResourceState,
Expand Down Expand Up @@ -170,9 +164,7 @@ const bootResourceSlice = createSlice({
params,
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
saveOtherError: (
state: BootResourceState,
Expand Down Expand Up @@ -201,9 +193,7 @@ const bootResourceSlice = createSlice({
params,
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
saveUbuntuError: (
state: BootResourceState,
Expand Down Expand Up @@ -231,9 +221,7 @@ const bootResourceSlice = createSlice({
params,
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
saveUbuntuCoreError: (
state: BootResourceState,
Expand All @@ -259,9 +247,7 @@ const bootResourceSlice = createSlice({
},
payload: null,
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
stopImportError: (
state: BootResourceState,
Expand Down
8 changes: 2 additions & 6 deletions src/app/store/config/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const statusSlice = createSlice({
},
payload: null,
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
fetchStart: (state: ConfigState) => {
state.loading = true;
Expand Down Expand Up @@ -56,9 +54,7 @@ const statusSlice = createSlice({
},
};
},
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
updateStart: (state: ConfigState) => {
state.saved = false;
Expand Down
58 changes: 18 additions & 40 deletions src/app/store/controller/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ const controllerSlice = createSlice({
ControllerMeta.PK,
CreateParams,
UpdateParams
>(ControllerMeta.MODEL, ControllerMeta.PK, setErrors),
>({
modelName: ControllerMeta.MODEL,
primaryKey: ControllerMeta.PK,
setErrors,
}),
checkImages: {
prepare: (ids: Controller[ControllerMeta.PK][]) => ({
meta: {
Expand All @@ -144,9 +148,7 @@ const controllerSlice = createSlice({
params: ids.map((id) => ({ [ControllerMeta.PK]: id })),
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
checkImagesError: {
prepare: (item: CheckImagesItem[], error: ControllerState["errors"]) => ({
Expand Down Expand Up @@ -247,9 +249,7 @@ const controllerSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
deleteError: statusHandlers.delete.error,
deleteNotify: (
Expand Down Expand Up @@ -311,9 +311,7 @@ const controllerSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
getSummaryXmlError: statusHandlers.getSummaryXml.error,
getSummaryXmlStart: statusHandlers.getSummaryXml.start,
Expand All @@ -333,9 +331,7 @@ const controllerSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
getSummaryYamlError: statusHandlers.getSummaryYaml.error,
getSummaryYamlStart: statusHandlers.getSummaryYaml.start,
Expand All @@ -354,9 +350,7 @@ const controllerSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
importImagesError: statusHandlers.importImages.error,
importImagesStart: statusHandlers.importImages.start,
Expand All @@ -375,9 +369,7 @@ const controllerSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
offError: statusHandlers.off.error,
offStart: statusHandlers.off.start,
Expand All @@ -396,9 +388,7 @@ const controllerSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
onError: statusHandlers.on.error,
onStart: statusHandlers.on.start,
Expand All @@ -417,9 +407,7 @@ const controllerSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
overrideFailedTestingError: statusHandlers.overrideFailedTesting.error,
overrideFailedTestingStart: statusHandlers.overrideFailedTesting.start,
Expand All @@ -439,9 +427,7 @@ const controllerSlice = createSlice({
params: ids.map((id) => ({ [ControllerMeta.PK]: id })),
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
pollCheckImagesError: {
prepare: (item: CheckImagesItem[], error: ControllerState["errors"]) => ({
Expand Down Expand Up @@ -494,9 +480,7 @@ const controllerSlice = createSlice({
},
payload: null,
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
pollCheckImagesSuccess: {
prepare: (item: CheckImagesItem[], payload: ImageSyncStatuses) => ({
Expand Down Expand Up @@ -536,9 +520,7 @@ const controllerSlice = createSlice({
params: system_id ? { system_id } : null,
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
setActiveError: (
state: ControllerState,
Expand Down Expand Up @@ -576,9 +558,7 @@ const controllerSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
setZoneError: statusHandlers.setZone.error,
setZoneStart: statusHandlers.setZone.start,
Expand All @@ -601,9 +581,7 @@ const controllerSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
testError: statusHandlers.test.error,
testStart: statusHandlers.test.start,
Expand Down
42 changes: 14 additions & 28 deletions src/app/store/device/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ const deviceSlice = createSlice({
DeviceMeta.PK,
CreateParams,
UpdateParams
>(DeviceMeta.MODEL, DeviceMeta.PK, setErrors),
>({
modelName: DeviceMeta.MODEL,
primaryKey: DeviceMeta.PK,
setErrors,
}),
createInterface: {
prepare: (params: CreateInterfaceParams) => ({
meta: {
Expand All @@ -118,9 +122,7 @@ const deviceSlice = createSlice({
params: preparePayloadParams(params),
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
createInterfaceError: statusHandlers.createInterface.error,
createInterfaceStart: statusHandlers.createInterface.start,
Expand Down Expand Up @@ -149,9 +151,7 @@ const deviceSlice = createSlice({
params: preparePayloadParams(params),
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
createPhysicalError: statusHandlers.createPhysical.error,
createPhysicalStart: statusHandlers.createPhysical.start,
Expand Down Expand Up @@ -188,9 +188,7 @@ const deviceSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
deleteError: statusHandlers.delete.error,
deleteNotify: (
Expand Down Expand Up @@ -219,9 +217,7 @@ const deviceSlice = createSlice({
params: preparePayloadParams(params),
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
deleteInterfaceError: statusHandlers.deleteInterface.error,
deleteInterfaceStart: statusHandlers.deleteInterface.start,
Expand All @@ -242,9 +238,7 @@ const deviceSlice = createSlice({
params: preparePayloadParams(params),
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
linkSubnetError: statusHandlers.linkSubnet.error,
linkSubnetStart: statusHandlers.linkSubnet.start,
Expand All @@ -260,9 +254,7 @@ const deviceSlice = createSlice({
params: system_id ? { system_id } : null,
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
setActiveError: (
state: DeviceState,
Expand Down Expand Up @@ -300,9 +292,7 @@ const deviceSlice = createSlice({
},
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
setZoneError: statusHandlers.setZone.error,
setZoneStart: statusHandlers.setZone.start,
Expand All @@ -317,9 +307,7 @@ const deviceSlice = createSlice({
params: preparePayloadParams(params),
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
unlinkSubnetError: statusHandlers.unlinkSubnet.error,
unlinkSubnetStart: statusHandlers.unlinkSubnet.start,
Expand All @@ -338,9 +326,7 @@ const deviceSlice = createSlice({
params: preparePayloadParams(params),
},
}),
reducer: () => {
// No state changes need to be handled for this action.
},
reducer: () => {},
},
updateInterfaceError: statusHandlers.updateInterface.error,
updateInterfaceStart: statusHandlers.updateInterface.start,
Expand Down
Loading

0 comments on commit b4df79e

Please sign in to comment.