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.

73 lines
1.7 KiB

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