闭社主体 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.

92 lines
2.3 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. }
  35. handleMute = () => {
  36. this.props.onMute(this.props.account);
  37. }
  38. handleBlockDomain = () => {
  39. const domain = this.props.account.get('acct').split('@')[1];
  40. if (!domain) return;
  41. this.props.onBlockDomain(domain, this.props.account.get('id'));
  42. }
  43. handleUnblockDomain = () => {
  44. const domain = this.props.account.get('acct').split('@')[1];
  45. if (!domain) return;
  46. this.props.onUnblockDomain(domain, this.props.account.get('id'));
  47. }
  48. render () {
  49. const { account, me } = this.props;
  50. if (account === null) {
  51. return <MissingIndicator />;
  52. }
  53. return (
  54. <div className='account-timeline__header'>
  55. <InnerHeader
  56. account={account}
  57. me={me}
  58. onFollow={this.handleFollow}
  59. />
  60. <ActionBar
  61. account={account}
  62. me={me}
  63. onBlock={this.handleBlock}
  64. onMention={this.handleMention}
  65. onReport={this.handleReport}
  66. onMute={this.handleMute}
  67. onBlockDomain={this.handleBlockDomain}
  68. onUnblockDomain={this.handleUnblockDomain}
  69. />
  70. </div>
  71. );
  72. }
  73. }