import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import classnames from 'classnames'
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/header'

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

    handleClick(active, e) {
        e.preventDefault()
        this.props.setActiveMenu(active.title)
    }

    render() {
        const { selectedFlowId, activeMenu} = this.props

        let entries = [...Header.entries]
        if(selectedFlowId)
            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/>
                </div>
            </header>
        )
    }
}

export default connect(
    state => ({
        selectedFlowId: state.flows.selected[0],
        activeMenu: state.ui.header.activeMenu,
    }),
    {
        setActiveMenu,
    }
)(Header)
a889fda5513'>refs</a><a href='/cgit/xen/xen/log/config/x86_64.mk?h=staging-4.0'>log</a><a class='active' href='/cgit/xen/xen/tree/config/x86_64.mk?h=staging-4.0&amp;id=1883561885f1aded51e1bf475bfaaa889fda5513'>tree</a><a href='/cgit/xen/xen/commit/config/x86_64.mk?h=staging-4.0&amp;id=1883561885f1aded51e1bf475bfaaa889fda5513'>commit</a><a href='/cgit/xen/xen/diff/config/x86_64.mk?h=staging-4.0&amp;id=1883561885f1aded51e1bf475bfaaa889fda5513'>diff</a><a href='/cgit/xen/xen/stats/config/x86_64.mk?h=staging-4.0'>stats</a></td><td class='form'><form class='right' method='get' action='/cgit/xen/xen/log/config/x86_64.mk'>
<input type='hidden' name='h' value='staging-4.0'/><input type='hidden' name='id' value='1883561885f1aded51e1bf475bfaaa889fda5513'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit/xen/xen/tree/?h=staging-4.0&amp;id=1883561885f1aded51e1bf475bfaaa889fda5513'>root</a>/<a href='/cgit/xen/xen/tree/config?h=staging-4.0&amp;id=1883561885f1aded51e1bf475bfaaa889fda5513'>config</a>/<a href='/cgit/xen/xen/tree/config/x86_64.mk?h=staging-4.0&amp;id=1883561885f1aded51e1bf475bfaaa889fda5513'>x86_64.mk</a></div><div class='content'>blob: 6f77053df3c329aa74877aa75ff60d5b801215f5 (<a href='/cgit/xen/xen/plain/config/x86_64.mk?h=staging-4.0&amp;id=1883561885f1aded51e1bf475bfaaa889fda5513'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
<a id='n10' href='#n10'>10</a>
<a id='n11' href='#n11'>11</a>
<a id='n12' href='#n12'>12</a>
<a id='n13' href='#n13'>13</a>
<a id='n14' href='#n14'>14</a>
<a id='n15' href='#n15'>15</a>
<a id='n16' href='#n16'>16</a>
<a id='n17' href='#n17'>17</a>
<a id='n18' href='#n18'>18</a>
<a id='n19' href='#n19'>19</a>
<a id='n20' href='#n20'>20</a>
<a id='n21' href='#n21'>21</a>
<a id='n22' href='#n22'>22</a>
<a id='n23' href='#n23'>23</a>
</pre></td>
<td class='lines'><pre><code>