logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

header.js (2771B)


  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. onDirect: PropTypes.func.isRequired,
  18. onReblogToggle: PropTypes.func.isRequired,
  19. onMute: PropTypes.func.isRequired,
  20. hideTabs: PropTypes.bool,
  21. };
  22. static contextTypes = {
  23. router: PropTypes.object,
  24. };
  25. handleFollow = () => {
  26. this.props.onFollow(this.props.account);
  27. }
  28. handleBlock = () => {
  29. this.props.onBlock(this.props.account);
  30. }
  31. handleMention = () => {
  32. this.props.onMention(this.props.account, this.context.router.history);
  33. }
  34. handleDirect = () => {
  35. this.props.onDirect(this.props.account, this.context.router.history);
  36. }
  37. handleReblogToggle = () => {
  38. this.props.onReblogToggle(this.props.account);
  39. }
  40. handleMute = () => {
  41. this.props.onMute(this.props.account);
  42. }
  43. render () {
  44. const { account, hideTabs } = this.props;
  45. if (account === null) {
  46. return <MissingIndicator />;
  47. }
  48. return (
  49. <div className='account-timeline__header'>
  50. {account.get('moved') && <MovedNote from={account} to={account.get('moved')} />}
  51. <InnerHeader
  52. account={account}
  53. onFollow={this.handleFollow}
  54. onBlock={this.handleBlock}
  55. />
  56. <ActionBar
  57. account={account}
  58. onBlock={this.handleBlock}
  59. onMention={this.handleMention}
  60. onDirect={this.handleDirect}
  61. onReblogToggle={this.handleReblogToggle}
  62. onMute={this.handleMute}
  63. />
  64. {!hideTabs && (
  65. <div className='account__section-headline'>
  66. <NavLink exact to={`/accounts/${account.get('id')}`}><FormattedMessage id='account.posts' defaultMessage='Toots' /></NavLink>
  67. <NavLink exact to={`/accounts/${account.get('id')}/with_replies`}><FormattedMessage id='account.posts_with_replies' defaultMessage='Toots and replies' /></NavLink>
  68. <NavLink exact to={`/accounts/${account.get('id')}/media`}><FormattedMessage id='account.media' defaultMessage='Media' /></NavLink>
  69. </div>
  70. )}
  71. </div>
  72. );
  73. }
  74. }