minor fixes

This commit is contained in:
Maximilian Hils 2016-06-15 13:39:56 -07:00
parent 48e372bf98
commit 94e2929b3f
3 changed files with 19 additions and 14 deletions

View File

@ -25,13 +25,13 @@ class Header extends Component {
}
render() {
const { settings, updateLocation, query, selectedFlow, active_menu} = this.props
const { settings, updateLocation, query, selectedFlow, activeMenu} = this.props
let entries = [...Header.entries]
if(selectedFlow)
entries.push(FlowMenu)
const Active = _.find(entries, (e) => e.title == active_menu)
const Active = _.find(entries, (e) => e.title == activeMenu)
return (
<header>
@ -60,7 +60,7 @@ class Header extends Component {
export default connect(
(state) => ({
selectedFlow: state.flows.selected[0],
active_menu: state.ui.active_menu
activeMenu: state.ui.activeMenu
}),
dispatch => bindActionCreators({
setActiveMenu,

View File

@ -2,7 +2,7 @@ import {combineReducers} from 'redux'
import eventLog from './eventLog'
import websocket from './websocket'
import flows from './flows'
import ui from './ui.js'
import ui from './ui'
const rootReducer = combineReducers({
eventLog,

View File

@ -3,23 +3,28 @@ const SET_ACTIVE_MENU = 'SET_ACTIVE_MENU'
const defaultState = {
active_menu: 'Start'
activeMenu: 'Start',
}
export default function reducer(state = defaultState, action) {
switch (action.type) {
case SET_ACTIVE_MENU:
return {
...state,
active_menu: action.active_menu
activeMenu: action.activeMenu
}
case SELECT_FLOW:
let isNewSelection = (action.flowId && !action.currentSelection)
let isSelectAction = action.flowId
if (isNewSelection){
let wasFlowSelected = state.active_menu == 'Flow'
return{
let isNewSelect = (action.flowId && !action.currentSelection)
let isDeselect = (!action.flowId && action.currentSelection)
if(isNewSelect) {
return {
...state,
active_menu: isSelectAction ? 'Flow' : (wasFlowSelected ? 'Start' : state.active_menu)
activeMenu: "Flow"
}
}
if(isDeselect && state.activeMenu === "Flow") {
return {
...state,
activeMenu: "Start"
}
}
return state
@ -28,10 +33,10 @@ export default function reducer(state = defaultState, action) {
}
}
export function setActiveMenu(active_menu) {
export function setActiveMenu(activeMenu) {
return {
type: SET_ACTIVE_MENU,
active_menu
activeMenu
}
}