Sha256: f318a9c1af91c2971acd3bd92f9dd7bb3ea8df2e78a98831ca7c8c20d88dd45e

Contents?: true

Size: 1.89 KB

Versions: 23

Compression:

Stored size: 1.89 KB

Contents

import React, {
  useState,
} from 'react';
import PropTypes from 'prop-types';
import { Dropdown, DropdownItem, KebabToggle, DropdownPosition, Split, Icon, Text } from '@patternfly/react-core';
import { UndoIcon, TrashIcon } from '@patternfly/react-icons';
import { noop } from 'foremanReact/common/helpers';
import { translate as __ } from 'foremanReact/common/I18n';

const DeleteMenu = ({ handleModalToggle, akId }) => {
  const [isOpen, setIsOpen] = useState(false);
  const onToggle = (isOpenValue) => {
    setIsOpen(isOpenValue);
  };
  const onFocus = () => {
    const element = document.getElementById('toggle-kebab');
    element.focus();
  };
  const onSelect = () => {
    setIsOpen(false);
    onFocus();
  };
  const dropdownItems = [
    <DropdownItem
      ouiaId="delete-menu-option"
      aria-label="delete-link"
      key="delete-link"
      component="button"
      onClick={handleModalToggle}
    >
      <Split hasGutter>
        <Icon>
          <TrashIcon />
        </Icon>
        <Text ouiaId="delete-text">
          {__('Delete')}
        </Text>
      </Split>
    </DropdownItem>,
    <DropdownItem
      ouiaId="ak-legacy-ui"
      key="ak-legacy-ui-link"
      href={`../../../activation_keys/${akId}`}
    >
      <Split hasGutter>
        <Icon>
          <UndoIcon />
        </Icon>
        <Text ouiaId="delete-text">
          {__('Legacy UI')}
        </Text>
      </Split>
    </DropdownItem>];
  return (
    <Dropdown
      ouiaId="dekete-action"
      onSelect={onSelect}
      position={DropdownPosition.right}
      toggle={<KebabToggle id="toggle-kebab" aria-label="delete-toggle" onToggle={onToggle} />}
      isOpen={isOpen}
      isPlain
      dropdownItems={dropdownItems}
    />
  );
};

DeleteMenu.propTypes = {
  handleModalToggle: PropTypes.func,
  akId: PropTypes.string.isRequired,
};

DeleteMenu.defaultProps = {
  handleModalToggle: noop,
};

export default DeleteMenu;

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
katello-4.15.0.rc2 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.15.0.rc1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.14.1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.14.0 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.14.0.rc3 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.14.0.rc2 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.14.0.rc1.1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.14.0.rc1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.13.1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.13.0 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.12.1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.13.0.rc1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.12.0 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.12.0.rc3 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.12.0.rc2 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.12.0.rc1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.11.1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.11.0 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.11.0.rc2 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
katello-4.11.0.rc1 webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js