diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-07 19:27:13 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:58 +0200 |
| commit | 8218c3d3c21bfa7c4f3ee4872722b9b1261576fb (patch) | |
| tree | 16b8d0b8813aed0c846310a3fa4a01bd8ad18c60 /src/actions/topology.js | |
| parent | a7d2ac48224c4226003d67f77143738cc72aa016 (diff) | |
Add machine mode with title and delete options
Diffstat (limited to 'src/actions/topology.js')
| -rw-r--r-- | src/actions/topology.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/actions/topology.js b/src/actions/topology.js index 04d9f102..d5812ece 100644 --- a/src/actions/topology.js +++ b/src/actions/topology.js @@ -22,6 +22,7 @@ export const START_RACK_CONSTRUCTION = "START_RACK_CONSTRUCTION"; export const STOP_RACK_CONSTRUCTION = "STOP_RACK_CONSTRUCTION"; export const ADD_RACK_TO_TILE = "ADD_RACK_TO_TILE"; export const ADD_MACHINE = "ADD_MACHINE"; +export const DELETE_MACHINE = "DELETE_MACHINE"; export function fetchLatestDatacenter() { return (dispatch, getState) => { @@ -249,3 +250,20 @@ export function addMachineSucceeded(machine) { dispatch(addPropToStoreObject("rack", rack.id, {machineIds})); }; } + +export function deleteMachine() { + return { + type: DELETE_MACHINE + }; +} + +export function deleteMachineSucceeded() { + return (dispatch, getState) => { + const {interactionLevel, objects} = getState(); + const rack = objects.rack[objects.tile[interactionLevel.tileId].objectId]; + const machineIds = [...rack.machineIds]; + machineIds[interactionLevel.position - 1] = null; + dispatch(goDownOneInteractionLevel()); + dispatch(addPropToStoreObject("rack", rack.id, {machineIds})); + }; +} |
