The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

123 lines
3.6 KiB

  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. import InnerHeader from '../../account/components/header';
  5. import ActionBar from '../../account/components/action_bar';
  6. import MissingIndicator from '../../../components/missing_indicator';
  7. import ImmutablePureComponent from 'react-immutable-pure-component';
  8. import MovedNote from './moved_note';
  9. import { FormattedMessage } from 'react-intl';
  10. import { NavLink } from 'react-router-dom';
  11. export default class Header extends ImmutablePureComponent {
  12. static propTypes = {
  13. account: ImmutablePropTypes.map,
  14. onFollow: PropTypes.func.isRequired,
  15. onBlock: PropTypes.func.isRequired,
  16. onMention: PropTypes.func.isRequired,
  17. onDirect: PropTypes.func.isRequired,
  18. onReblogToggle: PropTypes.func.isRequired,
  19. onReport: PropTypes.func.isRequired,
  20. onMute: PropTypes.func.isRequired,
  21. onBlockDomain: PropTypes.func.isRequired,
  22. onUnblockDomain: PropTypes.func.isRequired,
  23. onEndorseToggle: PropTypes.func.isRequired,
  24. hideTabs: PropTypes.bool,
  25. };
  26. static contextTypes = {
  27. router: PropTypes.object,
  28. };
  29. handleFollow = () => {
  30. this.props.onFollow(this.props.account);
  31. }
  32. handleBlock = () => {
  33. this.props.onBlock(this.props.account);
  34. }
  35. handleMention = () => {
  36. this.props.onMention(this.props.account, this.context.router.history);
  37. }
  38. handleDirect = () => {
  39. this.props.onDirect(this.props.account, this.context.router.history);
  40. }
  41. handleReport = () => {
  42. this.props.onReport(this.props.account);
  43. }
  44. handleReblogToggle = () => {
  45. this.props.onReblogToggle(this.props.account);
  46. }
  47. handleMute = () => {
  48. this.props.onMute(this.props.account);
  49. }
  50. handleBlockDomain = () => {
  51. const domain = this.props.account.get('acct').split('@')[1];
  52. if (!domain) return;
  53. this.props.onBlockDomain(domain);
  54. }
  55. handleUnblockDomain = () => {
  56. const domain = this.props.account.get('acct').split('@')[1];
  57. if (!domain) return;
  58. this.props.onUnblockDomain(domain);
  59. }
  60. handleEndorseToggle = () => {
  61. this.props.onEndorseToggle(this.props.account);
  62. }
  63. render () {
  64. const { account, hideTabs } = this.props;
  65. if (account === null) {
  66. return <MissingIndicator />;
  67. }
  68. return (
  69. <div className='account-timeline__header'>
  70. {account.get('moved') && <MovedNote from={account} to={account.get('moved')} />}
  71. <InnerHeader
  72. account={account}
  73. onFollow={this.handleFollow}
  74. onBlock={this.handleBlock}
  75. />
  76. <ActionBar
  77. account={account}
  78. onBlock={this.handleBlock}
  79. onMention={this.handleMention}
  80. onDirect={this.handleDirect}
  81. onReblogToggle={this.handleReblogToggle}
  82. onReport={this.handleReport}
  83. onMute={this.handleMute}
  84. onBlockDomain={this.handleBlockDomain}
  85. onUnblockDomain={this.handleUnblockDomain}
  86. onEndorseToggle={this.handleEndorseToggle}
  87. />
  88. {!hideTabs && (
  89. <div className='account__section-headline'>
  90. <NavLink exact to={`/accounts/${account.get('id')}`}><FormattedMessage id='account.posts' defaultMessage='Toots' /></NavLink>
  91. <NavLink exact to={`/accounts/${account.get('id')}/with_replies`}><FormattedMessage id='account.posts_with_replies' defaultMessage='Toots and replies' /></NavLink>
  92. <NavLink exact to={`/accounts/${account.get('id')}/media`}><FormattedMessage id='account.media' defaultMessage='Media' /></NavLink>
  93. </div>
  94. )}
  95. </div>
  96. );
  97. }
  98. }