This repository has been archived on 2025-09-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
repertory-ui/src/redux/reducers/common_reducer.js
2021-08-04 17:17:16 -05:00

58 lines
1.5 KiB
JavaScript

import {createReducer} from '@reduxjs/toolkit';
import {
confirmYesNoAction,
NOTIFY_APPLICATION_BUSY,
notifyRebootRequired,
setAllowMount,
setApplicationReady,
} from '../actions/common_actions';
export const createCommonReducer = (platformInfo, version) => {
return createReducer(
{
AllowMount: false,
AppBusy: false,
AppBusyTransparent: false,
AppPlatform: platformInfo.AppPlatform,
AppReady: false,
DisplayConfirmYesNo: false,
ConfirmTitle: null,
Platform: platformInfo.Platform,
RebootRequired: false,
Version: version,
},
{
[confirmYesNoAction.action_type]: (state, action) => {
return {
...state,
DisplayConfirmYesNo: action.payload.display,
ConfirmTitle:
action.payload.display && action.payload.data ? action.payload.data.title : null,
};
},
[setAllowMount]: (state, action) => {
return {...state, AllowMount: action.payload};
},
[setApplicationReady]: (state, action) => {
return {
...state,
AppReady: action.payload,
};
},
[NOTIFY_APPLICATION_BUSY]: (state, action) => {
return {
...state,
AppBusy: action.payload.busy,
AppBusyTransparent: action.payload.busy && action.payload.transparent,
};
},
[notifyRebootRequired]: (state, action) => {
return {
...state,
RebootRequired: action.payload,
};
},
}
);
};