2017-05-03 03:04:16 +03:00
import React from 'react' ;
2017-01-30 22:40:55 +02:00
import ImmutablePropTypes from 'react-immutable-proptypes' ;
2017-04-21 21:05:35 +03:00
import PropTypes from 'prop-types' ;
2017-12-04 09:26:40 +02:00
import InnerHeader from 'flavours/glitch/features/account/components/header' ;
import ActionBar from 'flavours/glitch/features/account/components/action_bar' ;
import MissingIndicator from 'flavours/glitch/components/missing_indicator' ;
2017-05-03 03:04:16 +03:00
import ImmutablePureComponent from 'react-immutable-pure-component' ;
2018-03-16 20:54:00 +02:00
import { FormattedMessage } from 'react-intl' ;
import { NavLink } from 'react-router-dom' ;
2017-01-30 22:40:55 +02:00
2017-06-23 20:36:54 +03:00
export default class Header extends ImmutablePureComponent {
2017-01-30 22:40:55 +02:00
2017-05-12 15:44:10 +03:00
static propTypes = {
account : ImmutablePropTypes . map ,
onFollow : PropTypes . func . isRequired ,
onBlock : PropTypes . func . isRequired ,
onMention : PropTypes . func . isRequired ,
2017-11-09 16:41:10 +02:00
onReblogToggle : PropTypes . func . isRequired ,
2017-05-12 15:44:10 +03:00
onReport : PropTypes . func . isRequired ,
2017-05-19 22:05:32 +03:00
onMute : PropTypes . func . isRequired ,
onBlockDomain : PropTypes . func . isRequired ,
onUnblockDomain : PropTypes . func . isRequired ,
2017-05-12 15:44:10 +03:00
} ;
static contextTypes = {
2017-05-20 18:31:47 +03:00
router : PropTypes . object ,
2017-05-12 15:44:10 +03:00
} ;
2017-01-30 22:40:55 +02:00
2017-05-12 15:44:10 +03:00
handleFollow = ( ) => {
2017-01-30 22:40:55 +02:00
this . props . onFollow ( this . props . account ) ;
2017-04-21 21:05:35 +03:00
}
2017-01-30 22:40:55 +02:00
2017-05-12 15:44:10 +03:00
handleBlock = ( ) => {
2017-01-30 22:40:55 +02:00
this . props . onBlock ( this . props . account ) ;
2017-04-21 21:05:35 +03:00
}
2017-01-30 22:40:55 +02:00
2017-05-12 15:44:10 +03:00
handleMention = ( ) => {
2017-06-20 21:40:03 +03:00
this . props . onMention ( this . props . account , this . context . router . history ) ;
2017-04-21 21:05:35 +03:00
}
2017-01-30 22:40:55 +02:00
2017-05-12 15:44:10 +03:00
handleReport = ( ) => {
2017-02-14 21:59:26 +02:00
this . props . onReport ( this . props . account ) ;
2017-04-21 21:05:35 +03:00
}
2017-02-14 21:59:26 +02:00
2017-11-09 16:41:10 +02:00
handleReblogToggle = ( ) => {
this . props . onReblogToggle ( this . props . account ) ;
}
2017-05-12 15:44:10 +03:00
handleMute = ( ) => {
2017-02-06 03:51:56 +02:00
this . props . onMute ( this . props . account ) ;
2017-04-21 21:05:35 +03:00
}
2017-02-06 03:51:56 +02:00
2017-05-19 22:05:32 +03: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 22:40:55 +02:00
render ( ) {
2017-10-31 04:27:48 +02:00
const { account } = this . props ;
2017-01-30 22:40:55 +02:00
2017-02-27 00:06:27 +02:00
if ( account === null ) {
return < MissingIndicator / > ;
2017-01-30 22:40:55 +02:00
}
return (
2017-04-23 05:26:55 +03:00
< div className = 'account-timeline__header' >
2017-01-30 22:40:55 +02:00
< InnerHeader
account = { account }
onFollow = { this . handleFollow }
2018-03-05 12:09:29 +02:00
onBlock = { this . handleBlock }
2017-01-30 22:40:55 +02:00
/ >
< ActionBar
account = { account }
onBlock = { this . handleBlock }
onMention = { this . handleMention }
2017-11-09 16:41:10 +02:00
onReblogToggle = { this . handleReblogToggle }
2017-02-14 21:59:26 +02:00
onReport = { this . handleReport }
2017-02-06 03:51:56 +02:00
onMute = { this . handleMute }
2017-05-19 22:05:32 +03:00
onBlockDomain = { this . handleBlockDomain }
onUnblockDomain = { this . handleUnblockDomain }
2017-01-30 22:40:55 +02:00
/ >
2018-03-16 20:54:00 +02:00
< div className = 'account__section-headline' >
< NavLink exact to = { ` /accounts/ ${ account . get ( 'id' ) } ` } > < FormattedMessage id = 'account.posts' defaultMessage = 'Toots' / > < / N a v L i n k >
< NavLink exact to = { ` /accounts/ ${ account . get ( 'id' ) } /with_replies ` } > < FormattedMessage id = 'account.posts_with_replies' defaultMessage = 'Toots with replies' / > < / N a v L i n k >
< NavLink exact to = { ` /accounts/ ${ account . get ( 'id' ) } /media ` } > < FormattedMessage id = 'account.media' defaultMessage = 'Media' / > < / N a v L i n k >
< / d i v >
2017-01-30 22:40:55 +02:00
< / d i v >
) ;
}
2017-04-21 21:05:35 +03:00
2017-05-12 15:44:10 +03:00
}