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