blob: 26420e0d697fb45125358e1befade1bb7b215c4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import { SELECT_FLOW } from './flows'
const SET_ACTIVE_MENU = 'SET_ACTIVE_MENU'
const defaultState = {
active_menu: 'Start'
}
export default function reducer(state = defaultState, action) {
switch (action.type) {
case SET_ACTIVE_MENU:
return {
...state,
active_menu: action.active_menu
}
case SELECT_FLOW:
let isNewSelection = (action.flowId && !action.currentSelection)
let isSelectAction = action.flowId
if (isNewSelection){
let wasFlowSelected = state.active_menu == 'Flow'
return{
...state,
active_menu: isSelectAction ? 'Flow' : (wasFlowSelected ? 'Start' : state.active_menu)
}
}
return state
default:
return state
}
}
export function setActiveMenu(active_menu) {
return {
type: SET_ACTIVE_MENU,
active_menu
}
}
|