| 1 |
import { Table, TableHeader, TableBody, TableProps } from '@patternfly/react-table/deprecated'; |
| 2 |
interface Repository { |
| 3 |
name: string; |
| 4 |
branches: string; |
| 5 |
prs: string; |
| 6 |
workspaces: string; |
| 7 |
lastCommit: string; |
| 8 |
} |
| 9 |
|
| 10 |
export const LegacyTableStriped: React.FunctionComponent = () => { |
| 11 |
// In real usage, this data would come from some external source like an API via props. |
| 12 |
const repositories: Repository[] = [ |
| 13 |
{ |
| 14 |
name: 'Repository one', |
| 15 |
branches: 'Branch one', |
| 16 |
prs: 'PR one', |
| 17 |
workspaces: 'Workspace one', |
| 18 |
lastCommit: 'Commit one' |
| 19 |
}, |
| 20 |
{ |
| 21 |
name: 'Repository two', |
| 22 |
branches: 'Branch two', |
| 23 |
prs: 'PR two', |
| 24 |
workspaces: 'Workspace two', |
| 25 |
lastCommit: 'Commit two' |
| 26 |
}, |
| 27 |
{ |
| 28 |
name: 'Repository three', |
| 29 |
branches: 'Branch three', |
| 30 |
prs: 'PR three', |
| 31 |
workspaces: 'Workspace three', |
| 32 |
lastCommit: 'Commit three' |
| 33 |
} |
| 34 |
]; |
| 35 |
|
| 36 |
const columns: TableProps['cells'] = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit']; |
| 37 |
const rows: TableProps['rows'] = repositories.map((repo) => [ |
| 38 |
repo.name, |
| 39 |
repo.branches, |
| 40 |
repo.prs, |
| 41 |
repo.workspaces, |
| 42 |
repo.lastCommit |
| 43 |
]); |
| 44 |
|
| 45 |
return ( |
| 46 |
<Table aria-label="Simple Table" cells={columns} rows={rows} isStriped> |
| 47 |
<TableHeader /> |
| 48 |
<TableBody /> |
| 49 |
</Table> |
| 50 |
); |
| 51 |
}; |