2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-03-24 04:39:12 +00:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl'
|
|
|
|
import { makeGetAccount } from '../../selectors'
|
|
|
|
import { blockAccount } from '../../actions/accounts'
|
|
|
|
import ConfirmationModal from './confirmation_modal'
|
|
|
|
|
2020-08-17 21:07:16 +01:00
|
|
|
class BlockAccountModal extends React.PureComponent {
|
2020-03-24 04:39:12 +00:00
|
|
|
|
|
|
|
handleClick = () => {
|
|
|
|
this.props.onConfirm(this.props.account)
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-04-07 02:53:23 +01:00
|
|
|
const { account, intl, onClose } = this.props
|
2020-03-24 04:39:12 +00:00
|
|
|
|
|
|
|
const title = intl.formatMessage(messages.title, {
|
|
|
|
name: !!account ? account.get('acct') : '',
|
|
|
|
})
|
|
|
|
const message = intl.formatMessage(messages.muteMessage, {
|
|
|
|
name: !!account ? account.get('acct') : '',
|
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ConfirmationModal
|
|
|
|
title={title}
|
|
|
|
message={message}
|
|
|
|
confirm={intl.formatMessage(messages.block)}
|
|
|
|
onConfirm={this.handleClick}
|
2020-04-07 02:53:23 +01:00
|
|
|
onClose={onClose}
|
2020-03-24 04:39:12 +00:00
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-08-18 18:07:47 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
title: { id: 'block_title', defaultMessage: 'Block {name}' },
|
|
|
|
muteMessage: { id: 'confirmations.block.message', defaultMessage: 'Are you sure you want to block {name}?' },
|
|
|
|
block: { id: 'confirmations.block.confirm', defaultMessage: 'Block' },
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapStateToProps = (state, { accountId }) => ({
|
|
|
|
account: makeGetAccount()(state, accountId),
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onConfirm(account) {
|
|
|
|
dispatch(blockAccount(account.get('id')))
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
BlockAccountModal.propTypes = {
|
|
|
|
account: PropTypes.object.isRequired,
|
|
|
|
onConfirm: PropTypes.func.isRequired,
|
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(BlockAccountModal))
|