2017-05-03 09:04:16 +09:00
|
|
|
import React from 'react';
|
2017-01-31 05:40:55 +09:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-04-22 03:05:35 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2017-01-31 05:40:55 +09:00
|
|
|
import InnerHeader from '../../account/components/header';
|
|
|
|
import ActionBar from '../../account/components/action_bar';
|
2017-02-27 07:06:27 +09:00
|
|
|
import MissingIndicator from '../../../components/missing_indicator';
|
2017-05-03 09:04:16 +09:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-05-03 09:04:16 +09:00
|
|
|
class Header extends ImmutablePureComponent {
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-04-22 03:05:35 +09:00
|
|
|
constructor (props, context) {
|
|
|
|
super(props, context);
|
|
|
|
this.handleFollow = this.handleFollow.bind(this);
|
|
|
|
this.handleBlock = this.handleBlock.bind(this);
|
|
|
|
this.handleMention = this.handleMention.bind(this);
|
|
|
|
this.handleReport = this.handleReport.bind(this);
|
|
|
|
this.handleMute = this.handleMute.bind(this);
|
|
|
|
}
|
2017-01-31 05:40:55 +09:00
|
|
|
|
|
|
|
handleFollow () {
|
|
|
|
this.props.onFollow(this.props.account);
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-01-31 05:40:55 +09:00
|
|
|
|
|
|
|
handleBlock () {
|
|
|
|
this.props.onBlock(this.props.account);
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-01-31 05:40:55 +09:00
|
|
|
|
|
|
|
handleMention () {
|
|
|
|
this.props.onMention(this.props.account, this.context.router);
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-02-15 04:59:26 +09:00
|
|
|
handleReport () {
|
|
|
|
this.props.onReport(this.props.account);
|
|
|
|
this.context.router.push('/report');
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-02-15 04:59:26 +09:00
|
|
|
|
2017-02-06 10:51:56 +09:00
|
|
|
handleMute() {
|
|
|
|
this.props.onMute(this.props.account);
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-02-06 10:51:56 +09:00
|
|
|
|
2017-01-31 05:40:55 +09:00
|
|
|
render () {
|
|
|
|
const { account, me } = this.props;
|
|
|
|
|
2017-02-27 07:06:27 +09:00
|
|
|
if (account === null) {
|
|
|
|
return <MissingIndicator />;
|
2017-01-31 05:40:55 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2017-04-23 11:26:55 +09:00
|
|
|
<div className='account-timeline__header'>
|
2017-01-31 05:40:55 +09:00
|
|
|
<InnerHeader
|
|
|
|
account={account}
|
|
|
|
me={me}
|
|
|
|
onFollow={this.handleFollow}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<ActionBar
|
|
|
|
account={account}
|
|
|
|
me={me}
|
|
|
|
onBlock={this.handleBlock}
|
|
|
|
onMention={this.handleMention}
|
2017-02-15 04:59:26 +09:00
|
|
|
onReport={this.handleReport}
|
2017-02-06 10:51:56 +09:00
|
|
|
onMute={this.handleMute}
|
2017-01-31 05:40:55 +09:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
Header.propTypes = {
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
me: PropTypes.number.isRequired,
|
|
|
|
onFollow: PropTypes.func.isRequired,
|
|
|
|
onBlock: PropTypes.func.isRequired,
|
|
|
|
onMention: PropTypes.func.isRequired,
|
|
|
|
onReport: PropTypes.func.isRequired,
|
|
|
|
onMute: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
Header.contextTypes = {
|
|
|
|
router: PropTypes.object
|
|
|
|
};
|
2017-01-31 05:40:55 +09:00
|
|
|
|
|
|
|
export default Header;
|