Sha256: a9b00e5d2dc29c44557b99177be99a2b78a79ecdb4e57c19d30ff6bdae41aa74

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

import React 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 }) => {
  if (status === CONNECTOR_STATUS.PENDING) {
    return (
      <Popover
        bodyContent={
          <div>
            {__('Cloud connector job is still running, you can view it here:')}
            <a href={jobLink} target="_blank" rel="noopener noreferrer">
              {__('Open job')}
            </a>
          </div>
        }
        aria-label="Popover with Link to cloud connector job"
        closeBtnAriaLabel="Close cloud connector Popover"
      >
        <Button variant="secondary">
          <Spinner size="sm" /> {__('Cloud Connector in progress')}
        </Button>
      </Popover>
    );
  }

  if (status === CONNECTOR_STATUS.RESOLVED) {
    return (
      <Button variant="secondary" isDisabled>
        {__('Cloud Connector is configured')}
      </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

1 entries across 1 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.15 webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js