1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
mastodon/app/assets/javascripts/components/features/account/components/action_bar.jsx

93 lines
3.6 KiB
React
Raw Normal View History

import PureRenderMixin from 'react-addons-pure-render-mixin';
import ImmutablePropTypes from 'react-immutable-proptypes';
import DropdownMenu from '../../../components/dropdown_menu';
import { Link } from 'react-router';
2016-11-18 06:36:16 -08:00
import { defineMessages, injectIntl, FormattedMessage, FormattedNumber } from 'react-intl';
const messages = defineMessages({
2017-02-28 15:53:11 -08:00
mention: { id: 'account.mention', defaultMessage: 'Mention @{name}' },
2016-11-18 06:36:16 -08:00
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
2017-02-28 15:53:11 -08:00
unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
2016-11-18 06:36:16 -08:00
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
2017-02-28 15:53:11 -08:00
block: { id: 'account.block', defaultMessage: 'Block @{name}' },
2016-11-18 06:36:16 -08:00
follow: { id: 'account.follow', defaultMessage: 'Follow' },
2017-02-28 15:53:11 -08:00
report: { id: 'account.report', defaultMessage: 'Report @{name}' }
2016-11-18 06:36:16 -08:00
});
const outerDropdownStyle = {
padding: '10px',
flex: '1 1 auto'
};
const outerLinksStyle = {
flex: '1 1 auto',
display: 'flex',
lineHeight: '18px'
};
const ActionBar = React.createClass({
propTypes: {
account: ImmutablePropTypes.map.isRequired,
me: React.PropTypes.number.isRequired,
2016-12-12 05:39:18 -08:00
onFollow: React.PropTypes.func,
onBlock: React.PropTypes.func.isRequired,
onMention: React.PropTypes.func.isRequired,
onReport: React.PropTypes.func.isRequired,
intl: React.PropTypes.object.isRequired
},
mixins: [PureRenderMixin],
render () {
const { account, me, intl } = this.props;
2016-10-09 13:19:15 -07:00
let menu = [];
2017-02-28 15:53:11 -08:00
menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.props.onMention });
menu.push(null);
if (account.get('id') === me) {
2016-11-18 06:36:16 -08:00
menu.push({ text: intl.formatMessage(messages.edit_profile), href: '/settings/profile' });
2016-10-09 13:19:15 -07:00
} else if (account.getIn(['relationship', 'blocking'])) {
2017-02-28 15:53:11 -08:00
menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.props.onBlock });
2016-10-09 13:19:15 -07:00
} else if (account.getIn(['relationship', 'following'])) {
2017-02-28 15:53:11 -08:00
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.props.onBlock });
2016-10-09 13:19:15 -07:00
} else {
2017-02-28 15:53:11 -08:00
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.props.onBlock });
}
if (account.get('id') !== me) {
2017-02-28 15:53:11 -08:00
menu.push({ text: intl.formatMessage(messages.report, { name: account.get('username') }), action: this.props.onReport });
}
return (
<div className='account__action-bar'>
<div style={outerDropdownStyle}>
<DropdownMenu items={menu} icon='bars' size={24} direction="right" />
</div>
<div style={outerLinksStyle}>
<Link className='account__action-bar__tab' to={`/accounts/${account.get('id')}`}>
<span><FormattedMessage id='account.posts' defaultMessage='Posts' /></span>
<strong><FormattedNumber value={account.get('statuses_count')} /></strong>
</Link>
2016-10-09 13:19:15 -07:00
<Link className='account__action-bar__tab' to={`/accounts/${account.get('id')}/following`}>
<span><FormattedMessage id='account.follows' defaultMessage='Follows' /></span>
<strong><FormattedNumber value={account.get('following_count')} /></strong>
</Link>
2016-10-09 13:19:15 -07:00
<Link className='account__action-bar__tab' to={`/accounts/${account.get('id')}/followers`}>
<span><FormattedMessage id='account.followers' defaultMessage='Followers' /></span>
<strong><FormattedNumber value={account.get('followers_count')} /></strong>
</Link>
2016-10-09 13:19:15 -07:00
</div>
</div>
);
}
});
export default injectIntl(ActionBar);