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.
 
 
 
 

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