]> cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/features/account_timeline/components/header.js
Improve eslint rules (#3147)
[mastodon.git] / app / javascript / mastodon / features / account_timeline / components / header.js
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
9 class Header extends ImmutablePureComponent {
10
11 static propTypes = {
12 account: ImmutablePropTypes.map,
13 me: PropTypes.number.isRequired,
14 onFollow: PropTypes.func.isRequired,
15 onBlock: PropTypes.func.isRequired,
16 onMention: PropTypes.func.isRequired,
17 onReport: PropTypes.func.isRequired,
18 onMute: PropTypes.func.isRequired,
19 onBlockDomain: PropTypes.func.isRequired,
20 onUnblockDomain: PropTypes.func.isRequired,
21 };
22
23 static contextTypes = {
24 router: PropTypes.object,
25 };
26
27 handleFollow = () => {
28 this.props.onFollow(this.props.account);
29 }
30
31 handleBlock = () => {
32 this.props.onBlock(this.props.account);
33 }
34
35 handleMention = () => {
36 this.props.onMention(this.props.account, this.context.router);
37 }
38
39 handleReport = () => {
40 this.props.onReport(this.props.account);
41 this.context.router.push('/report');
42 }
43
44 handleMute = () => {
45 this.props.onMute(this.props.account);
46 }
47
48 handleBlockDomain = () => {
49 const domain = this.props.account.get('acct').split('@')[1];
50
51 if (!domain) return;
52
53 this.props.onBlockDomain(domain, this.props.account.get('id'));
54 }
55
56 handleUnblockDomain = () => {
57 const domain = this.props.account.get('acct').split('@')[1];
58
59 if (!domain) return;
60
61 this.props.onUnblockDomain(domain, this.props.account.get('id'));
62 }
63
64 render () {
65 const { account, me } = this.props;
66
67 if (account === null) {
68 return <MissingIndicator />;
69 }
70
71 return (
72 <div className='account-timeline__header'>
73 <InnerHeader
74 account={account}
75 me={me}
76 onFollow={this.handleFollow}
77 />
78
79 <ActionBar
80 account={account}
81 me={me}
82 onBlock={this.handleBlock}
83 onMention={this.handleMention}
84 onReport={this.handleReport}
85 onMute={this.handleMute}
86 onBlockDomain={this.handleBlockDomain}
87 onUnblockDomain={this.handleUnblockDomain}
88 />
89 </div>
90 );
91 }
92
93 }
94
95 export default Header;
This page took 0.089234 seconds and 5 git commands to generate.