summaryrefslogtreecommitdiff
path: root/frontend/src/reducers/modals.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/modals.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/modals.js')
-rw-r--r--frontend/src/reducers/modals.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/frontend/src/reducers/modals.js b/frontend/src/reducers/modals.js
new file mode 100644
index 00000000..78527feb
--- /dev/null
+++ b/frontend/src/reducers/modals.js
@@ -0,0 +1,75 @@
+import { combineReducers } from "redux";
+import { OPEN_EXPERIMENT_SUCCEEDED } from "../actions/experiments";
+import {
+ CLOSE_NEW_EXPERIMENT_MODAL,
+ OPEN_NEW_EXPERIMENT_MODAL
+} from "../actions/modals/experiments";
+import {
+ CLOSE_DELETE_PROFILE_MODAL,
+ OPEN_DELETE_PROFILE_MODAL
+} from "../actions/modals/profile";
+import {
+ CLOSE_NEW_SIMULATION_MODAL,
+ OPEN_NEW_SIMULATION_MODAL
+} from "../actions/modals/simulations";
+import {
+ CLOSE_DELETE_MACHINE_MODAL,
+ CLOSE_DELETE_RACK_MODAL,
+ CLOSE_DELETE_ROOM_MODAL,
+ CLOSE_EDIT_RACK_NAME_MODAL,
+ CLOSE_EDIT_ROOM_NAME_MODAL,
+ OPEN_DELETE_MACHINE_MODAL,
+ OPEN_DELETE_RACK_MODAL,
+ OPEN_DELETE_ROOM_MODAL,
+ OPEN_EDIT_RACK_NAME_MODAL,
+ OPEN_EDIT_ROOM_NAME_MODAL
+} from "../actions/modals/topology";
+
+function modal(openAction, closeAction) {
+ return function(state = false, action) {
+ switch (action.type) {
+ case openAction:
+ return true;
+ case closeAction:
+ case OPEN_EXPERIMENT_SUCCEEDED:
+ return false;
+ default:
+ return state;
+ }
+ };
+}
+
+export const modals = combineReducers({
+ newSimulationModalVisible: modal(
+ OPEN_NEW_SIMULATION_MODAL,
+ CLOSE_NEW_SIMULATION_MODAL
+ ),
+ deleteProfileModalVisible: modal(
+ OPEN_DELETE_PROFILE_MODAL,
+ CLOSE_DELETE_PROFILE_MODAL
+ ),
+ editRoomNameModalVisible: modal(
+ OPEN_EDIT_ROOM_NAME_MODAL,
+ CLOSE_EDIT_ROOM_NAME_MODAL
+ ),
+ deleteRoomModalVisible: modal(
+ OPEN_DELETE_ROOM_MODAL,
+ CLOSE_DELETE_ROOM_MODAL
+ ),
+ editRackNameModalVisible: modal(
+ OPEN_EDIT_RACK_NAME_MODAL,
+ CLOSE_EDIT_RACK_NAME_MODAL
+ ),
+ deleteRackModalVisible: modal(
+ OPEN_DELETE_RACK_MODAL,
+ CLOSE_DELETE_RACK_MODAL
+ ),
+ deleteMachineModalVisible: modal(
+ OPEN_DELETE_MACHINE_MODAL,
+ CLOSE_DELETE_MACHINE_MODAL
+ ),
+ newExperimentModalVisible: modal(
+ OPEN_NEW_EXPERIMENT_MODAL,
+ CLOSE_NEW_EXPERIMENT_MODAL
+ )
+});