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-10.0.3 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-11.0.3 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-9.0.59 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-11.0.2 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-11.0.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-11.0.0 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-9.0.58 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-10.0.2 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-9.0.57 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-10.0.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-9.0.56 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-9.0.55 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-9.0.54 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-9.0.53 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-9.0.52 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-8.0.52 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-9.0.51 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-8.0.51 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-7.0.48 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
foreman_rh_cloud-7.0.47 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js