summaryrefslogtreecommitdiff
path: root/src/reducers
diff options
context:
space:
mode:
Diffstat (limited to 'src/reducers')
-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
5 files changed, 45 insertions, 40 deletions
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) {