Continue move to redux
This commit is contained in:
53
src/redux/reducers/release_version_reducer.js
Normal file
53
src/redux/reducers/release_version_reducer.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import {createReducer} from 'redux-starter-kit';
|
||||
import * as Actions from '../actions/release_version_actions';
|
||||
import * as Constants from '../../constants';
|
||||
|
||||
const versionLookup = Constants.RELEASE_TYPES.map(k=> {
|
||||
return {
|
||||
[k]: ['unavailable']
|
||||
};
|
||||
}).reduce((map, obj) => {
|
||||
return {
|
||||
...map,
|
||||
...obj,
|
||||
};
|
||||
});
|
||||
|
||||
export const releaseVersionReducer = createReducer({
|
||||
LocationsLookup: {},
|
||||
Release: 2,
|
||||
UpgradeAvailable: false,
|
||||
UpgradeDismissed: false,
|
||||
Version: -1,
|
||||
VersionLookup: versionLookup,
|
||||
}, {
|
||||
[Actions.CLEAR_UI_UPGRADE]: state => {
|
||||
return {
|
||||
...state,
|
||||
UpgradeAvailable: false,
|
||||
UpgradeDismissed: false,
|
||||
UpgradeData: null,
|
||||
};
|
||||
},
|
||||
[Actions.SET_ACTIVE_RELEASE]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
Release: action.payload.release,
|
||||
Version: action.payload.version
|
||||
};
|
||||
},
|
||||
[Actions.setDismissUIUpgrade]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
UpgradeDismissed: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.setUIUpgradeData]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
UpgradeAvailable: true,
|
||||
UpgradeData: action.payload,
|
||||
UpgradeDismissed: false,
|
||||
};
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user