Blame components/Modal/DeleteBlueprint.js

Packit Service eebd6f
import React from "react";
Packit Service eebd6f
import { Modal } from "patternfly-react";
Packit Service eebd6f
import { connect } from "react-redux";
Packit Service eebd6f
import { FormattedMessage, injectIntl } from "react-intl";
Packit Service eebd6f
import PropTypes from "prop-types";
Packit Service eebd6f
Packit Service eebd6f
import { deletingBlueprint } from "../../core/actions/blueprints";
Packit Service eebd6f
Packit Service eebd6f
class DeleteBlueprint extends React.Component {
Packit Service eebd6f
  constructor(props) {
Packit Service eebd6f
    super(props);
Packit Service eebd6f
    this.state = {
Packit Service eebd6f
      showModal: false,
Packit Service eebd6f
    };
Packit Service eebd6f
    this.open = this.open.bind(this);
Packit Service eebd6f
    this.close = this.close.bind(this);
Packit Service eebd6f
  }
Packit Service eebd6f
Packit Service eebd6f
  open() {
Packit Service eebd6f
    this.setState({ showModal: true });
Packit Service eebd6f
  }
Packit Service eebd6f
Packit Service eebd6f
  close() {
Packit Service eebd6f
    this.setState({ showModal: false });
Packit Service eebd6f
  }
Packit Service eebd6f
Packit Service eebd6f
  handleDelete(event, blueprint) {
Packit Service eebd6f
    this.props.deletingBlueprint(blueprint);
Packit Service eebd6f
    this.close();
Packit Service eebd6f
  }
Packit Service eebd6f
Packit Service eebd6f
  render() {
Packit Service eebd6f
    return (
Packit Service eebd6f
      <>
Packit Service eebd6f
        
Packit Service eebd6f
          <FormattedMessage defaultMessage="Delete" />
Packit Service eebd6f
        
Packit Service eebd6f
        <Modal show={this.state.showModal} onHide={this.close} id="cmpsr-modal-delete">
Packit Service eebd6f
          <Modal.Header>
Packit Service eebd6f
            <Modal.CloseButton onClick={this.close} />
Packit Service eebd6f
            <Modal.Title>
Packit Service eebd6f
              <FormattedMessage defaultMessage="Delete Blueprint" />
Packit Service eebd6f
            </Modal.Title>
Packit Service eebd6f
          </Modal.Header>
Packit Service eebd6f
          <Modal.Body>
Packit Service eebd6f
            

Packit Service eebd6f
              
Packit Service eebd6f
                defaultMessage="Are you sure you want to delete the blueprint {name}?"
Packit Service eebd6f
                values={{
Packit Service eebd6f
                  name: {this.props.blueprint.name},
Packit Service eebd6f
                }}
Packit Service eebd6f
              />
Packit Service eebd6f
            

Packit Service eebd6f
            <FormattedMessage defaultMessage="This action cannot be undone." tagName="p" />
Packit Service eebd6f
          </Modal.Body>
Packit Service eebd6f
          <Modal.Footer>
Packit Service eebd6f
            <button type="button" className="btn btn-default" onClick={this.close}>
Packit Service eebd6f
              <FormattedMessage defaultMessage="Cancel" />
Packit Service eebd6f
            </button>
Packit Service eebd6f
            
Packit Service eebd6f
              type="button"
Packit Service eebd6f
              className="btn btn-danger"
Packit Service eebd6f
              data-dismiss="modal"
Packit Service eebd6f
              onClick={(e) => this.handleDelete(e, this.props.blueprint.id)}
Packit Service eebd6f
            >
Packit Service eebd6f
              <FormattedMessage defaultMessage="Delete" />
Packit Service eebd6f
            </button>
Packit Service eebd6f
          </Modal.Footer>
Packit Service eebd6f
        </Modal>
Packit Service eebd6f
      
Packit Service eebd6f
    );
Packit Service eebd6f
  }
Packit Service eebd6f
}
Packit Service eebd6f
Packit Service eebd6f
const makeMapStateToProps = (state) => {
Packit Service eebd6f
  return state;
Packit Service eebd6f
};
Packit Service eebd6f
Packit Service eebd6f
DeleteBlueprint.propTypes = {
Packit Service eebd6f
  deletingBlueprint: PropTypes.func,
Packit Service eebd6f
  blueprint: PropTypes.shape({
Packit Service eebd6f
    id: PropTypes.string,
Packit Service eebd6f
    name: PropTypes.string,
Packit Service eebd6f
  }),
Packit Service eebd6f
};
Packit Service eebd6f
Packit Service eebd6f
DeleteBlueprint.defaultProps = {
Packit Service eebd6f
  deletingBlueprint() {},
Packit Service eebd6f
  blueprint: {},
Packit Service eebd6f
};
Packit Service eebd6f
Packit Service eebd6f
const mapDispatchToProps = (dispatch) => ({
Packit Service eebd6f
  deletingBlueprint: (blueprint) => {
Packit Service eebd6f
    dispatch(deletingBlueprint(blueprint));
Packit Service eebd6f
  },
Packit Service eebd6f
});
Packit Service eebd6f
Packit Service eebd6f
export default connect(makeMapStateToProps, mapDispatchToProps)(injectIntl(DeleteBlueprint));