import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table'; import t_global_background_color_secondary_default from '@patternfly/react-tokens/dist/esm/t_global_background_color_secondary_default'; interface Repository { name: string; branches: string | null; prs: string | null; workspaces: string; lastCommit: string; } export const TableMisc: React.FunctionComponent = () => { // In real usage, this data would come from some external source like an API via props. const repositories: Repository[] = [ { name: 'one', branches: 'two', prs: 'three', workspaces: 'four', lastCommit: 'five' }, { 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' } ]; const columnNames = { name: 'Repositories', branches: 'Branches', prs: 'Pull requests', workspaces: 'Workspaces', lastCommit: 'Last commit' }; return ( {repositories.map((repo, rowIndex) => { const isOddRow = (rowIndex + 1) % 2; const customStyle = { backgroundColor: t_global_background_color_secondary_default.var }; // Some arbitrary logic to demonstrate that cell styles can be based on anything const nameColSpan = repo.branches === null && repo.prs === null ? 3 : 1; const lastCommitTextCenter = rowIndex !== 2; return ( ); })}
{columnNames.name} {columnNames.branches} More information on pull requests ), ariaLabel: 'More information on pull requests', popoverProps: { headerContent: columnNames.prs, footerContent: Click here for even more info } }} > {columnNames.prs} {columnNames.workspaces} {columnNames.lastCommit}
{repo.name} {repo.branches}
); };