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