2017-05-02 17:04:16 -07:00
|
|
|
import React from 'react';
|
2017-04-22 19:39:50 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2017-06-23 07:05:04 -07:00
|
|
|
import { injectIntl, FormattedMessage } from 'react-intl';
|
2017-12-03 23:26:40 -08:00
|
|
|
import Button from 'flavours/glitch/components/button';
|
2017-04-22 19:39:50 -07:00
|
|
|
|
2017-06-23 10:36:54 -07:00
|
|
|
@injectIntl
|
|
|
|
export default class ConfirmationModal extends React.PureComponent {
|
2017-04-22 19:39:50 -07:00
|
|
|
|
2017-05-12 05:44:10 -07:00
|
|
|
static propTypes = {
|
|
|
|
message: PropTypes.node.isRequired,
|
|
|
|
confirm: PropTypes.string.isRequired,
|
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
|
onConfirm: PropTypes.func.isRequired,
|
2017-05-20 08:31:47 -07:00
|
|
|
intl: PropTypes.object.isRequired,
|
2017-05-12 05:44:10 -07:00
|
|
|
};
|
|
|
|
|
2017-05-23 04:10:41 -07:00
|
|
|
componentDidMount() {
|
|
|
|
this.button.focus();
|
|
|
|
}
|
|
|
|
|
2017-05-12 05:44:10 -07:00
|
|
|
handleClick = () => {
|
2017-04-22 19:39:50 -07:00
|
|
|
this.props.onClose();
|
|
|
|
this.props.onConfirm();
|
|
|
|
}
|
|
|
|
|
2017-05-23 04:10:41 -07:00
|
|
|
handleCancel = () => {
|
2017-04-22 19:39:50 -07:00
|
|
|
this.props.onClose();
|
|
|
|
}
|
|
|
|
|
2017-05-23 04:10:41 -07:00
|
|
|
setRef = (c) => {
|
|
|
|
this.button = c;
|
|
|
|
}
|
|
|
|
|
2017-04-22 19:39:50 -07:00
|
|
|
render () {
|
2017-05-23 04:10:41 -07:00
|
|
|
const { message, confirm } = this.props;
|
2017-04-22 19:39:50 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='modal-root__modal confirmation-modal'>
|
|
|
|
<div className='confirmation-modal__container'>
|
|
|
|
{message}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='confirmation-modal__action-bar'>
|
2017-05-23 04:10:41 -07:00
|
|
|
<Button onClick={this.handleCancel} className='confirmation-modal__cancel-button'>
|
|
|
|
<FormattedMessage id='confirmation_modal.cancel' defaultMessage='Cancel' />
|
|
|
|
</Button>
|
|
|
|
<Button text={confirm} onClick={this.handleClick} ref={this.setRef} />
|
2017-04-22 19:39:50 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|