@@ -2,6 +2,7 @@ import React from 'react';
22import { DataViewTable , DataViewTr , DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable' ;
33import { ExclamationCircleIcon } from '@patternfly/react-icons' ;
44import { Button } from '@patternfly/react-core' ;
5+ import { ActionsColumn } from '@patternfly/react-table' ;
56
67interface Repository {
78 id : number ;
@@ -21,14 +22,33 @@ const repositories: Repository[] = [
2122 { id : 6 , name : 'Repository six' , branches : 'Branch six' , prs : 'Pull request six' , workspaces : 'Workspace six' , lastCommit : 'Timestamp six' }
2223] ;
2324
25+ const rowActions = [
26+ {
27+ title : 'Some action' ,
28+ onClick : ( ) => console . log ( 'clicked on Some action' ) // eslint-disable-line no-console
29+ } ,
30+ {
31+ title : < div > Another action</ div > ,
32+ onClick : ( ) => console . log ( 'clicked on Another action' ) // eslint-disable-line no-console
33+ } ,
34+ {
35+ isSeparator : true
36+ } ,
37+ {
38+ title : 'Third action' ,
39+ onClick : ( ) => console . log ( 'clicked on Third action' ) // eslint-disable-line no-console
40+ }
41+ ] ;
42+
2443// you can also pass props to Tr by returning { row: DataViewTd[], props: TrProps } }
2544const rows : DataViewTr [ ] = repositories . map ( ( { id, name, branches, prs, workspaces, lastCommit } ) => [
2645 { id, cell : workspaces , props : { favorites : { isFavorited : true } } } ,
2746 { cell : < Button href = '#' variant = 'link' isInline > { name } </ Button > } ,
2847 branches ,
2948 prs ,
3049 workspaces ,
31- lastCommit
50+ lastCommit ,
51+ { cell : < ActionsColumn items = { rowActions } /> , props : { isActionCell : true } } ,
3252] ) ;
3353
3454const columns : DataViewTh [ ] = [
@@ -37,7 +57,7 @@ const columns: DataViewTh[] = [
3757 { cell : < > Branches< ExclamationCircleIcon className = 'pf-v5-u-ml-sm' color = 'var(--pf-v5-global--danger-color--100)' /> </ > } ,
3858 'Pull requests' ,
3959 { cell : 'Workspaces' , props : { info : { tooltip : 'More information' } } } ,
40- { cell : 'Last commit' , props : { sort : { sortBy : { } , columnIndex : 4 } } }
60+ { cell : 'Last commit' , props : { sort : { sortBy : { } , columnIndex : 4 } } } ,
4161] ;
4262
4363const ouiaId = 'TableExample' ;
0 commit comments