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.

107 lines
3.2 KiB

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