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.
 
 
 
 

82 regels
1.9 KiB

  1. import ImmutablePropTypes from 'react-immutable-proptypes';
  2. import PropTypes from 'prop-types';
  3. import InnerHeader from '../../account/components/header';
  4. import ActionBar from '../../account/components/action_bar';
  5. import MissingIndicator from '../../../components/missing_indicator';
  6. class Header extends React.PureComponent {
  7. constructor (props, context) {
  8. super(props, context);
  9. this.handleFollow = this.handleFollow.bind(this);
  10. this.handleBlock = this.handleBlock.bind(this);
  11. this.handleMention = this.handleMention.bind(this);
  12. this.handleReport = this.handleReport.bind(this);
  13. this.handleMute = this.handleMute.bind(this);
  14. }
  15. handleFollow () {
  16. this.props.onFollow(this.props.account);
  17. }
  18. handleBlock () {
  19. this.props.onBlock(this.props.account);
  20. }
  21. handleMention () {
  22. this.props.onMention(this.props.account, this.context.router);
  23. }
  24. handleReport () {
  25. this.props.onReport(this.props.account);
  26. this.context.router.push('/report');
  27. }
  28. handleMute() {
  29. this.props.onMute(this.props.account);
  30. }
  31. render () {
  32. const { account, me } = this.props;
  33. if (account === null) {
  34. return <MissingIndicator />;
  35. }
  36. return (
  37. <div>
  38. <InnerHeader
  39. account={account}
  40. me={me}
  41. onFollow={this.handleFollow}
  42. />
  43. <ActionBar
  44. account={account}
  45. me={me}
  46. onBlock={this.handleBlock}
  47. onMention={this.handleMention}
  48. onReport={this.handleReport}
  49. onMute={this.handleMute}
  50. />
  51. </div>
  52. );
  53. }
  54. }
  55. Header.propTypes = {
  56. account: ImmutablePropTypes.map,
  57. me: PropTypes.number.isRequired,
  58. onFollow: PropTypes.func.isRequired,
  59. onBlock: PropTypes.func.isRequired,
  60. onMention: PropTypes.func.isRequired,
  61. onReport: PropTypes.func.isRequired,
  62. onMute: PropTypes.func.isRequired
  63. };
  64. Header.contextTypes = {
  65. router: PropTypes.object
  66. };
  67. export default Header;