You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
4.2 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import DropdownMenu from '../../../components/dropdown_menu';
  4. import { Link } from 'react-router';
  5. import { defineMessages, injectIntl, FormattedMessage, FormattedNumber } from 'react-intl';
  6. const messages = defineMessages({
  7. mention: { id: 'account.mention', defaultMessage: 'Mention' },
  8. edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
  9. unblock: { id: 'account.unblock', defaultMessage: 'Unblock' },
  10. unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
  11. block: { id: 'account.block', defaultMessage: 'Block' },
  12. follow: { id: 'account.follow', defaultMessage: 'Follow' },
  13. block: { id: 'account.block', defaultMessage: 'Block' }
  14. });
  15. const outerStyle = {
  16. borderTop: '1px solid #363c4b',
  17. borderBottom: '1px solid #363c4b',
  18. lineHeight: '36px',
  19. overflow: 'hidden',
  20. flex: '0 0 auto',
  21. display: 'flex'
  22. };
  23. const outerDropdownStyle = {
  24. padding: '10px',
  25. flex: '1 1 auto'
  26. };
  27. const outerLinksStyle = {
  28. flex: '1 1 auto',
  29. display: 'flex',
  30. lineHeight: '18px'
  31. };
  32. const ActionBar = React.createClass({
  33. propTypes: {
  34. account: ImmutablePropTypes.map.isRequired,
  35. me: React.PropTypes.number.isRequired,
  36. onFollow: React.PropTypes.func.isRequired,
  37. onBlock: React.PropTypes.func.isRequired,
  38. onMention: React.PropTypes.func.isRequired
  39. },
  40. mixins: [PureRenderMixin],
  41. render () {
  42. const { account, me, intl } = this.props;
  43. let menu = [];
  44. menu.push({ text: intl.formatMessage(messages.mention), action: this.props.onMention });
  45. if (account.get('id') === me) {
  46. menu.push({ text: intl.formatMessage(messages.edit_profile), href: '/settings/profile' });
  47. } else if (account.getIn(['relationship', 'blocking'])) {
  48. menu.push({ text: intl.formatMessage(messages.unblock), action: this.props.onBlock });
  49. } else if (account.getIn(['relationship', 'following'])) {
  50. menu.push({ text: intl.formatMessage(messages.unfollow), action: this.props.onFollow });
  51. menu.push({ text: intl.formatMessage(messages.block), action: this.props.onBlock });
  52. } else {
  53. menu.push({ text: intl.formatMessage(messages.follow), action: this.props.onFollow });
  54. menu.push({ text: intl.formatMessage(messages.block), action: this.props.onBlock });
  55. }
  56. return (
  57. <div style={outerStyle}>
  58. <div style={outerDropdownStyle}>
  59. <DropdownMenu items={menu} icon='bars' size={24} />
  60. </div>
  61. <div style={outerLinksStyle}>
  62. <Link to={`/accounts/${account.get('id')}`} style={{ textDecoration: 'none', overflow: 'hidden', width: '80px', borderLeft: '1px solid #363c4b', padding: '10px', paddingRight: '5px' }}>
  63. <span style={{ display: 'block', textTransform: 'uppercase', fontSize: '11px', color: '#616b86' }}><FormattedMessage id='account.posts' defaultMessage='Posts' /></span>
  64. <span style={{ display: 'block', fontSize: '15px', fontWeight: '500', color: '#fff' }}><FormattedNumber value={account.get('statuses_count')} /></span>
  65. </Link>
  66. <Link to={`/accounts/${account.get('id')}/following`} style={{ textDecoration: 'none', overflow: 'hidden', width: '80px', borderLeft: '1px solid #363c4b', padding: '10px 5px' }}>
  67. <span style={{ display: 'block', textTransform: 'uppercase', fontSize: '11px', color: '#616b86' }}><FormattedMessage id='account.follows' defaultMessage='Follows' /></span>
  68. <span style={{ display: 'block', fontSize: '15px', fontWeight: '500', color: '#fff' }}><FormattedNumber value={account.get('following_count')} /></span>
  69. </Link>
  70. <Link to={`/accounts/${account.get('id')}/followers`} style={{ textDecoration: 'none', overflow: 'hidden', width: '80px', padding: '10px 5px', borderLeft: '1px solid #363c4b' }}>
  71. <span style={{ display: 'block', textTransform: 'uppercase', fontSize: '11px', color: '#616b86' }}><FormattedMessage id='account.followers' defaultMessage='Followers' /></span>
  72. <span style={{ display: 'block', fontSize: '15px', fontWeight: '500', color: '#fff' }}><FormattedNumber value={account.get('followers_count')} /></span>
  73. </Link>
  74. </div>
  75. </div>
  76. );
  77. }
  78. });
  79. export default injectIntl(ActionBar);