import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import { openSidebar } from '../actions/sidebar' import { openPopover } from '../actions/popover' import { BREAKPOINT_EXTRA_SMALL } from '../constants' import { me } from '../initial_state' import { makeGetAccount } from '../selectors' import Responsive from '../features/ui/util/responsive_component' import { CX, POPOVER_NAV_SETTINGS, } from '../constants' import Avatar from './avatar' import BackButton from './back_button' import Button from './button' import Heading from './heading' import Icon from './icon' import NavigationBarButton from './navigation_bar_button' import Search from './search' import Text from './text' class NavigationBar extends ImmutablePureComponent { handleOnOpenNavSettingsPopover = () => { this.props.onOpenNavSettingsPopover(this.avatarNode) } setAvatarNode = (c) => { this.avatarNode = c } render() { const { title, showBackBtn, actions, tabs, account, onOpenSidebar, noActions, noSearch, } = this.props return (
{ /** Default */}

{ !noSearch &&
}
{ !noActions &&
{ !!account && }
}
{ /** Mobile */}
{ !!account && !showBackBtn && !noActions && } { showBackBtn && } { noActions &&

}
{title}
{ actions && actions.map((action, i) => (
) } } const mapStateToProps = (state) => ({ account: makeGetAccount()(state, me), }) const mapDispatchToProps = (dispatch) => ({ onOpenSidebar() { dispatch(openSidebar()) }, onOpenNavSettingsPopover(targetRef) { dispatch(openPopover(POPOVER_NAV_SETTINGS, { targetRef, position: 'left-end', })) } }) NavigationBar.propTypes = { account: ImmutablePropTypes.map, actions: PropTypes.array, tabs: PropTypes.array, title: PropTypes.string, showBackBtn: PropTypes.bool, onOpenSidebar: PropTypes.func.isRequired, onOpenNavSettingsPopover: PropTypes.func.isRequired, noActions: PropTypes.bool, noSearch: PropTypes.bool, } export default connect(mapStateToProps, mapDispatchToProps)(NavigationBar)