2020-04-25 15:26:47 -07:00
|
|
|
import React from 'react';
|
2020-06-07 14:16:47 -07:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2020-04-25 15:26:47 -07:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
import { Link } from 'react-router-dom';
|
2020-05-28 15:52:07 -07:00
|
|
|
import LoginForm from 'soapbox/features/auth_login/components/login_form';
|
2020-04-25 15:26:47 -07:00
|
|
|
import SiteLogo from './site_logo';
|
2020-06-07 14:16:47 -07:00
|
|
|
import SoapboxPropTypes from 'soapbox/utils/soapbox_prop_types';
|
2020-08-05 19:12:15 -07:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
home: { id: 'header.home.label', defaultMessage: 'Home' },
|
|
|
|
about: { id: 'header.about.label', defaultMessage: 'About' },
|
|
|
|
backTo: { id: 'header.back_to.label', defaultMessage: 'Back to' },
|
|
|
|
login: { id: 'header.login.label', defaultMessage: 'Log in' },
|
|
|
|
});
|
2020-04-25 15:26:47 -07:00
|
|
|
|
2020-06-07 14:16:47 -07:00
|
|
|
const mapStateToProps = state => ({
|
|
|
|
me: state.get('me'),
|
|
|
|
instance: state.get('instance'),
|
|
|
|
});
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
2020-08-05 19:12:15 -07:00
|
|
|
@injectIntl
|
2020-06-07 14:16:47 -07:00
|
|
|
class Header extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
me: SoapboxPropTypes.me,
|
|
|
|
instance: ImmutablePropTypes.map,
|
2020-08-05 19:12:15 -07:00
|
|
|
intl: PropTypes.object.isRequired,
|
2020-06-07 14:16:47 -07:00
|
|
|
}
|
2020-04-25 15:26:47 -07:00
|
|
|
|
|
|
|
render() {
|
2020-08-05 19:12:15 -07:00
|
|
|
const { me, instance, intl } = this.props;
|
2020-06-07 14:16:47 -07:00
|
|
|
|
2020-04-25 15:26:47 -07:00
|
|
|
return (
|
|
|
|
<nav className='header'>
|
|
|
|
<div className='header-container'>
|
|
|
|
<div className='nav-left'>
|
|
|
|
<Link className='brand' to='/'>
|
|
|
|
<SiteLogo />
|
|
|
|
</Link>
|
2020-08-05 19:12:15 -07:00
|
|
|
<Link className='nav-link optional' to='/'>{intl.formatMessage(messages.home)}</Link>
|
|
|
|
<Link className='nav-link' to='/about'>{intl.formatMessage(messages.about)}</Link>
|
2020-04-25 15:26:47 -07:00
|
|
|
</div>
|
|
|
|
<div className='nav-center' />
|
|
|
|
<div className='nav-right'>
|
|
|
|
<div className='hidden-sm'>
|
2020-06-07 14:16:47 -07:00
|
|
|
{me
|
2020-08-05 19:12:15 -07:00
|
|
|
? <Link className='nav-link nav-button webapp-btn' to='/'>{intl.formatMessage(messages.backTo)} {instance.get('title')}</Link>
|
2020-06-07 14:16:47 -07:00
|
|
|
: <LoginForm />
|
|
|
|
}
|
2020-04-25 15:26:47 -07:00
|
|
|
</div>
|
|
|
|
<div className='visible-sm'>
|
2020-06-07 19:00:49 -07:00
|
|
|
{me
|
2020-08-05 19:12:15 -07:00
|
|
|
? <Link className='nav-link nav-button webapp-btn' to='/'>{intl.formatMessage(messages.backTo)} {instance.get('title')}</Link>
|
|
|
|
: <Link className='nav-link nav-button webapp-btn' to='/auth/sign_in'>{intl.formatMessage(messages.login)}</Link>
|
2020-06-07 19:00:49 -07:00
|
|
|
}
|
2020-04-25 15:26:47 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|