You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { injectIntl, FormattedMessage } from 'react-intl';
  4. import Button from 'flavours/glitch/components/button';
  5. @injectIntl
  6. export default class ConfirmationModal extends React.PureComponent {
  7. static propTypes = {
  8. message: PropTypes.node.isRequired,
  9. confirm: PropTypes.string.isRequired,
  10. onClose: PropTypes.func.isRequired,
  11. onConfirm: PropTypes.func.isRequired,
  12. intl: PropTypes.object.isRequired,
  13. };
  14. componentDidMount() {
  15. this.button.focus();
  16. }
  17. handleClick = () => {
  18. this.props.onClose();
  19. this.props.onConfirm();
  20. }
  21. handleCancel = () => {
  22. this.props.onClose();
  23. }
  24. setRef = (c) => {
  25. this.button = c;
  26. }
  27. render () {
  28. const { message, confirm } = this.props;
  29. return (
  30. <div className='modal-root__modal confirmation-modal'>
  31. <div className='confirmation-modal__container'>
  32. {message}
  33. </div>
  34. <div className='confirmation-modal__action-bar'>
  35. <Button onClick={this.handleCancel} className='confirmation-modal__cancel-button'>
  36. <FormattedMessage id='confirmation_modal.cancel' defaultMessage='Cancel' />
  37. </Button>
  38. <Button text={confirm} onClick={this.handleClick} ref={this.setRef} />
  39. </div>
  40. </div>
  41. );
  42. }
  43. }