2017-05-02 20:04:16 -04:00
|
|
|
import React from 'react';
|
2017-01-30 15:40:55 -05:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-04-21 14:05:35 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2017-07-12 04:02:51 -04:00
|
|
|
import InnerHeader from '../../../../glitch/components/account/header';
|
2017-01-30 15:40:55 -05:00
|
|
|
import ActionBar from '../../account/components/action_bar';
|
2017-02-26 17:06:27 -05:00
|
|
|
import MissingIndicator from '../../../components/missing_indicator';
|
2017-05-02 20:04:16 -04:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2017-01-30 15:40:55 -05:00
|
|
|
|
2017-06-23 13:36:54 -04:00
|
|
|
export default class Header extends ImmutablePureComponent {
|
2017-01-30 15:40:55 -05:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
static propTypes = {
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
me: PropTypes.number.isRequired,
|
|
|
|
onFollow: PropTypes.func.isRequired,
|
|
|
|
onBlock: PropTypes.func.isRequired,
|
|
|
|
onMention: PropTypes.func.isRequired,
|
|
|
|
onReport: PropTypes.func.isRequired,
|
2017-05-19 15:05:32 -04:00
|
|
|
onMute: PropTypes.func.isRequired,
|
|
|
|
onBlockDomain: PropTypes.func.isRequired,
|
|
|
|
onUnblockDomain: PropTypes.func.isRequired,
|
2017-05-12 08:44:10 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static contextTypes = {
|
2017-05-20 11:31:47 -04:00
|
|
|
router: PropTypes.object,
|
2017-05-12 08:44:10 -04:00
|
|
|
};
|
2017-01-30 15:40:55 -05:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
handleFollow = () => {
|
2017-01-30 15:40:55 -05:00
|
|
|
this.props.onFollow(this.props.account);
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|
2017-01-30 15:40:55 -05:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
handleBlock = () => {
|
2017-01-30 15:40:55 -05:00
|
|
|
this.props.onBlock(this.props.account);
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|
2017-01-30 15:40:55 -05:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
handleMention = () => {
|
2017-06-20 14:40:03 -04:00
|
|
|
this.props.onMention(this.props.account, this.context.router.history);
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|
2017-01-30 15:40:55 -05:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
handleReport = () => {
|
2017-02-14 14:59:26 -05:00
|
|
|
this.props.onReport(this.props.account);
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|
2017-02-14 14:59:26 -05:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
handleMute = () => {
|
2017-02-05 20:51:56 -05:00
|
|
|
this.props.onMute(this.props.account);
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|
2017-02-05 20:51:56 -05:00
|
|
|
|
2017-05-19 15:05:32 -04:00
|
|
|
handleBlockDomain = () => {
|
|
|
|
const domain = this.props.account.get('acct').split('@')[1];
|
|
|
|
|
|
|
|
if (!domain) return;
|
|
|
|
|
|
|
|
this.props.onBlockDomain(domain, this.props.account.get('id'));
|
|
|
|
}
|
|
|
|
|
|
|
|
handleUnblockDomain = () => {
|
|
|
|
const domain = this.props.account.get('acct').split('@')[1];
|
|
|
|
|
|
|
|
if (!domain) return;
|
|
|
|
|
|
|
|
this.props.onUnblockDomain(domain, this.props.account.get('id'));
|
|
|
|
}
|
|
|
|
|
2017-01-30 15:40:55 -05:00
|
|
|
render () {
|
|
|
|
const { account, me } = this.props;
|
|
|
|
|
2017-02-26 17:06:27 -05:00
|
|
|
if (account === null) {
|
|
|
|
return <MissingIndicator />;
|
2017-01-30 15:40:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2017-04-22 22:26:55 -04:00
|
|
|
<div className='account-timeline__header'>
|
2017-01-30 15:40:55 -05:00
|
|
|
<InnerHeader
|
|
|
|
account={account}
|
|
|
|
me={me}
|
|
|
|
onFollow={this.handleFollow}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<ActionBar
|
|
|
|
account={account}
|
|
|
|
me={me}
|
|
|
|
onBlock={this.handleBlock}
|
|
|
|
onMention={this.handleMention}
|
2017-02-14 14:59:26 -05:00
|
|
|
onReport={this.handleReport}
|
2017-02-05 20:51:56 -05:00
|
|
|
onMute={this.handleMute}
|
2017-05-19 15:05:32 -04:00
|
|
|
onBlockDomain={this.handleBlockDomain}
|
|
|
|
onUnblockDomain={this.handleUnblockDomain}
|
2017-01-30 15:40:55 -05:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-04-21 14:05:35 -04:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
}
|