2020-03-24 04:39:12 +00:00
import { injectIntl , defineMessages } from 'react-intl'
2020-04-02 17:57:04 +01:00
import { blockDomain } from '../../actions/domain_blocks'
import ConfirmationModal from './confirmation_modal'
2020-03-24 04:39:12 +00:00
const messages = defineMessages ( {
2020-04-02 17:57:04 +01:00
blockDomain : { id : 'block_domain' , defaultMessage : 'Block {domain}' } ,
2020-05-01 06:50:27 +01:00
blockDomainConfirm : { id : 'confirmations.domain_block.confirm' , defaultMessage : 'Block entire domain' } ,
2020-04-02 17:57:04 +01:00
blockDomainMessage : { id : 'confirmations.domain_block.message' , defaultMessage : 'Are you really, really sure you want to block the entire {domain}? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed.' } ,
2020-03-24 04:39:12 +00:00
cancel : { id : 'confirmation_modal.cancel' , defaultMessage : 'Cancel' } ,
} )
2020-04-11 23:29:19 +01:00
const mapDispatchToProps = ( dispatch ) => ( {
2020-05-01 06:50:27 +01:00
onConfirm : ( domain ) => dispatch ( blockDomain ( domain ) ) ,
2020-04-11 23:29:19 +01:00
} )
2020-03-24 04:39:12 +00:00
export default
2020-04-02 17:57:04 +01:00
@ connect ( null , mapDispatchToProps )
2020-03-24 04:39:12 +00:00
@ injectIntl
class BlockDomainModal extends PureComponent {
static propTypes = {
2020-04-02 17:57:04 +01:00
domain : PropTypes . string . isRequired ,
2020-05-01 06:50:27 +01:00
intl : PropTypes . object . isRequired ,
2020-03-24 04:39:12 +00:00
onConfirm : PropTypes . func . isRequired ,
2020-04-02 17:57:04 +01:00
onClose : PropTypes . func . isRequired ,
2020-03-24 04:39:12 +00:00
}
handleClick = ( ) => {
2020-04-02 17:57:04 +01:00
this . props . onConfirm ( this . props . domain )
2020-03-24 04:39:12 +00:00
}
render ( ) {
2020-04-02 17:57:04 +01:00
const { onClose , domain , intl } = this . props
2020-03-24 04:39:12 +00:00
return (
< ConfirmationModal
2020-04-02 17:57:04 +01:00
title = { intl . formatMessage ( messages . blockDomain , { domain } ) }
message = { intl . formatMessage ( messages . blockDomainMessage , { domain } ) }
confirm = { intl . formatMessage ( messages . blockDomainConfirm ) }
onConfirm = { this . handleClick }
onClose = { onClose }
2020-03-24 04:39:12 +00:00
/ >
)
}
}