Skip to content

Commit 4e1ae61

Browse files
🌱 chore(tag-table): update from pf deprecated (#1289)
closes #1284 Signed-off-by: gitdallas <[email protected]> Co-authored-by: Ian Bolton <[email protected]>
1 parent edf2855 commit 4e1ae61

File tree

1 file changed

+33
-36
lines changed

1 file changed

+33
-36
lines changed

client/src/app/pages/controls/tags/components/tag-table.tsx

+33-36
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import React from "react";
22
import { useTranslation } from "react-i18next";
33
import {
4+
Table,
5+
Thead,
6+
Tr,
7+
Th,
8+
Tbody,
9+
Td,
10+
ActionsColumn,
11+
IAction,
412
cellWidth,
5-
IActions,
613
ICell,
714
IRow,
815
IRowData,
916
} from "@patternfly/react-table";
10-
import {
11-
Table,
12-
TableBody,
13-
TableHeader,
14-
} from "@patternfly/react-table/deprecated";
15-
1617
import { Tag, TagCategory } from "@app/api/models";
1718
import "./tag-table.css";
1819

@@ -61,8 +62,6 @@ export const TagTable: React.FC<TabTableProps> = ({
6162
});
6263
});
6364

64-
// Rows
65-
6665
const editRow = (row: Tag) => {
6766
onEdit(row);
6867
};
@@ -71,42 +70,40 @@ export const TagTable: React.FC<TabTableProps> = ({
7170
onDelete(row);
7271
};
7372

74-
const actions: IActions = [
73+
const defaultActions = (tag: IRowData): IAction[] => [
7574
{
7675
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)),
8577
},
8678
{
8779
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)),
9681
},
9782
];
9883

9984
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>
110107
</Table>
111108
);
112109
};

0 commit comments

Comments
 (0)