2017-05-02 17:04:16 -07:00
import React from 'react' ;
2017-01-30 12:40:55 -08:00
import ImmutablePropTypes from 'react-immutable-proptypes' ;
2017-04-21 11:05:35 -07:00
import PropTypes from 'prop-types' ;
2017-12-03 23:26:40 -08:00
import InnerHeader from 'flavours/glitch/features/account/components/header' ;
import ActionBar from 'flavours/glitch/features/account/components/action_bar' ;
2017-05-02 17:04:16 -07:00
import ImmutablePureComponent from 'react-immutable-pure-component' ;
2018-03-16 11:54:00 -07:00
import { FormattedMessage } from 'react-intl' ;
import { NavLink } from 'react-router-dom' ;
2018-03-29 05:43:20 -07:00
import MovedNote from './moved_note' ;
2017-01-30 12:40:55 -08:00
2017-06-23 10:36:54 -07:00
export default class Header extends ImmutablePureComponent {
2017-01-30 12:40:55 -08:00
2017-05-12 05:44:10 -07:00
static propTypes = {
account : ImmutablePropTypes . map ,
onFollow : PropTypes . func . isRequired ,
onBlock : PropTypes . func . isRequired ,
onMention : PropTypes . func . isRequired ,
2018-03-29 12:13:47 -07:00
onDirect : PropTypes . func . isRequired ,
2017-11-09 06:41:10 -08:00
onReblogToggle : PropTypes . func . isRequired ,
2017-05-12 05:44:10 -07:00
onReport : PropTypes . func . isRequired ,
2017-05-19 12:05:32 -07:00
onMute : PropTypes . func . isRequired ,
onBlockDomain : PropTypes . func . isRequired ,
onUnblockDomain : PropTypes . func . isRequired ,
2018-08-10 07:25:46 -07:00
onEndorseToggle : PropTypes . func . isRequired ,
2018-11-06 08:44:28 -08:00
onAddToList : PropTypes . func . isRequired ,
2018-03-16 12:29:42 -07:00
hideTabs : PropTypes . bool ,
2019-03-25 16:36:25 -07:00
domain : PropTypes . string . isRequired ,
2017-05-12 05:44:10 -07:00
} ;
static contextTypes = {
2017-05-20 08:31:47 -07:00
router : PropTypes . object ,
2017-05-12 05:44:10 -07:00
} ;
2017-01-30 12:40:55 -08:00
2017-05-12 05:44:10 -07:00
handleFollow = ( ) => {
2017-01-30 12:40:55 -08:00
this . props . onFollow ( this . props . account ) ;
2017-04-21 11:05:35 -07:00
}
2017-01-30 12:40:55 -08:00
2017-05-12 05:44:10 -07:00
handleBlock = ( ) => {
2017-01-30 12:40:55 -08:00
this . props . onBlock ( this . props . account ) ;
2017-04-21 11:05:35 -07:00
}
2017-01-30 12:40:55 -08:00
2017-05-12 05:44:10 -07:00
handleMention = ( ) => {
2017-06-20 11:40:03 -07:00
this . props . onMention ( this . props . account , this . context . router . history ) ;
2017-04-21 11:05:35 -07:00
}
2017-01-30 12:40:55 -08:00
2018-03-29 12:13:47 -07:00
handleDirect = ( ) => {
this . props . onDirect ( this . props . account , this . context . router . history ) ;
}
2017-05-12 05:44:10 -07:00
handleReport = ( ) => {
2017-02-14 11:59:26 -08:00
this . props . onReport ( this . props . account ) ;
2017-04-21 11:05:35 -07:00
}
2017-02-14 11:59:26 -08:00
2017-11-09 06:41:10 -08:00
handleReblogToggle = ( ) => {
this . props . onReblogToggle ( this . props . account ) ;
}
2020-09-18 08:26:45 -07:00
handleNotifyToggle = ( ) => {
this . props . onNotifyToggle ( this . props . account ) ;
}
2017-05-12 05:44:10 -07:00
handleMute = ( ) => {
2017-02-05 17:51:56 -08:00
this . props . onMute ( this . props . account ) ;
2017-04-21 11:05:35 -07:00
}
2017-02-05 17:51:56 -08:00
2017-05-19 12:05:32 -07:00
handleBlockDomain = ( ) => {
const domain = this . props . account . get ( 'acct' ) . split ( '@' ) [ 1 ] ;
if ( ! domain ) return ;
2018-03-04 14:38:00 -08:00
this . props . onBlockDomain ( domain ) ;
2017-05-19 12:05:32 -07:00
}
handleUnblockDomain = ( ) => {
const domain = this . props . account . get ( 'acct' ) . split ( '@' ) [ 1 ] ;
if ( ! domain ) return ;
2018-03-04 14:38:00 -08:00
this . props . onUnblockDomain ( domain ) ;
2017-05-19 12:05:32 -07:00
}
2018-08-10 07:25:46 -07:00
handleEndorseToggle = ( ) => {
this . props . onEndorseToggle ( this . props . account ) ;
}
2018-11-06 08:44:28 -08:00
handleAddToList = ( ) => {
this . props . onAddToList ( this . props . account ) ;
}
2020-06-30 10:19:50 -07:00
handleEditAccountNote = ( ) => {
this . props . onEditAccountNote ( this . props . account ) ;
}
2017-01-30 12:40:55 -08:00
render ( ) {
2021-11-25 20:58:18 -08:00
const { account , hideTabs } = this . props ;
2017-01-30 12:40:55 -08:00
2017-02-26 14:06:27 -08:00
if ( account === null ) {
2019-04-08 20:02:48 -07:00
return null ;
2017-01-30 12:40:55 -08:00
}
return (
2017-04-22 19:26:55 -07:00
< div className = 'account-timeline__header' >
2018-03-29 05:43:20 -07:00
{ account . get ( 'moved' ) && < MovedNote from = { account } to = { account . get ( 'moved' ) } / > }
2017-01-30 12:40:55 -08:00
< InnerHeader
account = { account }
onFollow = { this . handleFollow }
2018-03-05 02:09:29 -08:00
onBlock = { this . handleBlock }
2019-03-25 21:31:09 -07:00
onMention = { this . handleMention }
onDirect = { this . handleDirect }
onReblogToggle = { this . handleReblogToggle }
2020-09-18 08:26:45 -07:00
onNotifyToggle = { this . handleNotifyToggle }
2019-03-25 21:31:09 -07:00
onReport = { this . handleReport }
onMute = { this . handleMute }
onBlockDomain = { this . handleBlockDomain }
onUnblockDomain = { this . handleUnblockDomain }
onEndorseToggle = { this . handleEndorseToggle }
onAddToList = { this . handleAddToList }
2020-06-30 10:19:50 -07:00
onEditAccountNote = { this . handleEditAccountNote }
2019-03-25 16:36:25 -07:00
domain = { this . props . domain }
2017-01-30 12:40:55 -08:00
/ >
< ActionBar
account = { account }
/ >
2018-03-16 11:54:00 -07:00
2018-03-16 12:29:42 -07:00
{ ! hideTabs && (
< div className = 'account__section-headline' >
2022-05-03 01:59:23 -07:00
< NavLink exact to = { ` /@ ${ account . get ( 'acct' ) } ` } > < FormattedMessage id = 'account.posts' defaultMessage = 'Posts' / > < / N a v L i n k >
< NavLink exact to = { ` /@ ${ account . get ( 'acct' ) } /with_replies ` } > < FormattedMessage id = 'account.posts_with_replies' defaultMessage = 'Posts with replies' / > < / N a v L i n k >
2021-09-25 20:46:13 -07:00
< NavLink exact to = { ` /@ ${ account . get ( 'acct' ) } /media ` } > < FormattedMessage id = 'account.media' defaultMessage = 'Media' / > < / N a v L i n k >
2018-03-16 12:29:42 -07:00
< / d i v >
) }
2017-01-30 12:40:55 -08:00
< / d i v >
) ;
}
2017-04-21 11:05:35 -07:00
2017-05-12 05:44:10 -07:00
}