1
1
import React from "react" ;
2
2
import { useTranslation } from "react-i18next" ;
3
3
import {
4
+ Table ,
5
+ Thead ,
6
+ Tr ,
7
+ Th ,
8
+ Tbody ,
9
+ Td ,
10
+ ActionsColumn ,
11
+ IAction ,
4
12
cellWidth ,
5
- IActions ,
6
13
ICell ,
7
14
IRow ,
8
15
IRowData ,
9
16
} from "@patternfly/react-table" ;
10
- import {
11
- Table ,
12
- TableBody ,
13
- TableHeader ,
14
- } from "@patternfly/react-table/deprecated" ;
15
-
16
17
import { Tag , TagCategory } from "@app/api/models" ;
17
18
import "./tag-table.css" ;
18
19
@@ -61,8 +62,6 @@ export const TagTable: React.FC<TabTableProps> = ({
61
62
} ) ;
62
63
} ) ;
63
64
64
- // Rows
65
-
66
65
const editRow = ( row : Tag ) => {
67
66
onEdit ( row ) ;
68
67
} ;
@@ -71,42 +70,40 @@ export const TagTable: React.FC<TabTableProps> = ({
71
70
onDelete ( row ) ;
72
71
} ;
73
72
74
- const actions : IActions = [
73
+ const defaultActions = ( tag : IRowData ) : IAction [ ] => [
75
74
{
76
75
title : t ( "actions.edit" ) ,
77
- onClick : (
78
- event : React . MouseEvent ,
79
- rowIndex : number ,
80
- rowData : IRowData
81
- ) => {
82
- const row : Tag = getRow ( rowData ) ;
83
- editRow ( row ) ;
84
- } ,
76
+ onClick : ( ) => editRow ( getRow ( tag ) ) ,
85
77
} ,
86
78
{
87
79
title : t ( "actions.delete" ) ,
88
- onClick : (
89
- event : React . MouseEvent ,
90
- rowIndex : number ,
91
- rowData : IRowData
92
- ) => {
93
- const row : Tag = getRow ( rowData ) ;
94
- deleteRow ( row ) ;
95
- } ,
80
+ onClick : ( ) => deleteRow ( getRow ( tag ) ) ,
96
81
} ,
97
82
] ;
98
83
99
84
return (
100
- < Table
101
- borders = { false }
102
- variant = "compact"
103
- aria-label = "Tag table"
104
- cells = { columns }
105
- rows = { rows }
106
- actions = { actions }
107
- >
108
- < TableHeader />
109
- < TableBody />
85
+ < Table borders = { false } aria-label = "Tag table" variant = "compact" isNested >
86
+ < Thead noWrap >
87
+ < Tr >
88
+ < Th > { t ( "terms.tagName" ) } </ Th >
89
+ < Td > </ Td >
90
+ </ Tr >
91
+ </ Thead >
92
+ < Tbody >
93
+ { rows . map ( ( row : IRow ) => {
94
+ const rowActions = defaultActions ( row ) ;
95
+ return (
96
+ < Tr >
97
+ { row . cells ?. map ( ( cell : any ) => (
98
+ < Td > { cell . title } </ Td >
99
+ ) ) }
100
+ < Td isActionCell >
101
+ { rowActions && < ActionsColumn items = { rowActions } /> }
102
+ </ Td >
103
+ </ Tr >
104
+ ) ;
105
+ } ) }
106
+ </ Tbody >
110
107
</ Table >
111
108
) ;
112
109
} ;
0 commit comments