Sha256: a957e284d8cfc8d91ff110966e195697908c5c921a8deb47902fde517fd0a3c5

Contents?: true

Size: 1.74 KB

Versions: 84

Compression:

Stored size: 1.74 KB

Contents

import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Spinner, Button, Popover } from '@patternfly/react-core';
import { translate as __ } from 'foremanReact/common/I18n';
import { CONNECTOR_STATUS } from './CloudConnectorConstants';

export const CloudConnectorButton = ({ status, onClick, jobLink }) => {
  const [isPopoverVisible, setIsPopoverVisible] = useState(false);
  if (status === CONNECTOR_STATUS.PENDING) {
    return (
      <Popover
        isVisible={isPopoverVisible}
        shouldClose={() => setIsPopoverVisible(false)}
        bodyContent={
          <div>
            {__('Cloud connector setup has started: ')}
            <a href={jobLink} target="_blank" rel="noopener noreferrer">
              {__('view the job in progress')}
            </a>
          </div>
        }
        aria-label="Popover with Link to cloud connector job"
        closeBtnAriaLabel="Close cloud connector Popover"
      >
        <div
          className="cloud-connector-pending-button"
          onMouseEnter={() => setIsPopoverVisible(true)}
        >
          <Button variant="secondary" isDisabled>
            <Spinner size="sm" /> {__('Cloud Connector is in progress')}
          </Button>
        </div>
      </Popover>
    );
  }

  if (status === CONNECTOR_STATUS.RESOLVED) {
    return (
      <Button variant="secondary" onClick={onClick}>
        {__('Reconfigure Cloud Connector')}
      </Button>
    );
  }

  return (
    <Button variant="secondary" onClick={onClick}>
      {__('Configure Cloud Connector')}
    </Button>
  );
};

CloudConnectorButton.propTypes = {
  status: PropTypes.string.isRequired,
  onClick: PropTypes.func.isRequired,
  jobLink: PropTypes.string,
};
CloudConnectorButton.defaultProps = {
  jobLink: '',
};

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
foreman_rh_cloud-5.0.28 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-4.0.27 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.26 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-4.0.26 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-4.0.25.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.25 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-4.0.25 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.24.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-4.0.24.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.24 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-4.0.24 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.23 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-4.0.23 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.22 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-4.0.22 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-4.0.21.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.21.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.21 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.20 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-3.0.19 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js