Sha256: 54aa2624ecc7d9d33f7cc825d8010b1ec357e4cc012551cdd77079135ab17740

Contents?: true

Size: 1.46 KB

Versions: 40

Compression:

Stored size: 1.46 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { Spinner, Button } from '@patternfly/react-core';
import { ExclamationTriangleIcon, RedoIcon } from '@patternfly/react-icons';
import { STATUS } from 'foremanReact/constants';
import SyncModal from './components/Modal';
import { SYNC_BUTTON_TEXT } from '../../../../ForemanInventoryConstants';

class SyncButton extends React.Component {
  state = {
    showModal: false,
  };

  toggleModal = () => {
    this.setState({ showModal: !this.state.showModal });
  };

  render() {
    const { cloudToken, handleSync, status } = this.props;

    const handleClick = !cloudToken ? this.toggleModal : handleSync;
    return (
      <React.Fragment>
        <SyncModal show={this.state.showModal} toggleModal={this.toggleModal} />
        <Button
          className="sync_button"
          onClick={handleClick}
          size="lg"
          isDisabled={status === STATUS.PENDING}
          variant="secondary"
        >
          {!cloudToken && (
            <span>
              <ExclamationTriangleIcon />{' '}
            </span>
          )}
          {status === STATUS.PENDING ? <Spinner size="sm" /> : <RedoIcon />}
          {SYNC_BUTTON_TEXT}
        </Button>
      </React.Fragment>
    );
  }
}

SyncButton.propTypes = {
  cloudToken: PropTypes.bool,
  handleSync: PropTypes.func.isRequired,
  status: PropTypes.string,
};

SyncButton.defaultProps = {
  cloudToken: false,
  status: null,
};

export default SyncButton;

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-3.0.33 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-4.0.35 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-5.0.35 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-5.0.34 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-5.0.33 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-3.0.32 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-4.0.32 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-5.0.32 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-4.0.31 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-5.0.31 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-5.0.30 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-4.0.30 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-3.0.29 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-4.0.29 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-5.0.29 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-3.0.28 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-5.0.28 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-4.0.27 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-3.0.26 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js