Sha256: 7a815768b414874a578bd2c8865725762eecbc1ef66a0a699b3277b3d565b4ac

Contents?: true

Size: 1.33 KB

Versions: 9

Compression:

Stored size: 1.33 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { Button, Icon, Spinner } from 'patternfly-react';
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} bsSize="lg">
          {!cloudToken && (
            <span>
              <Icon name="warning" />{' '}
            </span>
          )}
          {status === STATUS.PENDING ? (
            <Spinner loading size="xs" />
          ) : (
            <Icon name="refresh" />
          )}
          {SYNC_BUTTON_TEXT}
        </Button>
      </React.Fragment>
    );
  }
}

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

SyncButton.defaultProps = {
  status: null,
};

export default SyncButton;

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_rh_cloud-0.9.12 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-1.0.12 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-2.0.12 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-0.9.11 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-1.0.11 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-2.0.11 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-0.9.10 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-1.0.10 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
foreman_rh_cloud-2.0.10 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js