Sha256: e0d153ef9a9c99e142b549a1ae97cbf388f59e2e8b5dc97a03bc9a4bfb7e91f3

Contents?: true

Size: 1.46 KB

Versions: 87

Compression:

Stored size: 1.46 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { translate as __ } from 'foremanReact/common/I18n';
import { LoadingState, Alert } from 'patternfly-react';
import { STATUS } from 'foremanReact/constants';
import HostItem from './components/HostItem';

const TargetingHosts = ({ apiStatus, items }) => {
  if (apiStatus === STATUS.ERROR) {
    return (
      <Alert type="error">
        {__(
          'There was an error while updating the status, try refreshing the page.'
        )}
      </Alert>
    );
  }

  const tableBodyRows = items.length ? (
    items.map(({ name, link, status, actions }) => (
      <HostItem
        key={name}
        name={name}
        link={link}
        status={status}
        actions={actions}
      />
    ))
  ) : (
    <tr>
      <td colSpan="3">{__('No hosts found.')}</td>
    </tr>
  );

  return (
    <LoadingState loading={!items.length && apiStatus === STATUS.PENDING}>
      <div>
        <table className="table table-bordered table-striped table-hover">
          <thead>
            <tr>
              <th>{__('Host')}</th>
              <th>{__('Status')}</th>
              <th>{__('Actions')}</th>
            </tr>
          </thead>
          <tbody>{tableBodyRows}</tbody>
        </table>
      </div>
    </LoadingState>
  );
};

TargetingHosts.propTypes = {
  apiStatus: PropTypes.string,
  items: PropTypes.array.isRequired,
};

TargetingHosts.defaultProps = {
  apiStatus: null,
};

export default TargetingHosts;

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
foreman_remote_execution-14.1.4 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-14.1.3 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-14.1.2 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-14.1.1 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-14.1.0 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-14.0.2 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-14.0.1 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-13.2.6 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-14.0.0 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-13.2.5 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-13.2.4 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-13.2.3 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-13.2.2 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-12.0.7 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-13.2.1 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-13.2.0 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-10.1.3 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-13.0.0 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-12.0.5 webpack/react_app/components/TargetingHosts/TargetingHosts.js
foreman_remote_execution-12.0.4 webpack/react_app/components/TargetingHosts/TargetingHosts.js