Sha256: 157bea31df607ea58972d30a28186ff7b5656dcbc617e392cb324b877c3e8e26

Contents?: true

Size: 1.49 KB

Versions: 15

Compression:

Stored size: 1.49 KB

Contents

import React from 'react';
import {
  Table,
  TableHeader,
  TableBody,
} from '@patternfly/react-table';
import PropTypes from 'prop-types';
import { STATUS } from 'foremanReact/constants';

import EmptyStateMessage from '../components/EmptyStateMessage';
import Loading from '../components/Loading';

const TableWrapper = ({
  status, cells, rows, error, emptyTitle, emptyBody, ...extraTableProps
}) => {
  if (status === STATUS.PENDING) return (<Loading />);
  // Can we display the error message?
  if (status === STATUS.ERROR) return (<EmptyStateMessage error={error} />);
  // Can we prevent flash of empty row message while rows are loading with data?
  if (status === STATUS.RESOLVED && rows.length === 0) {
    return (<EmptyStateMessage title={emptyTitle} body={emptyBody} />);
  }

  const tableProps = { cells, rows, ...extraTableProps };
  return (
    <Table
      aria-label="Content View Table"
      className="katello-pf4-table"
      {...tableProps}
    >
      <TableHeader />
      <TableBody />
    </Table>
  );
};

TableWrapper.propTypes = {
  status: PropTypes.string.isRequired,
  cells: PropTypes.arrayOf(PropTypes.oneOfType([
    PropTypes.shape({}),
    PropTypes.string])).isRequired,
  rows: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
  error: PropTypes.oneOfType([
    PropTypes.shape({}),
    PropTypes.string,
  ]),
  emptyBody: PropTypes.string.isRequired,
  emptyTitle: PropTypes.string.isRequired,
};

TableWrapper.defaultProps = {
  error: null,
};

export default TableWrapper;

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
katello-3.16.2 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.1.2 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.1.1 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.1 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc5.1 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc5 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc4.1 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc4 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc3.1 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc3 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc2.1 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc2 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc1.1 webpack/scenes/ContentViews/Table/TableWrapper.js
katello-3.16.0.rc1 webpack/scenes/ContentViews/Table/TableWrapper.js