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' ;
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' ;
2018-03-29 15:43:20 +03:00
import MovedNote from './moved_note' ;
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 ,
2018-03-29 22:13:47 +03:00
onDirect : 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 ,
2018-08-10 17:25:46 +03:00
onEndorseToggle : PropTypes . func . isRequired ,
2018-11-06 18:44:28 +02:00
onAddToList : PropTypes . func . isRequired ,
2022-09-21 00:51:21 +03:00
onChangeLanguages : PropTypes . func . isRequired ,
2022-10-07 11:14:31 +03:00
onInteractionModal : PropTypes . func . isRequired ,
2022-11-10 09:49:35 +02:00
onOpenAvatar : PropTypes . func . isRequired ,
2018-03-16 21:29:42 +02:00
hideTabs : PropTypes . bool ,
2019-03-26 01:36:25 +02:00
domain : PropTypes . string . isRequired ,
2022-05-10 10:44:35 +03:00
hidden : PropTypes . bool ,
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 ) ;
2023-02-03 21:52:07 +02: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 ) ;
2023-02-03 21:52:07 +02: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 ) ;
2023-02-03 21:52:07 +02:00
} ;
2017-01-30 22:40:55 +02:00
2018-03-29 22:13:47 +03:00
handleDirect = ( ) => {
this . props . onDirect ( this . props . account , this . context . router . history ) ;
2023-02-03 21:52:07 +02:00
} ;
2018-03-29 22:13:47 +03:00
2017-05-12 15:44:10 +03:00
handleReport = ( ) => {
2017-02-14 21:59:26 +02:00
this . props . onReport ( this . props . account ) ;
2023-02-03 21:52:07 +02:00
} ;
2017-02-14 21:59:26 +02:00
2017-11-09 16:41:10 +02:00
handleReblogToggle = ( ) => {
this . props . onReblogToggle ( this . props . account ) ;
2023-02-03 21:52:07 +02:00
} ;
2017-11-09 16:41:10 +02:00
2020-09-18 18:26:45 +03:00
handleNotifyToggle = ( ) => {
this . props . onNotifyToggle ( this . props . account ) ;
2023-02-03 21:52:07 +02:00
} ;
2020-09-18 18:26:45 +03:00
2017-05-12 15:44:10 +03:00
handleMute = ( ) => {
2017-02-06 03:51:56 +02:00
this . props . onMute ( this . props . account ) ;
2023-02-03 21:52:07 +02: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 ;
2018-03-05 00:38:00 +02:00
this . props . onBlockDomain ( domain ) ;
2023-02-03 21:52:07 +02:00
} ;
2017-05-19 22:05:32 +03:00
handleUnblockDomain = ( ) => {
const domain = this . props . account . get ( 'acct' ) . split ( '@' ) [ 1 ] ;
if ( ! domain ) return ;
2018-03-05 00:38:00 +02:00
this . props . onUnblockDomain ( domain ) ;
2023-02-03 21:52:07 +02:00
} ;
2017-05-19 22:05:32 +03:00
2018-08-10 17:25:46 +03:00
handleEndorseToggle = ( ) => {
this . props . onEndorseToggle ( this . props . account ) ;
2023-02-03 21:52:07 +02:00
} ;
2018-08-10 17:25:46 +03:00
2018-11-06 18:44:28 +02:00
handleAddToList = ( ) => {
this . props . onAddToList ( this . props . account ) ;
2023-02-03 21:52:07 +02:00
} ;
2018-11-06 18:44:28 +02:00
2020-06-30 20:19:50 +03:00
handleEditAccountNote = ( ) => {
this . props . onEditAccountNote ( this . props . account ) ;
2023-02-03 21:52:07 +02:00
} ;
2020-06-30 20:19:50 +03:00
2022-09-21 00:51:21 +03:00
handleChangeLanguages = ( ) => {
this . props . onChangeLanguages ( this . props . account ) ;
2023-02-03 21:52:07 +02:00
} ;
2022-09-21 00:51:21 +03:00
2022-10-07 11:14:31 +03:00
handleInteractionModal = ( ) => {
this . props . onInteractionModal ( this . props . account ) ;
2023-02-03 21:52:07 +02:00
} ;
2022-10-07 11:14:31 +03:00
2022-11-10 09:49:35 +02:00
handleOpenAvatar = ( ) => {
this . props . onOpenAvatar ( this . props . account ) ;
2023-02-03 21:52:07 +02:00
} ;
2022-11-10 09:49:35 +02:00
2017-01-30 22:40:55 +02:00
render ( ) {
2022-05-10 10:44:35 +03:00
const { account , hidden , hideTabs } = this . props ;
2017-01-30 22:40:55 +02:00
2017-02-27 00:06:27 +02:00
if ( account === null ) {
2019-04-09 06:02:48 +03:00
return null ;
2017-01-30 22:40:55 +02:00
}
return (
2017-04-23 05:26:55 +03:00
< div className = 'account-timeline__header' >
2022-05-10 10:44:35 +03:00
{ ( ! hidden && account . get ( 'moved' ) ) && < MovedNote from = { account } to = { account . get ( 'moved' ) } / > }
2018-03-29 15:43:20 +03:00
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 }
2019-03-26 06:31:09 +02:00
onMention = { this . handleMention }
onDirect = { this . handleDirect }
onReblogToggle = { this . handleReblogToggle }
2020-09-18 18:26:45 +03:00
onNotifyToggle = { this . handleNotifyToggle }
2019-03-26 06:31:09 +02:00
onReport = { this . handleReport }
onMute = { this . handleMute }
onBlockDomain = { this . handleBlockDomain }
onUnblockDomain = { this . handleUnblockDomain }
onEndorseToggle = { this . handleEndorseToggle }
onAddToList = { this . handleAddToList }
2020-06-30 20:19:50 +03:00
onEditAccountNote = { this . handleEditAccountNote }
2022-09-21 00:51:21 +03:00
onChangeLanguages = { this . handleChangeLanguages }
2022-10-07 11:14:31 +03:00
onInteractionModal = { this . handleInteractionModal }
2022-11-10 09:49:35 +02:00
onOpenAvatar = { this . handleOpenAvatar }
2019-03-26 01:36:25 +02:00
domain = { this . props . domain }
2022-05-10 10:44:35 +03:00
hidden = { hidden }
2017-01-30 22:40:55 +02:00
/ >
< ActionBar
account = { account }
/ >
2018-03-16 20:54:00 +02:00
2022-05-10 10:44:35 +03:00
{ ! ( hideTabs || hidden ) && (
2018-03-16 21:29:42 +02:00
< div className = 'account__section-headline' >
2022-05-03 11:59:23 +03:00
< NavLink exact to = { ` /@ ${ account . get ( 'acct' ) } ` } > < FormattedMessage id = 'account.posts' defaultMessage = 'Posts' / > < / NavLink >
< NavLink exact to = { ` /@ ${ account . get ( 'acct' ) } /with_replies ` } > < FormattedMessage id = 'account.posts_with_replies' defaultMessage = 'Posts with replies' / > < / NavLink >
2021-09-26 06:46:13 +03:00
< NavLink exact to = { ` /@ ${ account . get ( 'acct' ) } /media ` } > < FormattedMessage id = 'account.media' defaultMessage = 'Media' / > < / NavLink >
2018-03-16 21:29:42 +02:00
< / div >
) }
2017-01-30 22:40:55 +02:00
< / div >
) ;
}
2017-04-21 21:05:35 +03:00
2017-05-12 15:44:10 +03:00
}