summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions/topology.js269
-rw-r--r--src/actions/topology/building.js130
-rw-r--r--src/actions/topology/machine.js21
-rw-r--r--src/actions/topology/rack.js53
-rw-r--r--src/actions/topology/room.js73
-rw-r--r--src/containers/map/layers/ObjectHoverLayer.js2
-rw-r--r--src/containers/map/layers/RoomHoverLayer.js2
-rw-r--r--src/containers/modals/DeleteMachineModal.js2
-rw-r--r--src/containers/modals/DeleteRackModal.js2
-rw-r--r--src/containers/modals/DeleteRoomModal.js2
-rw-r--r--src/containers/modals/EditRackNameModal.js2
-rw-r--r--src/containers/modals/EditRoomNameModal.js2
-rw-r--r--src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js2
-rw-r--r--src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js2
-rw-r--r--src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js2
-rw-r--r--src/containers/sidebars/topology/rack/EmptySlotContainer.js2
-rw-r--r--src/containers/sidebars/topology/room/RackConstructionContainer.js2
-rw-r--r--src/containers/simulations/FilterLink.js2
-rw-r--r--src/containers/simulations/VisibleSimulationAuthList.js4
-rw-r--r--src/pages/App.js2
-rw-r--r--src/reducers/construction.js7
-rw-r--r--src/reducers/index.js6
-rw-r--r--src/reducers/simulation-list.js37
-rw-r--r--src/reducers/simulations.js33
-rw-r--r--src/reducers/topology.js2
-rw-r--r--src/sagas/index.js12
-rw-r--r--src/sagas/topology.js12
27 files changed, 346 insertions, 341 deletions
diff --git a/src/actions/topology.js b/src/actions/topology.js
deleted file mode 100644
index d5812ece..00000000
--- a/src/actions/topology.js
+++ /dev/null
@@ -1,269 +0,0 @@
-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";
-export const FETCH_TOPOLOGY_OF_DATACENTER_SUCCEEDED = "FETCH_TOPOLOGY_OF_DATACENTER_SUCCEEDED";
-export const FETCH_LATEST_DATACENTER = "FETCH_LATEST_DATACENTER";
-export const FETCH_LATEST_DATACENTER_SUCCEEDED = "FETCH_LATEST_DATACENTER_SUCCEEDED";
-export const RESET_CURRENT_DATACENTER = "RESET_CURRENT_DATACENTER";
-export const START_NEW_ROOM_CONSTRUCTION = "START_NEW_ROOM_CONSTRUCTION";
-export const START_NEW_ROOM_CONSTRUCTION_SUCCEEDED = "START_NEW_ROOM_CONSTRUCTION_SUCCEEDED";
-export const FINISH_NEW_ROOM_CONSTRUCTION = "FINISH_NEW_ROOM_CONSTRUCTION";
-export const CANCEL_NEW_ROOM_CONSTRUCTION = "CANCEL_NEW_ROOM_CONSTRUCTION";
-export const CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED = "CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED";
-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 EDIT_RACK_NAME = "EDIT_RACK_NAME";
-export const DELETE_RACK = "DELETE_RACK";
-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) => {
- const {currentSimulationId} = getState();
- dispatch({
- type: FETCH_LATEST_DATACENTER,
- currentSimulationId
- });
- };
-}
-
-export function fetchLatestDatacenterSucceeded(datacenterId) {
- return {
- type: FETCH_LATEST_DATACENTER_SUCCEEDED,
- datacenterId
- };
-}
-
-export function resetCurrentDatacenter() {
- return {
- type: RESET_CURRENT_DATACENTER
- };
-}
-
-export function startNewRoomConstruction() {
- return {
- type: START_NEW_ROOM_CONSTRUCTION
- };
-}
-
-export function startNewRoomConstructionSucceeded(roomId) {
- return (dispatch, getState) => {
- const {currentDatacenterId} = getState();
- dispatch(addIdToStoreObjectListProp("datacenter", currentDatacenterId, "roomIds", roomId));
- dispatch({
- type: START_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
- roomId
- });
- };
-}
-
-export function finishNewRoomConstruction() {
- return (dispatch, getState) => {
- const {objects, construction} = getState();
- if (objects.room[construction.currentRoomInConstruction].tileIds.length === 0) {
- dispatch(cancelNewRoomConstruction());
- return;
- }
-
- dispatch({
- type: FINISH_NEW_ROOM_CONSTRUCTION
- });
- };
-}
-
-export function cancelNewRoomConstruction() {
- return {
- type: CANCEL_NEW_ROOM_CONSTRUCTION
- };
-}
-
-export function cancelNewRoomConstructionSucceeded() {
- return (dispatch, getState) => {
- const {currentDatacenterId, construction} = getState();
- dispatch(removeIdFromStoreObjectListProp("datacenter", currentDatacenterId, "roomIds",
- construction.currentRoomInConstruction));
- dispatch({
- type: CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED
- });
- };
-}
-
-export function toggleTileAtLocation(positionX, positionY) {
- return (dispatch, getState) => {
- const {objects, construction} = getState();
-
- const tileIds = objects.room[construction.currentRoomInConstruction].tileIds;
- for (let index in tileIds) {
- if (objects.tile[tileIds[index]].positionX === positionX
- && objects.tile[tileIds[index]].positionY === positionY) {
- dispatch(deleteTile(tileIds[index]));
- return;
- }
- }
- dispatch(addTile(positionX, positionY));
- };
-}
-
-export function addTile(positionX, positionY) {
- return {
- type: ADD_TILE,
- positionX,
- positionY
- };
-}
-
-export function addTileSucceeded(tileId) {
- return (dispatch, getState) => {
- const {construction} = getState();
- dispatch(addIdToStoreObjectListProp("room", construction.currentRoomInConstruction, "tileIds", tileId));
- };
-}
-
-export function deleteTile(tileId) {
- return {
- type: DELETE_TILE,
- tileId
- }
-}
-
-export function deleteTileSucceeded(tileId) {
- return (dispatch, getState) => {
- const {construction} = getState();
- dispatch(removeIdFromStoreObjectListProp("room", construction.currentRoomInConstruction, "tileIds", tileId));
- };
-}
-
-export function editRoomName(name) {
- return {
- type: EDIT_ROOM_NAME,
- name
- };
-}
-
-export function editRoomNameSucceeded(name) {
- return (dispatch, getState) => {
- const {interactionLevel} = getState();
- dispatch(addPropToStoreObject("room", interactionLevel.roomId, {name}));
- };
-}
-
-export function startRackConstruction() {
- return {
- type: START_RACK_CONSTRUCTION
- };
-}
-
-export function stopRackConstruction() {
- return {
- type: STOP_RACK_CONSTRUCTION
- };
-}
-
-export function addRackToTile(positionX, positionY) {
- return (dispatch, getState) => {
- const {objects, interactionLevel} = getState();
- const currentRoom = objects.room[interactionLevel.roomId];
- const tiles = currentRoom.tileIds.map(tileId => objects.tile[tileId]);
- const tile = findTileWithPosition(tiles, positionX, positionY);
-
- if (tile !== null) {
- dispatch({
- type: ADD_RACK_TO_TILE,
- tileId: tile.id
- });
- }
- };
-}
-
-export function addRackToTileSucceeded(tileId, rackId) {
- return dispatch => {
- dispatch(addPropToStoreObject("tile", tileId, {objectType: "RACK"}));
- 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));
- };
-}
-
-export function editRackName(name) {
- return {
- type: EDIT_RACK_NAME,
- name
- };
-}
-
-export function editRackNameSucceeded(name) {
- return (dispatch, getState) => {
- const {objects, interactionLevel} = getState();
- dispatch(addPropToStoreObject("rack", objects.tile[interactionLevel.tileId].objectId, {name}));
- };
-}
-
-export function deleteRack() {
- return {
- type: DELETE_RACK
- };
-}
-
-export function deleteRackSucceeded() {
- return (dispatch, getState) => {
- const {interactionLevel} = getState();
- const currentTileId = interactionLevel.tileId;
- dispatch(goDownOneInteractionLevel());
- dispatch(addPropToStoreObject("tile", currentTileId, {objectType: undefined}));
- dispatch(addPropToStoreObject("tile", currentTileId, {objectId: undefined}));
- };
-}
-
-export function addMachine(position) {
- return {
- type: ADD_MACHINE,
- position
- };
-}
-
-export function addMachineSucceeded(machine) {
- return (dispatch, getState) => {
- const {objects, interactionLevel} = getState();
- const rack = objects.rack[objects.tile[interactionLevel.tileId].objectId];
- const machineIds = [...rack.machineIds];
- machineIds[machine.position - 1] = machine.id;
- 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}));
- };
-}
diff --git a/src/actions/topology/building.js b/src/actions/topology/building.js
new file mode 100644
index 00000000..87abbf5b
--- /dev/null
+++ b/src/actions/topology/building.js
@@ -0,0 +1,130 @@
+import {addIdToStoreObjectListProp, removeIdFromStoreObjectListProp} from "../objects";
+
+export const FETCH_TOPOLOGY_OF_DATACENTER = "FETCH_TOPOLOGY_OF_DATACENTER";
+export const FETCH_TOPOLOGY_OF_DATACENTER_SUCCEEDED = "FETCH_TOPOLOGY_OF_DATACENTER_SUCCEEDED";
+export const FETCH_LATEST_DATACENTER = "FETCH_LATEST_DATACENTER";
+export const FETCH_LATEST_DATACENTER_SUCCEEDED = "FETCH_LATEST_DATACENTER_SUCCEEDED";
+export const RESET_CURRENT_DATACENTER = "RESET_CURRENT_DATACENTER";
+export const START_NEW_ROOM_CONSTRUCTION = "START_NEW_ROOM_CONSTRUCTION";
+export const START_NEW_ROOM_CONSTRUCTION_SUCCEEDED = "START_NEW_ROOM_CONSTRUCTION_SUCCEEDED";
+export const FINISH_NEW_ROOM_CONSTRUCTION = "FINISH_NEW_ROOM_CONSTRUCTION";
+export const CANCEL_NEW_ROOM_CONSTRUCTION = "CANCEL_NEW_ROOM_CONSTRUCTION";
+export const CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED = "CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED";
+export const ADD_TILE = "ADD_TILE";
+export const DELETE_TILE = "DELETE_TILE";
+
+export function fetchLatestDatacenter() {
+ return (dispatch, getState) => {
+ const {currentSimulationId} = getState();
+ dispatch({
+ type: FETCH_LATEST_DATACENTER,
+ currentSimulationId
+ });
+ };
+}
+
+export function fetchLatestDatacenterSucceeded(datacenterId) {
+ return {
+ type: FETCH_LATEST_DATACENTER_SUCCEEDED,
+ datacenterId
+ };
+}
+
+export function resetCurrentDatacenter() {
+ return {
+ type: RESET_CURRENT_DATACENTER
+ };
+}
+
+export function startNewRoomConstruction() {
+ return {
+ type: START_NEW_ROOM_CONSTRUCTION
+ };
+}
+
+export function startNewRoomConstructionSucceeded(roomId) {
+ return (dispatch, getState) => {
+ const {currentDatacenterId} = getState();
+ dispatch(addIdToStoreObjectListProp("datacenter", currentDatacenterId, "roomIds", roomId));
+ dispatch({
+ type: START_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
+ roomId
+ });
+ };
+}
+
+export function finishNewRoomConstruction() {
+ return (dispatch, getState) => {
+ const {objects, construction} = getState();
+ if (objects.room[construction.currentRoomInConstruction].tileIds.length === 0) {
+ dispatch(cancelNewRoomConstruction());
+ return;
+ }
+
+ dispatch({
+ type: FINISH_NEW_ROOM_CONSTRUCTION
+ });
+ };
+}
+
+export function cancelNewRoomConstruction() {
+ return {
+ type: CANCEL_NEW_ROOM_CONSTRUCTION
+ };
+}
+
+export function cancelNewRoomConstructionSucceeded() {
+ return (dispatch, getState) => {
+ const {currentDatacenterId, construction} = getState();
+ dispatch(removeIdFromStoreObjectListProp("datacenter", currentDatacenterId, "roomIds",
+ construction.currentRoomInConstruction));
+ dispatch({
+ type: CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED
+ });
+ };
+}
+
+export function toggleTileAtLocation(positionX, positionY) {
+ return (dispatch, getState) => {
+ const {objects, construction} = getState();
+
+ const tileIds = objects.room[construction.currentRoomInConstruction].tileIds;
+ for (let index in tileIds) {
+ if (objects.tile[tileIds[index]].positionX === positionX
+ && objects.tile[tileIds[index]].positionY === positionY) {
+ dispatch(deleteTile(tileIds[index]));
+ return;
+ }
+ }
+ dispatch(addTile(positionX, positionY));
+ };
+}
+
+export function addTile(positionX, positionY) {
+ return {
+ type: ADD_TILE,
+ positionX,
+ positionY
+ };
+}
+
+export function addTileSucceeded(tileId) {
+ return (dispatch, getState) => {
+ const {construction} = getState();
+ dispatch(addIdToStoreObjectListProp("room", construction.currentRoomInConstruction, "tileIds", tileId));
+ };
+}
+
+export function deleteTile(tileId) {
+ return {
+ type: DELETE_TILE,
+ tileId
+ }
+}
+
+export function deleteTileSucceeded(tileId) {
+ return (dispatch, getState) => {
+ const {construction} = getState();
+ dispatch(removeIdFromStoreObjectListProp("room", construction.currentRoomInConstruction, "tileIds", tileId));
+ };
+}
diff --git a/src/actions/topology/machine.js b/src/actions/topology/machine.js
new file mode 100644
index 00000000..af258a6f
--- /dev/null
+++ b/src/actions/topology/machine.js
@@ -0,0 +1,21 @@
+import {goDownOneInteractionLevel} from "../interaction-level";
+import {addPropToStoreObject} from "../objects";
+
+export const DELETE_MACHINE = "DELETE_MACHINE";
+
+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}));
+ };
+}
diff --git a/src/actions/topology/rack.js b/src/actions/topology/rack.js
new file mode 100644
index 00000000..cb6ec387
--- /dev/null
+++ b/src/actions/topology/rack.js
@@ -0,0 +1,53 @@
+import {goDownOneInteractionLevel} from "../interaction-level";
+import {addPropToStoreObject} from "../objects";
+
+export const EDIT_RACK_NAME = "EDIT_RACK_NAME";
+export const DELETE_RACK = "DELETE_RACK";
+export const ADD_MACHINE = "ADD_MACHINE";
+
+export function editRackName(name) {
+ return {
+ type: EDIT_RACK_NAME,
+ name
+ };
+}
+
+export function editRackNameSucceeded(name) {
+ return (dispatch, getState) => {
+ const {objects, interactionLevel} = getState();
+ dispatch(addPropToStoreObject("rack", objects.tile[interactionLevel.tileId].objectId, {name}));
+ };
+}
+
+export function deleteRack() {
+ return {
+ type: DELETE_RACK
+ };
+}
+
+export function deleteRackSucceeded() {
+ return (dispatch, getState) => {
+ const {interactionLevel} = getState();
+ const currentTileId = interactionLevel.tileId;
+ dispatch(goDownOneInteractionLevel());
+ dispatch(addPropToStoreObject("tile", currentTileId, {objectType: undefined}));
+ dispatch(addPropToStoreObject("tile", currentTileId, {objectId: undefined}));
+ };
+}
+
+export function addMachine(position) {
+ return {
+ type: ADD_MACHINE,
+ position
+ };
+}
+
+export function addMachineSucceeded(machine) {
+ return (dispatch, getState) => {
+ const {objects, interactionLevel} = getState();
+ const rack = objects.rack[objects.tile[interactionLevel.tileId].objectId];
+ const machineIds = [...rack.machineIds];
+ machineIds[machine.position - 1] = machine.id;
+ dispatch(addPropToStoreObject("rack", rack.id, {machineIds}));
+ };
+}
diff --git a/src/actions/topology/room.js b/src/actions/topology/room.js
new file mode 100644
index 00000000..12133330
--- /dev/null
+++ b/src/actions/topology/room.js
@@ -0,0 +1,73 @@
+import {findTileWithPosition} from "../../util/tile-calculations";
+import {goDownOneInteractionLevel} from "../interaction-level";
+import {addPropToStoreObject, removeIdFromStoreObjectListProp} from "../objects";
+
+export const EDIT_ROOM_NAME = "EDIT_ROOM_NAME";
+export const DELETE_ROOM = "DELETE_ROOM";
+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 function editRoomName(name) {
+ return {
+ type: EDIT_ROOM_NAME,
+ name
+ };
+}
+
+export function editRoomNameSucceeded(name) {
+ return (dispatch, getState) => {
+ const {interactionLevel} = getState();
+ dispatch(addPropToStoreObject("room", interactionLevel.roomId, {name}));
+ };
+}
+
+export function startRackConstruction() {
+ return {
+ type: START_RACK_CONSTRUCTION
+ };
+}
+
+export function stopRackConstruction() {
+ return {
+ type: STOP_RACK_CONSTRUCTION
+ };
+}
+
+export function addRackToTile(positionX, positionY) {
+ return (dispatch, getState) => {
+ const {objects, interactionLevel} = getState();
+ const currentRoom = objects.room[interactionLevel.roomId];
+ const tiles = currentRoom.tileIds.map(tileId => objects.tile[tileId]);
+ const tile = findTileWithPosition(tiles, positionX, positionY);
+
+ if (tile !== null) {
+ dispatch({
+ type: ADD_RACK_TO_TILE,
+ tileId: tile.id
+ });
+ }
+ };
+}
+
+export function addRackToTileSucceeded(tileId, rackId) {
+ return dispatch => {
+ dispatch(addPropToStoreObject("tile", tileId, {objectType: "RACK"}));
+ 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));
+ };
+}
diff --git a/src/containers/map/layers/ObjectHoverLayer.js b/src/containers/map/layers/ObjectHoverLayer.js
index 138daa2c..d0cc35fd 100644
--- a/src/containers/map/layers/ObjectHoverLayer.js
+++ b/src/containers/map/layers/ObjectHoverLayer.js
@@ -1,5 +1,5 @@
import {connect} from "react-redux";
-import {addRackToTile} from "../../../actions/topology";
+import {addRackToTile} from "../../../actions/topology/room";
import ObjectHoverLayerComponent from "../../../components/map/layers/ObjectHoverLayerComponent";
import {findTileWithPosition} from "../../../util/tile-calculations";
diff --git a/src/containers/map/layers/RoomHoverLayer.js b/src/containers/map/layers/RoomHoverLayer.js
index 188ee51a..23f590d5 100644
--- a/src/containers/map/layers/RoomHoverLayer.js
+++ b/src/containers/map/layers/RoomHoverLayer.js
@@ -1,5 +1,5 @@
import {connect} from "react-redux";
-import {toggleTileAtLocation} from "../../../actions/topology";
+import {toggleTileAtLocation} from "../../../actions/topology/building";
import RoomHoverLayerComponent from "../../../components/map/layers/RoomHoverLayerComponent";
import {
deriveValidNextTilePositions,
diff --git a/src/containers/modals/DeleteMachineModal.js b/src/containers/modals/DeleteMachineModal.js
index aeb42024..c2b658d9 100644
--- a/src/containers/modals/DeleteMachineModal.js
+++ b/src/containers/modals/DeleteMachineModal.js
@@ -1,7 +1,7 @@
import React from "react";
import {connect} from "react-redux";
import {closeDeleteMachineModal} from "../../actions/modals/topology";
-import {deleteMachine} from "../../actions/topology";
+import {deleteMachine} from "../../actions/topology/machine";
import ConfirmationModal from "../../components/modals/ConfirmationModal";
const DeleteMachineModalComponent = ({visible, callback}) => (
diff --git a/src/containers/modals/DeleteRackModal.js b/src/containers/modals/DeleteRackModal.js
index 00dd036c..6515ab96 100644
--- a/src/containers/modals/DeleteRackModal.js
+++ b/src/containers/modals/DeleteRackModal.js
@@ -1,7 +1,7 @@
import React from "react";
import {connect} from "react-redux";
import {closeDeleteRackModal} from "../../actions/modals/topology";
-import {deleteRack} from "../../actions/topology";
+import {deleteRack} from "../../actions/topology/rack";
import ConfirmationModal from "../../components/modals/ConfirmationModal";
const DeleteRackModalComponent = ({visible, callback}) => (
diff --git a/src/containers/modals/DeleteRoomModal.js b/src/containers/modals/DeleteRoomModal.js
index 92684385..a32c9ca1 100644
--- a/src/containers/modals/DeleteRoomModal.js
+++ b/src/containers/modals/DeleteRoomModal.js
@@ -1,7 +1,7 @@
import React from "react";
import {connect} from "react-redux";
import {closeDeleteRoomModal} from "../../actions/modals/topology";
-import {deleteRoom} from "../../actions/topology";
+import {deleteRoom} from "../../actions/topology/room";
import ConfirmationModal from "../../components/modals/ConfirmationModal";
const DeleteRoomModalComponent = ({visible, callback}) => (
diff --git a/src/containers/modals/EditRackNameModal.js b/src/containers/modals/EditRackNameModal.js
index e793f146..6f638bbc 100644
--- a/src/containers/modals/EditRackNameModal.js
+++ b/src/containers/modals/EditRackNameModal.js
@@ -1,7 +1,7 @@
import React from "react";
import {connect} from "react-redux";
import {closeEditRackNameModal} from "../../actions/modals/topology";
-import {editRackName} from "../../actions/topology";
+import {editRackName} from "../../actions/topology/rack";
import TextInputModal from "../../components/modals/TextInputModal";
const EditRackNameModalComponent = ({visible, previousName, callback}) => (
diff --git a/src/containers/modals/EditRoomNameModal.js b/src/containers/modals/EditRoomNameModal.js
index 649ffeda..be6230d0 100644
--- a/src/containers/modals/EditRoomNameModal.js
+++ b/src/containers/modals/EditRoomNameModal.js
@@ -1,7 +1,7 @@
import React from "react";
import {connect} from "react-redux";
import {closeEditRoomNameModal} from "../../actions/modals/topology";
-import {editRoomName} from "../../actions/topology";
+import {editRoomName} from "../../actions/topology/room";
import TextInputModal from "../../components/modals/TextInputModal";
const EditRoomNameModalComponent = ({visible, previousName, callback}) => (
diff --git a/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js b/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js
index 6061da96..399c7a0d 100644
--- a/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js
+++ b/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js
@@ -1,5 +1,5 @@
import {connect} from "react-redux";
-import {cancelNewRoomConstruction} from "../../../../actions/topology";
+import {cancelNewRoomConstruction} from "../../../../actions/topology/building";
import CancelNewRoomConstructionComponent from "../../../../components/sidebars/topology/building/CancelNewRoomConstructionComponent";
const mapDispatchToProps = dispatch => {
diff --git a/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js b/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js
index ca34dcc3..8fc192e0 100644
--- a/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js
+++ b/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js
@@ -1,5 +1,5 @@
import {connect} from "react-redux";
-import {finishNewRoomConstruction} from "../../../../actions/topology";
+import {finishNewRoomConstruction} from "../../../../actions/topology/building";
import FinishNewRoomConstructionComponent from "../../../../components/sidebars/topology/building/FinishNewRoomConstructionComponent";
const mapDispatchToProps = dispatch => {
diff --git a/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js b/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js
index f26eb5d4..c2c9808a 100644
--- a/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js
+++ b/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js
@@ -1,5 +1,5 @@
import {connect} from "react-redux";
-import {startNewRoomConstruction} from "../../../../actions/topology";
+import {startNewRoomConstruction} from "../../../../actions/topology/building";
import StartNewRoomConstructionComponent from "../../../../components/sidebars/topology/building/StartNewRoomConstructionComponent";
const mapDispatchToProps = dispatch => {
diff --git a/src/containers/sidebars/topology/rack/EmptySlotContainer.js b/src/containers/sidebars/topology/rack/EmptySlotContainer.js
index 01ec6529..97abf473 100644
--- a/src/containers/sidebars/topology/rack/EmptySlotContainer.js
+++ b/src/containers/sidebars/topology/rack/EmptySlotContainer.js
@@ -1,5 +1,5 @@
import {connect} from "react-redux";
-import {addMachine} from "../../../../actions/topology";
+import {addMachine} from "../../../../actions/topology/rack";
import EmptySlotComponent from "../../../../components/sidebars/topology/rack/EmptySlotComponent";
const mapDispatchToProps = (dispatch, ownProps) => {
diff --git a/src/containers/sidebars/topology/room/RackConstructionContainer.js b/src/containers/sidebars/topology/room/RackConstructionContainer.js
index 47ca43fc..0c539c75 100644
--- a/src/containers/sidebars/topology/room/RackConstructionContainer.js
+++ b/src/containers/sidebars/topology/room/RackConstructionContainer.js
@@ -1,5 +1,5 @@
import {connect} from "react-redux";
-import {startRackConstruction, stopRackConstruction} from "../../../../actions/topology";
+import {startRackConstruction, stopRackConstruction} from "../../../../actions/topology/room";
import RackConstructionComponent from "../../../../components/sidebars/topology/room/RackConstructionComponent";
const mapStateToProps = state => {
diff --git a/src/containers/simulations/FilterLink.js b/src/containers/simulations/FilterLink.js
index dff01ab2..00d8f722 100644
--- a/src/containers/simulations/FilterLink.js
+++ b/src/containers/simulations/FilterLink.js
@@ -4,7 +4,7 @@ import FilterButton from "../../components/simulations/FilterButton";
const mapStateToProps = (state, ownProps) => {
return {
- active: state.authVisibilityFilter === ownProps.filter
+ active: state.simulationList.authVisibilityFilter === ownProps.filter
};
};
diff --git a/src/containers/simulations/VisibleSimulationAuthList.js b/src/containers/simulations/VisibleSimulationAuthList.js
index 2a676e73..578ae303 100644
--- a/src/containers/simulations/VisibleSimulationAuthList.js
+++ b/src/containers/simulations/VisibleSimulationAuthList.js
@@ -16,12 +16,12 @@ const getVisibleSimulationAuths = (simulationAuths, filter) => {
};
const mapStateToProps = state => {
- const denormalizedAuthorizations = state.authorizationsOfCurrentUser.map(authorizationIds =>
+ const denormalizedAuthorizations = state.simulationList.authorizationsOfCurrentUser.map(authorizationIds =>
denormalize(state, "authorization", authorizationIds)
);
return {
- authorizations: getVisibleSimulationAuths(denormalizedAuthorizations, state.authVisibilityFilter)
+ authorizations: getVisibleSimulationAuths(denormalizedAuthorizations, state.simulationList.authVisibilityFilter)
};
};
diff --git a/src/pages/App.js b/src/pages/App.js
index c8e22775..fc38b92d 100644
--- a/src/pages/App.js
+++ b/src/pages/App.js
@@ -3,7 +3,7 @@ import React from 'react';
import {connect} from "react-redux";
import {ShortcutManager} from "react-shortcuts";
import {openSimulationSucceeded} from "../actions/simulations";
-import {fetchLatestDatacenter, resetCurrentDatacenter} from "../actions/topology";
+import {fetchLatestDatacenter, resetCurrentDatacenter} from "../actions/topology/building";
import MapStage from "../components/map/MapStage";
import AppNavbar from "../components/navigation/AppNavbar";
import DeleteMachineModal from "../containers/modals/DeleteMachineModal";
diff --git a/src/reducers/construction.js b/src/reducers/construction.js
index 772135ff..3e0b7542 100644
--- a/src/reducers/construction.js
+++ b/src/reducers/construction.js
@@ -2,10 +2,9 @@ import {combineReducers} from "redux";
import {
CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
FINISH_NEW_ROOM_CONSTRUCTION,
- START_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
- START_RACK_CONSTRUCTION,
- STOP_RACK_CONSTRUCTION
-} from "../actions/topology";
+ START_NEW_ROOM_CONSTRUCTION_SUCCEEDED
+} from "../actions/topology/building";
+import {START_RACK_CONSTRUCTION, STOP_RACK_CONSTRUCTION} from "../actions/topology/room";
export function currentRoomInConstruction(state = -1, action) {
switch (action.type) {
diff --git a/src/reducers/index.js b/src/reducers/index.js
index 2dc6b8af..f1f51337 100644
--- a/src/reducers/index.js
+++ b/src/reducers/index.js
@@ -4,15 +4,15 @@ import {construction} from "./construction";
import {interactionLevel} from "./interaction-level";
import {modals} from "./modals";
import {objects} from "./objects";
-import {authorizationsOfCurrentUser, authVisibilityFilter, currentSimulationId} from "./simulations";
+import {simulationList} from "./simulation-list";
+import {currentSimulationId} from "./simulations";
import {currentDatacenterId} from "./topology";
const rootReducer = combineReducers({
auth,
objects,
modals,
- authorizationsOfCurrentUser,
- authVisibilityFilter,
+ simulationList,
currentSimulationId,
currentDatacenterId,
interactionLevel,
diff --git a/src/reducers/simulation-list.js b/src/reducers/simulation-list.js
new file mode 100644
index 00000000..86386093
--- /dev/null
+++ b/src/reducers/simulation-list.js
@@ -0,0 +1,37 @@
+import {combineReducers} from "redux";
+import {
+ ADD_SIMULATION_SUCCEEDED,
+ DELETE_SIMULATION_SUCCEEDED,
+ SET_AUTH_VISIBILITY_FILTER
+} from "../actions/simulations";
+import {FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED} from "../actions/users";
+
+export function authorizationsOfCurrentUser(state = [], action) {
+ switch (action.type) {
+ case FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED:
+ return action.authorizationsOfCurrentUser;
+ case ADD_SIMULATION_SUCCEEDED:
+ return [
+ ...state,
+ action.authorization
+ ];
+ case DELETE_SIMULATION_SUCCEEDED:
+ return state.filter(authorization => authorization[1] !== action.id);
+ default:
+ return state;
+ }
+}
+
+export function authVisibilityFilter(state = "SHOW_ALL", action) {
+ switch (action.type) {
+ case SET_AUTH_VISIBILITY_FILTER:
+ return action.filter;
+ default:
+ return state;
+ }
+}
+
+export const simulationList = combineReducers({
+ authorizationsOfCurrentUser,
+ authVisibilityFilter,
+});
diff --git a/src/reducers/simulations.js b/src/reducers/simulations.js
index 9bca7740..e15c2d21 100644
--- a/src/reducers/simulations.js
+++ b/src/reducers/simulations.js
@@ -1,35 +1,4 @@
-import {
- ADD_SIMULATION_SUCCEEDED,
- DELETE_SIMULATION_SUCCEEDED,
- OPEN_SIMULATION_SUCCEEDED,
- SET_AUTH_VISIBILITY_FILTER
-} from "../actions/simulations";
-import {FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED} from "../actions/users";
-
-export function authorizationsOfCurrentUser(state = [], action) {
- switch (action.type) {
- case FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED:
- return action.authorizationsOfCurrentUser;
- case ADD_SIMULATION_SUCCEEDED:
- return [
- ...state,
- action.authorization
- ];
- case DELETE_SIMULATION_SUCCEEDED:
- return state.filter(authorization => authorization[1] !== action.id);
- default:
- return state;
- }
-}
-
-export function authVisibilityFilter(state = "SHOW_ALL", action) {
- switch (action.type) {
- case SET_AUTH_VISIBILITY_FILTER:
- return action.filter;
- default:
- return state;
- }
-}
+import {OPEN_SIMULATION_SUCCEEDED} from "../actions/simulations";
export function currentSimulationId(state = -1, action) {
switch (action.type) {
diff --git a/src/reducers/topology.js b/src/reducers/topology.js
index e0236e0c..f98b50e7 100644
--- a/src/reducers/topology.js
+++ b/src/reducers/topology.js
@@ -1,4 +1,4 @@
-import {FETCH_LATEST_DATACENTER_SUCCEEDED, RESET_CURRENT_DATACENTER} from "../actions/topology";
+import {FETCH_LATEST_DATACENTER_SUCCEEDED, RESET_CURRENT_DATACENTER} from "../actions/topology/building";
export function currentDatacenterId(state = -1, action) {
switch (action.type) {
diff --git a/src/sagas/index.js b/src/sagas/index.js
index 91b8a024..a064de33 100644
--- a/src/sagas/index.js
+++ b/src/sagas/index.js
@@ -2,19 +2,15 @@ import {takeEvery} from "redux-saga/effects";
import {LOG_IN} from "../actions/auth";
import {ADD_SIMULATION, DELETE_SIMULATION} from "../actions/simulations";
import {
- ADD_MACHINE,
- ADD_RACK_TO_TILE,
ADD_TILE,
CANCEL_NEW_ROOM_CONSTRUCTION,
- DELETE_MACHINE,
- DELETE_RACK,
- DELETE_ROOM,
DELETE_TILE,
- EDIT_RACK_NAME,
- EDIT_ROOM_NAME,
FETCH_LATEST_DATACENTER,
START_NEW_ROOM_CONSTRUCTION
-} from "../actions/topology";
+} from "../actions/topology/building";
+import {DELETE_MACHINE} from "../actions/topology/machine";
+import {ADD_MACHINE, DELETE_RACK, EDIT_RACK_NAME} from "../actions/topology/rack";
+import {ADD_RACK_TO_TILE, DELETE_ROOM, EDIT_ROOM_NAME} from "../actions/topology/room";
import {DELETE_CURRENT_USER, FETCH_AUTHORIZATIONS_OF_CURRENT_USER} from "../actions/users";
import {onDeleteCurrentUser} from "./profile";
import {onSimulationAdd, onSimulationDelete} from "./simulations";
diff --git a/src/sagas/topology.js b/src/sagas/topology.js
index 05bebc6c..9eab4368 100644
--- a/src/sagas/topology.js
+++ b/src/sagas/topology.js
@@ -1,19 +1,15 @@
import {call, put, select} from "redux-saga/effects";
import {addPropToStoreObject, addToStore} from "../actions/objects";
import {
- addMachineSucceeded,
- addRackToTileSucceeded,
addTileSucceeded,
cancelNewRoomConstructionSucceeded,
- deleteMachineSucceeded,
- deleteRackSucceeded,
- deleteRoomSucceeded,
deleteTileSucceeded,
- editRackNameSucceeded,
- editRoomNameSucceeded,
fetchLatestDatacenterSucceeded,
startNewRoomConstructionSucceeded
-} from "../actions/topology";
+} from "../actions/topology/building";
+import {deleteMachineSucceeded} from "../actions/topology/machine";
+import {addMachineSucceeded, deleteRackSucceeded, editRackNameSucceeded} from "../actions/topology/rack";
+import {addRackToTileSucceeded, deleteRoomSucceeded, editRoomNameSucceeded} from "../actions/topology/room";
import {addRoomToDatacenter} from "../api/routes/datacenters";
import {addTileToRoom, deleteRoom, updateRoom} from "../api/routes/rooms";
import {