gab-social/app/javascript/gabsocial/components/modal/block_domain_modal.js

51 lines
1.7 KiB
JavaScript
Raw Normal View History

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}' },
blockDomainConfirm: { id: 'confirmations.domain_block.confirm', defaultMessage: 'Hide entire domain' },
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) => ({
onConfirm(domain) {
dispatch(blockDomain(domain))
},
})
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-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
intl: PropTypes.object.isRequired,
}
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
2020-04-02 17:57:04 +01:00
console.log("this.props: ", 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
/>
)
}
}