Skip to content

Commit 18c1223

Browse files
kmalyjurMariaAga
authored andcommitted
Fixes #38629 - Add expand all rows to the table
1 parent 4851c04 commit 18c1223

File tree

1 file changed

+18
-3
lines changed
  • webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/Table

1 file changed

+18
-3
lines changed

webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/Table/Table.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export const Table = ({
4141
children,
4242
bottomPagination,
4343
childrenOutsideTbody, // Expandable table rows are each a Tbody so they cant be inside the Tbody
44+
onExpandAll,
45+
areAllRowsExpanded,
4446
}) => {
4547
const onPagination = newPagination => {
4648
setParams({ ...params, ...newPagination });
@@ -121,12 +123,21 @@ export const Table = ({
121123
>
122124
<Thead>
123125
<Tr ouiaId="table-header">
126+
{childrenOutsideTbody && (
127+
<Th
128+
aria-label="expansion-header"
129+
key="expansion-th"
130+
expand={
131+
onExpandAll && {
132+
areAllExpanded: areAllRowsExpanded,
133+
onToggle: onExpandAll,
134+
}
135+
}
136+
/>
137+
)}
124138
{showCheckboxes && (
125139
<Th aria-label="checkbox-header" key="checkbox-th" />
126140
)}
127-
{childrenOutsideTbody && (
128-
<Th aria-label="expansion-carat" key="expansion-carat" />
129-
)}
130141
{columnNamesKeys.map(k => (
131142
<Th
132143
key={k}
@@ -247,6 +258,8 @@ Table.propTypes = {
247258
showCheckboxes: PropTypes.bool,
248259
bottomPagination: PropTypes.node,
249260
childrenOutsideTbody: PropTypes.bool,
261+
onExpandAll: PropTypes.func,
262+
areAllRowsExpanded: PropTypes.bool,
250263
};
251264

252265
Table.defaultProps = {
@@ -267,4 +280,6 @@ Table.defaultProps = {
267280
showCheckboxes: false,
268281
bottomPagination: null,
269282
childrenOutsideTbody: false,
283+
onExpandAll: null,
284+
areAllRowsExpanded: false,
270285
};

0 commit comments

Comments
 (0)