Sha256: a02f3778b6a4edaf50d20da063af05745fa5ae29f996cd1c52c49a2ebd2bf5c0
Contents?: true
Size: 1.9 KB
Versions: 10
Compression:
Stored size: 1.9 KB
Contents
import React from 'react'; import PropTypes from 'prop-types'; import { Table as PfTable } from 'patternfly-react'; import { noop } from 'foremanReact/common/helpers'; import EmptyState from 'foremanReact/components/common/EmptyState'; import Pagination from 'foremanReact/components/Pagination'; import TableBody from './TableBody'; const Table = ({ columns, rows, emptyState, bodyMessage, children, itemCount, pagination, onPaginationChange, ...props }) => { if (rows.length === 0 && bodyMessage === undefined) { return <EmptyState {...emptyState} />; } const shouldRenderPagination = itemCount && pagination; const body = children || [ <PfTable.Header key="header" />, <TableBody key="body" columns={columns} rows={rows} message={bodyMessage} rowKey="id" />, ]; return ( <div> <PfTable.PfProvider columns={columns} className="table-fixed neat-table-cells" striped bordered hover {...props} > {body} </PfTable.PfProvider> {shouldRenderPagination && ( // eslint-disable-next-line @theforeman/rules/require-ouiaid <Pagination itemCount={itemCount} onChange={onPaginationChange} {...pagination} /> )} </div> ); }; Table.propTypes = { columns: PropTypes.arrayOf(PropTypes.shape({})).isRequired, rows: PropTypes.arrayOf(PropTypes.shape({})).isRequired, emptyState: PropTypes.object, // eslint-disable-line react/forbid-prop-types pagination: PropTypes.object, // eslint-disable-line react/forbid-prop-types bodyMessage: PropTypes.node, children: PropTypes.node, itemCount: PropTypes.number, onPaginationChange: PropTypes.func, }; Table.defaultProps = { emptyState: undefined, pagination: undefined, bodyMessage: undefined, children: undefined, itemCount: undefined, onPaginationChange: noop, }; export default Table;
Version data entries
10 entries across 10 versions & 1 rubygems