summaryrefslogtreecommitdiff
path: root/frontend/src/reducers/construction-mode.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-29 15:47:09 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 16:08:41 +0200
commit90fae26aa4bd0e0eb3272ff6e6524060e9004fbb (patch)
treebf6943882f5fa5f3114c01fc571503c79ee1056d /frontend/src/reducers/construction-mode.js
parent7032a007d4431f5a0c4c5e2d3f3bd20462d49950 (diff)
Prepare frontend repository for monorepo
This change prepares the frontend Git repository for the monorepo residing at https://github.com/atlarge-research.com/opendc. To accomodate for this, we move all files into a frontend subdirectory.
Diffstat (limited to 'frontend/src/reducers/construction-mode.js')
-rw-r--r--frontend/src/reducers/construction-mode.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/frontend/src/reducers/construction-mode.js b/frontend/src/reducers/construction-mode.js
new file mode 100644
index 00000000..b5e6e781
--- /dev/null
+++ b/frontend/src/reducers/construction-mode.js
@@ -0,0 +1,50 @@
+import { combineReducers } from "redux";
+import { OPEN_EXPERIMENT_SUCCEEDED } from "../actions/experiments";
+import { GO_DOWN_ONE_INTERACTION_LEVEL } from "../actions/interaction-level";
+import {
+ CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
+ FINISH_NEW_ROOM_CONSTRUCTION,
+ FINISH_ROOM_EDIT,
+ START_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
+ START_ROOM_EDIT
+} from "../actions/topology/building";
+import {
+ DELETE_ROOM,
+ START_RACK_CONSTRUCTION,
+ STOP_RACK_CONSTRUCTION
+} from "../actions/topology/room";
+
+export function currentRoomInConstruction(state = -1, action) {
+ switch (action.type) {
+ case START_NEW_ROOM_CONSTRUCTION_SUCCEEDED:
+ return action.roomId;
+ case START_ROOM_EDIT:
+ return action.roomId;
+ case CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED:
+ case FINISH_NEW_ROOM_CONSTRUCTION:
+ case OPEN_EXPERIMENT_SUCCEEDED:
+ case FINISH_ROOM_EDIT:
+ case DELETE_ROOM:
+ return -1;
+ default:
+ return state;
+ }
+}
+
+export function inRackConstructionMode(state = false, action) {
+ switch (action.type) {
+ case START_RACK_CONSTRUCTION:
+ return true;
+ case STOP_RACK_CONSTRUCTION:
+ case OPEN_EXPERIMENT_SUCCEEDED:
+ case GO_DOWN_ONE_INTERACTION_LEVEL:
+ return false;
+ default:
+ return state;
+ }
+}
+
+export const construction = combineReducers({
+ currentRoomInConstruction,
+ inRackConstructionMode
+});