2017-05-02 20:04:16 -04:00
|
|
|
import React from 'react';
|
2016-09-23 14:23:26 -04:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-04-21 14:05:35 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2017-12-04 02:26:40 -05:00
|
|
|
import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_container';
|
2018-09-13 05:20:21 -04:00
|
|
|
import { NavLink } from 'react-router-dom';
|
2019-03-25 19:36:25 -04:00
|
|
|
import { injectIntl, FormattedMessage, FormattedNumber } from 'react-intl';
|
2018-08-31 06:33:32 -04:00
|
|
|
import { me, isStaff } from 'flavours/glitch/util/initial_state';
|
2018-09-25 08:46:14 -04:00
|
|
|
import { profileLink, accountAdminLink } from 'flavours/glitch/util/backend_links';
|
2019-03-28 12:07:40 -04:00
|
|
|
import Icon from 'flavours/glitch/components/icon';
|
2016-11-18 09:36:16 -05:00
|
|
|
|
2017-06-23 13:36:54 -04:00
|
|
|
@injectIntl
|
|
|
|
export default class ActionBar extends React.PureComponent {
|
2016-09-23 14:23:26 -04:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
static propTypes = {
|
|
|
|
account: ImmutablePropTypes.map.isRequired,
|
2017-05-20 11:31:47 -04:00
|
|
|
intl: PropTypes.object.isRequired,
|
2017-05-12 08:44:10 -04:00
|
|
|
};
|
|
|
|
|
2018-09-21 01:17:44 -04:00
|
|
|
isStatusesPageActive = (match, location) => {
|
|
|
|
if (!match) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !location.pathname.match(/\/(followers|following)\/?$/);
|
|
|
|
}
|
|
|
|
|
2016-09-23 14:23:26 -04:00
|
|
|
render () {
|
2017-10-30 22:27:48 -04:00
|
|
|
const { account, intl } = this.props;
|
2016-10-02 09:14:26 -04:00
|
|
|
|
2017-02-28 19:18:34 -05:00
|
|
|
let extraInfo = '';
|
2016-09-23 14:23:26 -04:00
|
|
|
|
2017-02-28 20:00:21 -05:00
|
|
|
if (account.get('acct') !== account.get('username')) {
|
2017-07-24 14:05:29 -04:00
|
|
|
extraInfo = (
|
|
|
|
<div className='account__disclaimer'>
|
2019-03-28 12:07:40 -04:00
|
|
|
<Icon icon='info-circle' fixedWidth /> <FormattedMessage
|
2017-07-24 14:05:29 -04:00
|
|
|
id='account.disclaimer_full'
|
|
|
|
defaultMessage="Information below may reflect the user's profile incompletely."
|
|
|
|
/>
|
|
|
|
{' '}
|
|
|
|
<a target='_blank' rel='noopener' href={account.get('url')}>
|
|
|
|
<FormattedMessage id='account.view_full_profile' defaultMessage='View full profile' />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
);
|
2018-08-31 06:33:32 -04:00
|
|
|
}
|
|
|
|
|
2016-09-23 14:23:26 -04:00
|
|
|
return (
|
2017-07-24 14:05:29 -04:00
|
|
|
<div>
|
|
|
|
{extraInfo}
|
|
|
|
|
|
|
|
<div className='account__action-bar'>
|
|
|
|
<div className='account__action-bar-links'>
|
2018-09-21 01:17:44 -04:00
|
|
|
<NavLink isActive={this.isStatusesPageActive} activeClassName='active' className='account__action-bar__tab' to={`/accounts/${account.get('id')}`}>
|
2018-07-30 07:21:48 -04:00
|
|
|
<FormattedMessage id='account.posts' defaultMessage='Posts' />
|
2017-07-24 14:05:29 -04:00
|
|
|
<strong><FormattedNumber value={account.get('statuses_count')} /></strong>
|
2018-09-13 05:20:21 -04:00
|
|
|
</NavLink>
|
2017-07-24 14:05:29 -04:00
|
|
|
|
2018-09-13 05:20:21 -04:00
|
|
|
<NavLink exact activeClassName='active' className='account__action-bar__tab' to={`/accounts/${account.get('id')}/following`}>
|
2018-07-30 07:21:48 -04:00
|
|
|
<FormattedMessage id='account.follows' defaultMessage='Follows' />
|
2017-07-24 14:05:29 -04:00
|
|
|
<strong><FormattedNumber value={account.get('following_count')} /></strong>
|
2018-09-13 05:20:21 -04:00
|
|
|
</NavLink>
|
2017-07-24 14:05:29 -04:00
|
|
|
|
2018-09-13 05:20:21 -04:00
|
|
|
<NavLink exact activeClassName='active' className='account__action-bar__tab' to={`/accounts/${account.get('id')}/followers`}>
|
2018-07-30 07:21:48 -04:00
|
|
|
<FormattedMessage id='account.followers' defaultMessage='Followers' />
|
2018-12-17 15:23:44 -05:00
|
|
|
<strong>{ account.get('followers_count') < 0 ? '-' : <FormattedNumber value={account.get('followers_count')} /> }</strong>
|
2018-09-13 05:20:21 -04:00
|
|
|
</NavLink>
|
2017-07-24 14:05:29 -04:00
|
|
|
</div>
|
2016-10-09 16:19:15 -04:00
|
|
|
</div>
|
2016-09-23 14:23:26 -04:00
|
|
|
</div>
|
|
|
|
);
|
2016-11-16 11:20:52 -05:00
|
|
|
}
|
2016-09-23 14:23:26 -04:00
|
|
|
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|