@@ -2,6 +2,7 @@ import React from 'react';
2
2
import { DataViewTable , DataViewTr , DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable' ;
3
3
import { ExclamationCircleIcon } from '@patternfly/react-icons' ;
4
4
import { Button } from '@patternfly/react-core' ;
5
+ import { ActionsColumn } from '@patternfly/react-table' ;
5
6
6
7
interface Repository {
7
8
id : number ;
@@ -21,14 +22,33 @@ const repositories: Repository[] = [
21
22
{ id : 6 , name : 'Repository six' , branches : 'Branch six' , prs : 'Pull request six' , workspaces : 'Workspace six' , lastCommit : 'Timestamp six' }
22
23
] ;
23
24
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
+
24
43
// you can also pass props to Tr by returning { row: DataViewTd[], props: TrProps } }
25
44
const rows : DataViewTr [ ] = repositories . map ( ( { id, name, branches, prs, workspaces, lastCommit } ) => [
26
45
{ id, cell : workspaces , props : { favorites : { isFavorited : true } } } ,
27
46
{ cell : < Button href = '#' variant = 'link' isInline > { name } </ Button > } ,
28
47
branches ,
29
48
prs ,
30
49
workspaces ,
31
- lastCommit
50
+ lastCommit ,
51
+ { cell : < ActionsColumn items = { rowActions } /> , props : { isActionCell : true } } ,
32
52
] ) ;
33
53
34
54
const columns : DataViewTh [ ] = [
@@ -37,7 +57,7 @@ const columns: DataViewTh[] = [
37
57
{ cell : < > Branches< ExclamationCircleIcon className = 'pf-v5-u-ml-sm' color = 'var(--pf-v5-global--danger-color--100)' /> </ > } ,
38
58
'Pull requests' ,
39
59
{ 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 } } } ,
41
61
] ;
42
62
43
63
const ouiaId = 'TableExample' ;
0 commit comments