Sha256: 07e24b744eca39f079df07548d91d47aca149ee80a5b85ebe0b4d940be6ee9fb

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Icon, Button, MessageDialog } from 'patternfly-react';
import { translate as __ } from 'foremanReact/common/I18n';

const DeleteTableEntry = ({
  hidden,
  disabled,
  onDeleteTableEntry,
  additionalData,
}) => {
  const [showModal, setShowModal] = useState(false);
  const toggleModal = () => setShowModal(!showModal);

  if (hidden) {
    return null;
  }

  return (
    <span>
      <MessageDialog
        show={showModal}
        onHide={toggleModal}
        primaryAction={() => onDeleteTableEntry(additionalData)}
        secondaryAction={toggleModal}
        primaryActionButtonContent={__('Confirm')}
        secondaryActionButtonContent={__('Cancel')}
        title={__('Confirm action')}
        primaryContent={__('Are you sure you wish to delete this item?')}
      />
      <Button bsStyle="default" disabled={disabled} onClick={toggleModal}>
        <Icon type="pf" name="delete" title={__('Delete entry')} />
      </Button>
    </span>
  );
};

DeleteTableEntry.propTypes = {
  hidden: PropTypes.bool.isRequired,
  disabled: PropTypes.bool.isRequired,
  onDeleteTableEntry: PropTypes.func.isRequired,
  additionalData: PropTypes.object.isRequired,
};

export default DeleteTableEntry;

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_acd-0.11.0 webpack/components/common/DeleteTableEntry.js
foreman_acd-0.10.0 webpack/components/common/DeleteTableEntry.js