Sha256: a18ee78f15d5775aadcc9e5a8523363f15ed80473471419d798a6e0e96c60308

Contents?: true

Size: 1.95 KB

Versions: 41

Compression:

Stored size: 1.95 KB

Contents

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

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

const MainTable = ({
  status, cells, rows, error, emptyContentTitle, emptyContentBody,
  emptySearchTitle, emptySearchBody, searchIsActive, activeFilters,
  ...extraTableProps
}) => {
  const isFiltering = activeFilters || searchIsActive;
  if (status === STATUS.PENDING) return (<Loading />);
  // Can we display the error message?
  if (status === STATUS.ERROR) return (<EmptyStateMessage error={error} />);
  if (status === STATUS.RESOLVED && isFiltering && rows.length === 0) {
    return (<EmptyStateMessage
      title={emptySearchTitle}
      body={emptySearchBody}
      search
    />);
  }
  if (status === STATUS.RESOLVED && rows.length === 0) {
    return (<EmptyStateMessage title={emptyContentTitle} body={emptyContentBody} />);
  }

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

MainTable.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,
  ]),
  emptyContentTitle: PropTypes.string.isRequired,
  emptyContentBody: PropTypes.string.isRequired,
  emptySearchTitle: PropTypes.string.isRequired,
  emptySearchBody: PropTypes.string.isRequired,
  searchIsActive: PropTypes.bool,
  activeFilters: PropTypes.bool,
};

MainTable.defaultProps = {
  error: null,
  searchIsActive: false,
  activeFilters: false,
};

export default MainTable;

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
katello-4.2.2 webpack/components/Table/MainTable.js
katello-4.2.1 webpack/components/Table/MainTable.js
katello-4.2.0.1 webpack/components/Table/MainTable.js
katello-4.1.4 webpack/components/Table/MainTable.js
katello-4.0.3 webpack/components/Table/MainTable.js
katello-4.2.0.1.rc3 webpack/components/Table/MainTable.js
katello-3.18.5 webpack/components/Table/MainTable.js
katello-4.2.0.1.rc2 webpack/components/Table/MainTable.js
katello-4.2.0.rc2 webpack/components/Table/MainTable.js
katello-4.1.3 webpack/components/Table/MainTable.js
katello-4.2.0.rc1 webpack/components/Table/MainTable.js
katello-4.0.2.1 webpack/components/Table/MainTable.js
katello-4.1.2.1 webpack/components/Table/MainTable.js
katello-4.0.2 webpack/components/Table/MainTable.js
katello-4.1.2 webpack/components/Table/MainTable.js
katello-3.18.4 webpack/components/Table/MainTable.js
katello-4.1.1 webpack/components/Table/MainTable.js
katello-4.1.0 webpack/components/Table/MainTable.js
katello-4.0.1.2 webpack/components/Table/MainTable.js
katello-3.18.3.1 webpack/components/Table/MainTable.js