aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/components/Header.js
blob: 93ca5154419ecc7586adfbff469bceeaaf37aa4a (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import classnames from 'classnames'
import { toggleEventLogVisibility } from '../ducks/eventLog'
import MainMenu from './Header/MainMenu'
import ViewMenu from './Header/ViewMenu'
import OptionMenu from './Header/OptionMenu'
import FileMenu from './Header/FileMenu'
import FlowMenu from './Header/FlowMenu'
import {setActiveMenu} from '../ducks/ui.js'

class Header extends Component {
    static entries = [MainMenu, ViewMenu, OptionMenu]

    static propTypes = {
        settings: PropTypes.object.isRequired,
    }

    handleClick(active, e) {
        e.preventDefault()
        this.props.setActiveMenu(active.title)
       // this.props.updateLocation(active.route)
       // this.setState({ active })
    }

    render() {
        const { settings, updateLocation, query, selectedFlow, activeMenu} = this.props

        let entries = [...Header.entries]
        if(selectedFlow)
            entries.push(FlowMenu)

        const Active = _.find(entries, (e) => e.title == activeMenu)

        return (
            <header>
                <nav className="nav-tabs nav-tabs-lg">
                    <FileMenu/>
                    {entries.map(Entry => (
                        <a key={Entry.title}
                           href="#"
                           className={classnames({ active: Entry === Active})}
                           onClick={e => this.handleClick(Entry, e)}>
                            {Entry.title}
                        </a>
                    ))}
                </nav>
                <div className="menu">
                    <Active
                        settings={settings}
                        updateLocation={updateLocation}
                        query={query}
                        />
                </div>
            </header>
        )
    }
}
export default connect(
    (state) => ({
        selectedFlow: state.flows.selected[0],
        activeMenu: state.ui.activeMenu
    }),
    {
        setActiveMenu,
    }
)(Header)