Sha256: 970f854249c37357927603fcd1d845cc89773c1768bb7a1283da448c5feca99d

Contents?: true

Size: 1.54 KB

Versions: 7

Compression:

Stored size: 1.54 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { Modal, Button, ModalVariant, Spinner } from '@patternfly/react-core';

import { translate as __ } from 'foremanReact/common/I18n';

import './ConfirmModal.scss';

const ConfirmModal = props => {
  const [callMutation, { loading }] = props.prepareMutation();

  const actions = [
    <Button
      ouiaId={`oscap-conf-modal-${props.record?.id}-confirm`}
      key="confirm"
      variant="primary"
      onClick={() => props.onConfirm(callMutation, props.record.id)}
      isDisabled={loading}
    >
      {__('Confirm')}
    </Button>,
    <Button
      ouiaId={`oscap-conf-modal-${props.record?.id}-cancel`}
      key="cancel"
      variant="link"
      onClick={event => props.onClose()}
      isDisabled={loading}
    >
      {__('Cancel')}
    </Button>,
  ];

  if (loading) {
    actions.push(<Spinner key="spinner" size="lg" />);
  }

  return (
    <Modal
      ouiaId={`oscap-conf-modal-${props.record?.id}`}
      variant={ModalVariant.medium}
      title={props.title}
      isOpen={props.isOpen}
      className="foreman-modal"
      showClose={false}
      actions={actions}
    >
      {props.text}
    </Modal>
  );
};

ConfirmModal.propTypes = {
  prepareMutation: PropTypes.func.isRequired,
  onConfirm: PropTypes.func.isRequired,
  record: PropTypes.object,
  onClose: PropTypes.func.isRequired,
  title: PropTypes.string.isRequired,
  isOpen: PropTypes.bool.isRequired,
  text: PropTypes.string.isRequired,
};

ConfirmModal.defaultProps = {
  record: null,
};

export default ConfirmModal;

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
foreman_openscap-10.0.3 webpack/components/ConfirmModal.js
foreman_openscap-10.0.2 webpack/components/ConfirmModal.js
foreman_openscap-10.0.1 webpack/components/ConfirmModal.js
foreman_openscap-10.0.0 webpack/components/ConfirmModal.js
foreman_openscap-9.0.4 webpack/components/ConfirmModal.js
foreman_openscap-9.0.3 webpack/components/ConfirmModal.js
foreman_openscap-9.0.2 webpack/components/ConfirmModal.js