'use strict'; import React from 'react'; import { Link } from 'react-router'; import history from '../history'; import Nav from 'react-bootstrap/lib/Nav'; import Navbar from 'react-bootstrap/lib/Navbar'; import CollapsibleNav from 'react-bootstrap/lib/CollapsibleNav'; import DropdownButton from 'react-bootstrap/lib/DropdownButton'; import MenuItem from 'react-bootstrap/lib/MenuItem'; import NavItem from 'react-bootstrap/lib/NavItem'; import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; import AclProxy from './acl_proxy'; import EventActions from '../actions/event_actions'; import UserActions from '../actions/user_actions'; import UserStore from '../stores/user_store'; import WhitelabelActions from '../actions/whitelabel_actions'; import WhitelabelStore from '../stores/whitelabel_store'; import HeaderNotifications from './header_notification'; import HeaderNotificationDebug from './header_notification_debug'; import NavRoutesLinks from './nav_routes_links'; import { mergeOptions } from '../utils/general_utils'; import { getLangText } from '../utils/lang_utils'; import { constructHead } from '../utils/dom_utils'; let Header = React.createClass({ propTypes: { routes: React.PropTypes.arrayOf(React.PropTypes.object) }, getInitialState() { return mergeOptions( WhitelabelStore.getState(), UserStore.getState() ); }, componentDidMount() { UserStore.listen(this.onChange); UserActions.fetchCurrentUser.defer(); WhitelabelStore.listen(this.onChange); WhitelabelActions.fetchWhitelabel.defer(); if (this.state.currentUser && this.state.currentUser.email) { EventActions.profileDidLoad.defer(this.state.currentUser); } }, componentWillUpdate(nextProps, nextState) { const { currentUser: { email: curEmail } = {} } = this.state; const { currentUser: { email: nextEmail } = {} } = nextState; if (nextEmail && curEmail !== nextEmail) { EventActions.profileDidLoad.defer(nextState.currentUser); } }, componentWillUnmount() { UserStore.unlisten(this.onChange); WhitelabelStore.unlisten(this.onChange); //history.unlisten(this.onRouteChange); }, getLogo() { let { whitelabel } = this.state; if (whitelabel.head) { constructHead(whitelabel.head); } if (whitelabel.subdomain && whitelabel.subdomain !== 'www' && whitelabel.logo){ return ( Whitelabel brand ); } return ( ); }, getPoweredBy(){ return (
  • {getLangText('powered by')}
  • ); }, onChange(state) { this.setState(state); }, onMenuItemClick() { /* This is a hack to make the dropdown close after clicking on an item The function just need to be defined from https://github.com/react-bootstrap/react-bootstrap/issues/368: @jvillasante - Have you tried to use onSelect with the DropdownButton? I don't have a working example that is exactly like yours, but I just noticed that the Dropdown closes when I've attached an event handler to OnSelect: onSelected: function(e) { // doesn't need to have functionality (necessarily) ... just wired up } Internally, a call to DropdownButton.setDropDownState(false) is made which will hide the dropdown menu. So, you should be able to call that directly on the DropdownButton instance as well if needed. NOW, THAT DIDN'T WORK - the onSelect routine isnt triggered in all cases Hence, we do this manually */ this.refs.dropdownbutton.setDropdownState(false); }, render() { let account; let signup; let navRoutesLinks; if (this.state.currentUser.username){ account = ( {getLangText('Account Settings')} {getLangText('Contract Settings')} {getLangText('Log out')} ); navRoutesLinks = ; } else { account = ( {getLangText('LOGIN')} ); signup = ( {getLangText('SIGNUP')} ); } return (
    {this.getLogo()} {navRoutesLinks}

    ); } }); export default Header;