logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

action_bar.js (5122B)


  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
  5. import { Link } from 'react-router-dom';
  6. import { defineMessages, injectIntl, FormattedMessage, FormattedNumber } from 'react-intl';
  7. import { me } from '../../../initial_state';
  8. const messages = defineMessages({
  9. mention: { id: 'account.mention', defaultMessage: 'Mention @{name}' },
  10. direct: { id: 'account.direct', defaultMessage: 'Direct message @{name}' },
  11. edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
  12. unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
  13. unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
  14. block: { id: 'account.block', defaultMessage: 'Block @{name}' },
  15. follow: { id: 'account.follow', defaultMessage: 'Follow' },
  16. report: { id: 'account.report', defaultMessage: 'Report @{name}' },
  17. share: { id: 'account.share', defaultMessage: 'Share @{name}\'s profile' },
  18. media: { id: 'account.media', defaultMessage: 'Media' },
  19. hideReblogs: { id: 'account.hide_reblogs', defaultMessage: 'Hide boosts from @{name}' },
  20. showReblogs: { id: 'account.show_reblogs', defaultMessage: 'Show boosts from @{name}' },
  21. });
  22. @injectIntl
  23. export default class ActionBar extends React.PureComponent {
  24. static propTypes = {
  25. account: ImmutablePropTypes.map.isRequired,
  26. onFollow: PropTypes.func,
  27. onBlock: PropTypes.func.isRequired,
  28. onMention: PropTypes.func.isRequired,
  29. onDirect: PropTypes.func.isRequired,
  30. onReblogToggle: PropTypes.func.isRequired,
  31. intl: PropTypes.object.isRequired,
  32. };
  33. handleShare = () => {
  34. navigator.share({
  35. url: this.props.account.get('url'),
  36. });
  37. }
  38. render () {
  39. const { account, intl } = this.props;
  40. let menu = [];
  41. let extraInfo = '';
  42. menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.props.onMention });
  43. menu.push({ text: intl.formatMessage(messages.direct, { name: account.get('username') }), action: this.props.onDirect });
  44. if ('share' in navigator) {
  45. menu.push({ text: intl.formatMessage(messages.share, { name: account.get('username') }), action: this.handleShare });
  46. }
  47. menu.push(null);
  48. if (account.get('id') === me) {
  49. menu.push({ text: intl.formatMessage(messages.edit_profile), href: '/settings/profile' });
  50. } else {
  51. if (account.getIn(['relationship', 'following'])) {
  52. if (account.getIn(['relationship', 'showing_reblogs'])) {
  53. menu.push({ text: intl.formatMessage(messages.hideReblogs, { name: account.get('username') }), action: this.props.onReblogToggle });
  54. } else {
  55. menu.push({ text: intl.formatMessage(messages.showReblogs, { name: account.get('username') }), action: this.props.onReblogToggle });
  56. }
  57. }
  58. if (account.getIn(['relationship', 'blocking'])) {
  59. menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.props.onBlock });
  60. } else {
  61. menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.props.onBlock });
  62. }
  63. }
  64. if (account.get('acct') !== account.get('username')) {
  65. extraInfo = (
  66. <div className='account__disclaimer'>
  67. <FormattedMessage
  68. id='account.disclaimer_full'
  69. defaultMessage="Information below may reflect the user's profile incompletely."
  70. />
  71. {' '}
  72. <a target='_blank' rel='noopener' href={account.get('url')}>
  73. <FormattedMessage id='account.view_full_profile' defaultMessage='View full profile' />
  74. </a>
  75. </div>
  76. );
  77. menu.push(null);
  78. }
  79. return (
  80. <div>
  81. {extraInfo}
  82. <div className='account__action-bar'>
  83. <div className='account__action-bar-dropdown'>
  84. <DropdownMenuContainer items={menu} icon='bars' size={24} direction='right' />
  85. </div>
  86. <div className='account__action-bar-links'>
  87. <Link className='account__action-bar__tab' to={`/accounts/${account.get('id')}`}>
  88. <span><FormattedMessage id='account.posts' defaultMessage='Toots' /></span>
  89. <strong><FormattedNumber value={account.get('statuses_count')} /></strong>
  90. </Link>
  91. <Link className='account__action-bar__tab' to={`/accounts/${account.get('id')}/following`}>
  92. <span><FormattedMessage id='account.follows' defaultMessage='Follows' /></span>
  93. <strong><FormattedNumber value={account.get('following_count')} /></strong>
  94. </Link>
  95. <Link className='account__action-bar__tab' to={`/accounts/${account.get('id')}/followers`}>
  96. <span><FormattedMessage id='account.followers' defaultMessage='Followers' /></span>
  97. <strong><FormattedNumber value={account.get('followers_count')} /></strong>
  98. </Link>
  99. </div>
  100. </div>
  101. </div>
  102. );
  103. }
  104. }