2022-10-04 18:13:23 +00:00
|
|
|
import React from 'react';
|
|
|
|
import Logo from 'flavours/glitch/components/logo';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
import { registrationsOpen, me } from 'flavours/glitch/initial_state';
|
|
|
|
import Avatar from 'flavours/glitch/components/avatar';
|
|
|
|
import Permalink from 'flavours/glitch/components/permalink';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
const Account = connect(state => ({
|
|
|
|
account: state.getIn(['accounts', me]),
|
|
|
|
}))(({ account }) => (
|
2022-10-09 13:55:32 +00:00
|
|
|
<Permalink href={account.get('url')} to={`/@${account.get('acct')}`} title={account.get('acct')}>
|
2022-10-04 18:13:23 +00:00
|
|
|
<Avatar account={account} size={35} />
|
|
|
|
</Permalink>
|
|
|
|
));
|
|
|
|
|
|
|
|
export default class Header extends React.PureComponent {
|
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
identity: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { signedIn } = this.context.identity;
|
|
|
|
|
|
|
|
let content;
|
|
|
|
|
|
|
|
if (signedIn) {
|
|
|
|
content = <Account />;
|
|
|
|
} else {
|
|
|
|
content = (
|
|
|
|
<React.Fragment>
|
|
|
|
<a href='/auth/sign_in' className='button'><FormattedMessage id='sign_in_banner.sign_in' defaultMessage='Sign in' /></a>
|
|
|
|
<a href={registrationsOpen ? '/auth/sign_up' : 'https://joinmastodon.org/servers'} className='button button-tertiary'><FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' /></a>
|
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='ui__header'>
|
|
|
|
<Link to='/' className='ui__header__logo'><Logo /></Link>
|
|
|
|
|
|
|
|
<div className='ui__header__links'>
|
|
|
|
{content}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|