diff options
Diffstat (limited to 'opendc-web/opendc-web-server/src/main/webui/redux/reducers')
| -rw-r--r-- | opendc-web/opendc-web-server/src/main/webui/redux/reducers/construction-mode.js | 13 | ||||
| -rw-r--r-- | opendc-web/opendc-web-server/src/main/webui/redux/reducers/topology/machine.js | 8 |
2 files changed, 21 insertions, 0 deletions
diff --git a/opendc-web/opendc-web-server/src/main/webui/redux/reducers/construction-mode.js b/opendc-web/opendc-web-server/src/main/webui/redux/reducers/construction-mode.js index d0aac5ae..8520e794 100644 --- a/opendc-web/opendc-web-server/src/main/webui/redux/reducers/construction-mode.js +++ b/opendc-web/opendc-web-server/src/main/webui/redux/reducers/construction-mode.js @@ -37,7 +37,20 @@ export function inRackConstructionMode(state = false, action) { } } +export function currentRackPrefab(state = null, action) { + switch (action.type) { + case START_RACK_CONSTRUCTION: + return action.rackPrefab || null + case STOP_RACK_CONSTRUCTION: + case GO_DOWN_ONE_INTERACTION_LEVEL: + return null + default: + return state + } +} + export const construction = combineReducers({ currentRoomInConstruction, inRackConstructionMode, + currentRackPrefab, }) diff --git a/opendc-web/opendc-web-server/src/main/webui/redux/reducers/topology/machine.js b/opendc-web/opendc-web-server/src/main/webui/redux/reducers/topology/machine.js index 1789257b..5cf38726 100644 --- a/opendc-web/opendc-web-server/src/main/webui/redux/reducers/topology/machine.js +++ b/opendc-web/opendc-web-server/src/main/webui/redux/reducers/topology/machine.js @@ -2,11 +2,19 @@ import produce from 'immer' import { STORE_TOPOLOGY } from '../../actions/topology' import { DELETE_MACHINE, ADD_UNIT, DELETE_UNIT } from '../../actions/topology/machine' import { ADD_MACHINE, DELETE_RACK } from '../../actions/topology/rack' +import { ADD_RACK_TO_TILE } from '../../actions/topology/room' function machine(state = {}, action, { racks }) { switch (action.type) { case STORE_TOPOLOGY: return action.entities.machines || {} + case ADD_RACK_TO_TILE: + return produce(state, (draft) => { + const { entities } = action + if (entities && entities.machines) { + Object.assign(draft, entities.machines) + } + }) case ADD_MACHINE: return produce(state, (draft) => { const { machine } = action |
