diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-06-15 13:40:03 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-06-15 13:40:03 -0700 |
commit | c7a891b652f4f85877c4dc8ee04fcd45d9e20a74 (patch) | |
tree | f80bdafc25555b459bd618ff20273b6b8eddc627 /web/src/js/ducks/ui.js | |
parent | 7de5d7b2984db3c835d3ef2ec3f81ba26a4e458a (diff) | |
parent | 94e2929b3fd6dc335d1c787167956df18f05494e (diff) | |
download | mitmproxy-c7a891b652f4f85877c4dc8ee04fcd45d9e20a74.tar.gz mitmproxy-c7a891b652f4f85877c4dc8ee04fcd45d9e20a74.tar.bz2 mitmproxy-c7a891b652f4f85877c4dc8ee04fcd45d9e20a74.zip |
Merge branch 'add_flow_to_options'
Diffstat (limited to 'web/src/js/ducks/ui.js')
-rw-r--r-- | web/src/js/ducks/ui.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/web/src/js/ducks/ui.js b/web/src/js/ducks/ui.js new file mode 100644 index 00000000..28a13ea4 --- /dev/null +++ b/web/src/js/ducks/ui.js @@ -0,0 +1,42 @@ +import { SELECT_FLOW } from './flows' +const SET_ACTIVE_MENU = 'SET_ACTIVE_MENU' + + +const defaultState = { + activeMenu: 'Start', +} +export default function reducer(state = defaultState, action) { + switch (action.type) { + case SET_ACTIVE_MENU: + return { + ...state, + activeMenu: action.activeMenu + } + case SELECT_FLOW: + let isNewSelect = (action.flowId && !action.currentSelection) + let isDeselect = (!action.flowId && action.currentSelection) + if(isNewSelect) { + return { + ...state, + activeMenu: "Flow" + } + } + if(isDeselect && state.activeMenu === "Flow") { + return { + ...state, + activeMenu: "Start" + } + } + return state + default: + return state + } +} + +export function setActiveMenu(activeMenu) { + return { + type: SET_ACTIVE_MENU, + activeMenu + } +} + |