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