diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-06 22:07:16 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:57 +0200 |
| commit | d5a92d3006561fd631279b68b23a1f8075b28bb8 (patch) | |
| tree | 39797ed1e314e5e3cd8521239141af1334f18ec5 /src/actions | |
| parent | 02eafd26b8841ed5896ab83672aba13d569ea63d (diff) | |
Add a button to delete the currently viewed room
Diffstat (limited to 'src/actions')
| -rw-r--r-- | src/actions/modals/topology.js | 14 | ||||
| -rw-r--r-- | src/actions/topology.js | 17 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/actions/modals/topology.js b/src/actions/modals/topology.js index 5e3fc803..ded8771a 100644 --- a/src/actions/modals/topology.js +++ b/src/actions/modals/topology.js @@ -1,5 +1,7 @@ export const OPEN_EDIT_ROOM_NAME_MODAL = "OPEN_EDIT_ROOM_NAME_MODAL"; export const CLOSE_EDIT_ROOM_NAME_MODAL = "CLOSE_EDIT_ROOM_NAME_MODAL"; +export const OPEN_DELETE_ROOM_MODAL = "OPEN_DELETE_ROOM_MODAL"; +export const CLOSE_DELETE_ROOM_MODAL = "CLOSE_DELETE_ROOM_MODAL"; export function openEditRoomNameModal() { return { @@ -12,3 +14,15 @@ export function closeEditRoomNameModal() { type: CLOSE_EDIT_ROOM_NAME_MODAL }; } + +export function openDeleteRoomModal() { + return { + type: OPEN_DELETE_ROOM_MODAL + }; +} + +export function closeDeleteRoomModal() { + return { + type: CLOSE_DELETE_ROOM_MODAL + }; +} diff --git a/src/actions/topology.js b/src/actions/topology.js index 1f111f06..ec614c1c 100644 --- a/src/actions/topology.js +++ b/src/actions/topology.js @@ -1,4 +1,5 @@ import {findTileWithPosition} from "../util/tile-calculations"; +import {goDownOneInteractionLevel} from "./interaction-level"; import {addIdToStoreObjectListProp, addPropToStoreObject, removeIdFromStoreObjectListProp} from "./objects"; export const FETCH_TOPOLOGY_OF_DATACENTER = "FETCH_TOPOLOGY_OF_DATACENTER"; @@ -14,6 +15,7 @@ export const CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED = "CANCEL_NEW_ROOM_CONSTRUCT export const ADD_TILE = "ADD_TILE"; export const DELETE_TILE = "DELETE_TILE"; export const EDIT_ROOM_NAME = "EDIT_ROOM_NAME"; +export const DELETE_ROOM = "DELETE_ROOM"; export const START_OBJECT_CONSTRUCTION = "START_OBJECT_CONSTRUCTION"; export const STOP_OBJECT_CONSTRUCTION = "STOP_OBJECT_CONSTRUCTION"; export const ADD_RACK_TO_TILE = "ADD_RACK_TO_TILE"; @@ -183,3 +185,18 @@ export function addRackToTileSucceeded(tileId, rackId) { dispatch(addPropToStoreObject("tile", tileId, {objectId: rackId})); }; } + +export function deleteRoom() { + return { + type: DELETE_ROOM + }; +} + +export function deleteRoomSucceeded() { + return (dispatch, getState) => { + const {currentDatacenterId, interactionLevel} = getState(); + const currentRoomId = interactionLevel.roomId; + dispatch(goDownOneInteractionLevel()); + dispatch(removeIdFromStoreObjectListProp("datacenter", currentDatacenterId, "roomIds", currentRoomId)); + }; +} |
