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