2022-01-10 14:17:52 -08:00
import PropTypes from 'prop-types' ;
2020-03-27 13:59:38 -07:00
import React from 'react' ;
import ImmutablePropTypes from 'react-immutable-proptypes' ;
2022-01-10 14:01:24 -08:00
import ImmutablePureComponent from 'react-immutable-pure-component' ;
2022-01-10 14:17:52 -08:00
import { defineMessages , injectIntl , FormattedMessage } from 'react-intl' ;
2022-03-17 18:17:28 -07:00
import { withRouter } from 'react-router-dom' ;
2022-01-10 14:25:06 -08:00
2022-01-10 14:17:52 -08:00
import Icon from 'soapbox/components/icon' ;
2022-03-21 11:09:01 -07:00
import { Modal , Stack , Text } from 'soapbox/components/ui' ;
import ReplyIndicator from 'soapbox/features/compose/components/reply_indicator' ;
2020-03-27 13:59:38 -07:00
const messages = defineMessages ( {
cancel _reblog : { id : 'status.cancel_reblog_private' , defaultMessage : 'Un-repost' } ,
reblog : { id : 'status.reblog' , defaultMessage : 'Repost' } ,
} ) ;
2022-03-17 18:17:28 -07:00
export default @ injectIntl @ withRouter
2020-03-27 13:59:38 -07:00
class BoostModal extends ImmutablePureComponent {
static propTypes = {
2022-03-23 10:14:42 -07:00
status : ImmutablePropTypes . record . isRequired ,
2020-03-27 13:59:38 -07:00
onReblog : PropTypes . func . isRequired ,
onClose : PropTypes . func . isRequired ,
intl : PropTypes . object . isRequired ,
2022-03-17 18:17:28 -07:00
history : PropTypes . object ,
2020-03-27 13:59:38 -07:00
} ;
handleReblog = ( ) => {
this . props . onReblog ( this . props . status ) ;
this . props . onClose ( ) ;
}
handleAccountClick = ( e ) => {
if ( e . button === 0 && ! ( e . ctrlKey || e . metaKey ) ) {
e . preventDefault ( ) ;
this . props . onClose ( ) ;
2022-03-17 18:17:28 -07:00
this . props . history . push ( ` /@ ${ this . props . status . getIn ( [ 'account' , 'acct' ] ) } ` ) ;
2020-03-27 13:59:38 -07:00
}
}
handleStatusClick = ( e ) => {
if ( e . button === 0 && ! ( e . ctrlKey || e . metaKey ) ) {
e . preventDefault ( ) ;
this . props . onClose ( ) ;
2022-03-17 18:17:28 -07:00
this . props . history . push ( ` /@ ${ this . props . status . getIn ( [ 'account' , 'acct' ] ) } /posts/ ${ this . props . status . get ( 'url' ) } ` ) ;
2020-03-27 13:59:38 -07:00
}
}
2020-04-14 14:47:35 -07:00
render ( ) {
2020-03-27 13:59:38 -07:00
const { status , intl } = this . props ;
const buttonText = status . get ( 'reblogged' ) ? messages . cancel _reblog : messages . reblog ;
return (
2022-03-21 11:09:01 -07:00
< Modal
2022-04-19 13:24:12 -07:00
title = 'Repost?'
2022-03-21 11:09:01 -07:00
confirmationAction = { this . handleReblog }
confirmationText = { intl . formatMessage ( buttonText ) }
>
< Stack space = { 4 } >
< ReplyIndicator status = { status } hideActions / >
< Text >
< FormattedMessage id = 'boost_modal.combo' defaultMessage = 'You can press {combo} to skip this next time' values = { { combo : < span > Shift + < Icon id = 'retweet' / > < /span> }} / >
< / T e x t >
< / S t a c k >
< / M o d a l >
2020-03-27 13:59:38 -07:00
) ;
}
}