闭社主体 forked from https://github.com/tootsuite/mastodon
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.

93 lines
2.4 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. export default class Header extends ImmutablePureComponent {
  9. static propTypes = {
  10. account: ImmutablePropTypes.map,
  11. me: PropTypes.number.isRequired,
  12. onFollow: PropTypes.func.isRequired,
  13. onBlock: PropTypes.func.isRequired,
  14. onMention: PropTypes.func.isRequired,
  15. onReport: PropTypes.func.isRequired,
  16. onMute: PropTypes.func.isRequired,
  17. onBlockDomain: PropTypes.func.isRequired,
  18. onUnblockDomain: PropTypes.func.isRequired,
  19. };
  20. static contextTypes = {
  21. router: PropTypes.object,
  22. };
  23. handleFollow = () => {
  24. this.props.onFollow(this.props.account);
  25. }
  26. handleBlock = () => {
  27. this.props.onBlock(this.props.account);
  28. }
  29. handleMention = () => {
  30. this.props.onMention(this.props.account, this.context.router.history);
  31. }
  32. handleReport = () => {
  33. this.props.onReport(this.props.account);
  34. this.context.router.history.push('/report');
  35. }
  36. handleMute = () => {
  37. this.props.onMute(this.props.account);
  38. }
  39. handleBlockDomain = () => {
  40. const domain = this.props.account.get('acct').split('@')[1];
  41. if (!domain) return;
  42. this.props.onBlockDomain(domain, this.props.account.get('id'));
  43. }
  44. handleUnblockDomain = () => {
  45. const domain = this.props.account.get('acct').split('@')[1];
  46. if (!domain) return;
  47. this.props.onUnblockDomain(domain, this.props.account.get('id'));
  48. }
  49. render () {
  50. const { account, me } = this.props;
  51. if (account === null) {
  52. return <MissingIndicator />;
  53. }
  54. return (
  55. <div className='account-timeline__header'>
  56. <InnerHeader
  57. account={account}
  58. me={me}
  59. onFollow={this.handleFollow}
  60. />
  61. <ActionBar
  62. account={account}
  63. me={me}
  64. onBlock={this.handleBlock}
  65. onMention={this.handleMention}
  66. onReport={this.handleReport}
  67. onMute={this.handleMute}
  68. onBlockDomain={this.handleBlockDomain}
  69. onUnblockDomain={this.handleUnblockDomain}
  70. />
  71. </div>
  72. );
  73. }
  74. }