58 lines
1.5 KiB
JavaScript
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,
|
|
};
|
|
},
|
|
}
|
|
);
|
|
};
|