import { useState } from 'react'; import { info, textCenter, ICell } from '@patternfly/react-table'; import { Table, TableHeader, TableBody, TableProps } from '@patternfly/react-table/deprecated'; import styles from '@patternfly/react-styles/css/components/Table/table'; interface Repository { name: string; branches: string | null; prs: string | null; workspaces: string; lastCommit: string; } export const LegacyTableClickable: React.FunctionComponent = () => { // In real usage, this data would come from some external source like an API via props. const repositories: Repository[] = [ { name: 'Repository one', branches: 'Branch one', prs: 'PR one', workspaces: 'Workspace one', lastCommit: 'Commit one' }, { name: 'one - 2', branches: null, prs: null, workspaces: 'four - 2', lastCommit: 'five - 2' }, { name: 'one - 3', branches: 'two - 3', prs: 'three - 3', workspaces: 'four - 3', lastCommit: 'five - 3 (not centered)' } ]; // In this example, selected rows are tracked by the repo names from each row. This could be any unique identifier. // This is to prevent state from being based on row order index in case we later add sorting. const [selectedRepoName, setSelectedRepoName] = useState(''); const columns: TableProps['cells'] = [ { title: 'Repositories', transforms: [ info({ tooltip: 'More information about repositories', className: 'repositories-info-tip', tooltipProps: { isContentLeftAligned: true } }) ] }, 'Branches', { title: 'Pull requests', transforms: [ info({ popover: (