summaryrefslogtreecommitdiff
path: root/frontend/src/reducers/current-ids.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-07-10 10:24:31 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:48:01 +0200
commit3b4e27320c479bd6ef48998f448ed070e8bd7511 (patch)
tree35ec6527e8d7a0b4093e18c8cb501c293a18b5eb /frontend/src/reducers/current-ids.js
parentb30906bbe0d5f343b337a80de1b4b70ebf288331 (diff)
parent8aa174e70c01631ae4e00a6d208966fcd77cf972 (diff)
Merge pull request #8 from atlarge-research/feature/portfolios-scenarios-frontend
Portfolios and scenarios on the frontend
Diffstat (limited to 'frontend/src/reducers/current-ids.js')
-rw-r--r--frontend/src/reducers/current-ids.js39
1 files changed, 34 insertions, 5 deletions
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
+ }
+}