import PropTypes from 'prop-types'; import { PureComponent } from 'react'; import { FormattedMessage } from 'react-intl'; import { Link, withRouter } from 'react-router-dom'; import { connect } from 'react-redux'; import { openModal } from 'mastodon/actions/modal'; import { Avatar } from 'mastodon/components/avatar'; import { WordmarkLogo, SymbolLogo } from 'mastodon/components/logo'; import { registrationsOpen, me } from 'mastodon/initial_state'; const Account = connect(state => ({ account: state.getIn(['accounts', me]), }))(({ account }) => ( )); const mapStateToProps = (state) => ({ signupUrl: state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'), }); const mapDispatchToProps = (dispatch) => ({ openClosedRegistrationsModal() { dispatch(openModal('CLOSED_REGISTRATIONS')); }, }); class Header extends PureComponent { static contextTypes = { identity: PropTypes.object, }; static propTypes = { openClosedRegistrationsModal: PropTypes.func, location: PropTypes.object, signupUrl: PropTypes.string.isRequired, }; render () { const { signedIn } = this.context.identity; const { location, openClosedRegistrationsModal, signupUrl } = this.props; let content; if (signedIn) { content = ( <> {location.pathname !== '/publish' && } ); } else { let signupButton; if (registrationsOpen) { signupButton = ( ); } else { signupButton = ( ); } content = ( <> {signupButton} ); } return (
{content}
); } } export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Header));