/* eslint-disable no-console */ import { FunctionComponent } from 'react'; import { ActionsColumn, Caption, IActions, Table, TableGridBreakpoint, Td, Th, Thead, Tr } from '@patternfly/react-table'; import { CellMeasurerCache, CellMeasurer } from 'react-virtualized'; import { AutoSizer, VirtualTableBody } from '@patternfly/react-virtualized-extension'; export const ActionsExample: FunctionComponent = () => { interface RowType { disableActions: boolean; id: string; cells: string[]; } const rows: RowType[] = []; for (let i = 0; i < 100; i++) { rows.push({ disableActions: i % 3 === 2, id: `actions-row-${i}`, cells: [`one-${i}`, `two-${i}`, `three-${i}`, `four-${i}`, `five-${i}`] }); } const columns = ['Name', 'Namespace', 'Labels', 'Status', 'Pod Selector']; const actions: IActions = [ { title: 'Some action', onClick: (_event, rowId, _rowData, _extra) => console.log('clicked on Some action, on row: ', rowId) }, { title:
Another action
, onClick: (_event, rowId, _rowData, _extra) => console.log('clicked on Another action, on row: ', rowId) }, { isSeparator: true }, { title: 'Third action', onClick: (_event, rowId, _rowData, _extra) => console.log('clicked on Third action, on row: ', rowId) } ]; const measurementCache = new CellMeasurerCache({ fixedWidth: true, minHeight: 44, keyMapper: (rowIndex) => rowIndex }); const rowRenderer = ({ index: rowIndex, _isScrolling, key, style, parent }) => ( {columns.map((col, index) => ( {rows[rowIndex].cells[index]} ))} ); return (
Actions VirtualizedTable
{columns[0]} {columns[1]} {columns[2]} {columns[3]} {columns[4]}
{({ width }) => ( )}
); };