summaryrefslogtreecommitdiff
path: root/frontend/src/reducers
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/reducers')
-rw-r--r--frontend/src/reducers/construction-mode.js9
-rw-r--r--frontend/src/reducers/current-ids.js39
-rw-r--r--frontend/src/reducers/index.js6
-rw-r--r--frontend/src/reducers/interaction-level.js6
-rw-r--r--frontend/src/reducers/modals.js8
-rw-r--r--frontend/src/reducers/objects.js3
6 files changed, 54 insertions, 17 deletions
diff --git a/frontend/src/reducers/construction-mode.js b/frontend/src/reducers/construction-mode.js
index b15ac834..257dddd2 100644
--- a/frontend/src/reducers/construction-mode.js
+++ b/frontend/src/reducers/construction-mode.js
@@ -1,5 +1,4 @@
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,
@@ -10,6 +9,8 @@ import {
START_ROOM_EDIT,
} from '../actions/topology/building'
import { DELETE_ROOM, START_RACK_CONSTRUCTION, STOP_RACK_CONSTRUCTION } from '../actions/topology/room'
+import { OPEN_PORTFOLIO_SUCCEEDED } from '../actions/portfolios'
+import { OPEN_SCENARIO_SUCCEEDED } from '../actions/scenarios'
export function currentRoomInConstruction(state = '-1', action) {
switch (action.type) {
@@ -19,7 +20,8 @@ export function currentRoomInConstruction(state = '-1', action) {
return action.roomId
case CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED:
case FINISH_NEW_ROOM_CONSTRUCTION:
- case OPEN_EXPERIMENT_SUCCEEDED:
+ case OPEN_PORTFOLIO_SUCCEEDED:
+ case OPEN_SCENARIO_SUCCEEDED:
case FINISH_ROOM_EDIT:
case SET_CURRENT_TOPOLOGY:
case DELETE_ROOM:
@@ -34,7 +36,8 @@ export function inRackConstructionMode(state = false, action) {
case START_RACK_CONSTRUCTION:
return true
case STOP_RACK_CONSTRUCTION:
- case OPEN_EXPERIMENT_SUCCEEDED:
+ case OPEN_PORTFOLIO_SUCCEEDED:
+ case OPEN_SCENARIO_SUCCEEDED:
case SET_CURRENT_TOPOLOGY:
case GO_DOWN_ONE_INTERACTION_LEVEL:
return false
diff --git a/frontend/src/reducers/current-ids.js b/frontend/src/reducers/current-ids.js
index 0726da6d..9b46aa60 100644
--- a/frontend/src/reducers/current-ids.js
+++ b/frontend/src/reducers/current-ids.js
@@ -1,13 +1,12 @@
-import { OPEN_EXPERIMENT_SUCCEEDED } from '../actions/experiments'
+import { OPEN_PORTFOLIO_SUCCEEDED, SET_CURRENT_PORTFOLIO } from '../actions/portfolios'
import { OPEN_PROJECT_SUCCEEDED } from '../actions/projects'
-import { RESET_CURRENT_TOPOLOGY, SET_CURRENT_TOPOLOGY } from '../actions/topology/building'
+import { SET_CURRENT_TOPOLOGY } from '../actions/topology/building'
+import { OPEN_SCENARIO_SUCCEEDED, SET_CURRENT_SCENARIO } from '../actions/scenarios'
export function currentTopologyId(state = '-1', action) {
switch (action.type) {
case SET_CURRENT_TOPOLOGY:
return action.topologyId
- case RESET_CURRENT_TOPOLOGY:
- return '-1'
default:
return state
}
@@ -17,9 +16,39 @@ export function currentProjectId(state = '-1', action) {
switch (action.type) {
case OPEN_PROJECT_SUCCEEDED:
return action.id
- case OPEN_EXPERIMENT_SUCCEEDED:
+ case OPEN_PORTFOLIO_SUCCEEDED:
+ case OPEN_SCENARIO_SUCCEEDED:
return action.projectId
default:
return state
}
}
+
+export function currentPortfolioId(state = '-1', action) {
+ switch (action.type) {
+ case OPEN_PORTFOLIO_SUCCEEDED:
+ case SET_CURRENT_PORTFOLIO:
+ case SET_CURRENT_SCENARIO:
+ return action.portfolioId
+ case OPEN_SCENARIO_SUCCEEDED:
+ return action.portfolioId
+ case OPEN_PROJECT_SUCCEEDED:
+ case SET_CURRENT_TOPOLOGY:
+ return '-1'
+ default:
+ return state
+ }
+}
+export function currentScenarioId(state = '-1', action) {
+ switch (action.type) {
+ case OPEN_SCENARIO_SUCCEEDED:
+ case SET_CURRENT_SCENARIO:
+ return action.scenarioId
+ case OPEN_PORTFOLIO_SUCCEEDED:
+ case SET_CURRENT_TOPOLOGY:
+ case OPEN_PROJECT_SUCCEEDED:
+ return '-1'
+ default:
+ return state
+ }
+}
diff --git a/frontend/src/reducers/index.js b/frontend/src/reducers/index.js
index 6ca95ec6..787d5a74 100644
--- a/frontend/src/reducers/index.js
+++ b/frontend/src/reducers/index.js
@@ -1,7 +1,7 @@
import { combineReducers } from 'redux'
import { auth } from './auth'
import { construction } from './construction-mode'
-import { currentProjectId, currentTopologyId } from './current-ids'
+import { currentPortfolioId, currentProjectId, currentScenarioId, currentTopologyId } from './current-ids'
import { interactionLevel } from './interaction-level'
import { map } from './map'
import { modals } from './modals'
@@ -11,11 +11,13 @@ import { projectList } from './project-list'
const rootReducer = combineReducers({
objects,
modals,
- projectList: projectList,
+ projectList,
construction,
map,
currentProjectId,
currentTopologyId,
+ currentPortfolioId,
+ currentScenarioId,
interactionLevel,
auth,
})
diff --git a/frontend/src/reducers/interaction-level.js b/frontend/src/reducers/interaction-level.js
index 21aba715..eafcb269 100644
--- a/frontend/src/reducers/interaction-level.js
+++ b/frontend/src/reducers/interaction-level.js
@@ -1,4 +1,4 @@
-import { OPEN_EXPERIMENT_SUCCEEDED } from '../actions/experiments'
+import { OPEN_PORTFOLIO_SUCCEEDED } from '../actions/portfolios'
import {
GO_DOWN_ONE_INTERACTION_LEVEL,
GO_FROM_BUILDING_TO_ROOM,
@@ -7,10 +7,12 @@ import {
} from '../actions/interaction-level'
import { OPEN_PROJECT_SUCCEEDED } from '../actions/projects'
import { SET_CURRENT_TOPOLOGY } from '../actions/topology/building'
+import { OPEN_SCENARIO_SUCCEEDED } from '../actions/scenarios'
export function interactionLevel(state = { mode: 'BUILDING' }, action) {
switch (action.type) {
- case OPEN_EXPERIMENT_SUCCEEDED:
+ case OPEN_PORTFOLIO_SUCCEEDED:
+ case OPEN_SCENARIO_SUCCEEDED:
case OPEN_PROJECT_SUCCEEDED:
case SET_CURRENT_TOPOLOGY:
return {
diff --git a/frontend/src/reducers/modals.js b/frontend/src/reducers/modals.js
index 77927cff..2fd71a5b 100644
--- a/frontend/src/reducers/modals.js
+++ b/frontend/src/reducers/modals.js
@@ -1,6 +1,4 @@
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_PROJECT_MODAL, OPEN_NEW_PROJECT_MODAL } from '../actions/modals/projects'
import {
@@ -17,6 +15,8 @@ import {
OPEN_EDIT_RACK_NAME_MODAL,
OPEN_EDIT_ROOM_NAME_MODAL,
} from '../actions/modals/topology'
+import { CLOSE_NEW_PORTFOLIO_MODAL, OPEN_NEW_PORTFOLIO_MODAL } from '../actions/modals/portfolios'
+import { CLOSE_NEW_SCENARIO_MODAL, OPEN_NEW_SCENARIO_MODAL } from '../actions/modals/scenarios'
function modal(openAction, closeAction) {
return function(state = false, action) {
@@ -24,7 +24,6 @@ function modal(openAction, closeAction) {
case openAction:
return true
case closeAction:
- case OPEN_EXPERIMENT_SUCCEEDED:
return false
default:
return state
@@ -41,5 +40,6 @@ export const modals = combineReducers({
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),
+ newPortfolioModalVisible: modal(OPEN_NEW_PORTFOLIO_MODAL, CLOSE_NEW_PORTFOLIO_MODAL),
+ newScenarioModalVisible: modal(OPEN_NEW_SCENARIO_MODAL, CLOSE_NEW_SCENARIO_MODAL),
})
diff --git a/frontend/src/reducers/objects.js b/frontend/src/reducers/objects.js
index d25eb136..b4db0a6b 100644
--- a/frontend/src/reducers/objects.js
+++ b/frontend/src/reducers/objects.js
@@ -22,7 +22,8 @@ export const objects = combineReducers({
topology: object('topology'),
trace: object('trace'),
scheduler: object('scheduler'),
- experiment: object('experiment'),
+ portfolio: object('portfolio'),
+ scenario: object('scenario'),
})
function object(type, defaultState = {}) {