闭社主体 forked from https://github.com/tootsuite/mastodon
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.

51 lines
1.4 KiB

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