@@ -308,8 +357,39 @@
data-index="0"
>
+
+
+
+
+
+ |
+
|
|
+
+
+
+
+
+ |
+
|
|
+
+
+
+
+
+ |
+
|
|
+
+
+
+
+
+ |
+
|
> = Omit<
* Whether to show a loading spinner
*/
loading?: boolean;
+
+ renderRowSelectionToolbar?: (props: { table: MRT_TableInstance }) => ReactNode;
};
// Use a zero-indexed "useURLState" hook, so pages are shown in the URL as 1-indexed
@@ -169,18 +172,27 @@ export default function Table>({
return (tableProps.data ?? []).filter(it => filterFunction(it));
}, [tableProps.data, filterFunction]);
- const gridTemplateColumns = tableProps.columns
- .filter(it => {
- const isHidden = tableProps.state?.columnVisibility?.[it.id!] === false;
- return !isHidden;
- })
- .map(it => {
- if (typeof it.gridTemplate === 'number') {
- return `${it.gridTemplate}fr`;
- }
- return it.gridTemplate ?? '1fr';
- })
- .join(' ');
+ const gridTemplateColumns = useMemo(() => {
+ let preGridTemplateColumns = tableProps.columns
+ .filter(it => {
+ const isHidden = tableProps.state?.columnVisibility?.[it.id!] === false;
+ return !isHidden;
+ })
+ .map(it => {
+ if (typeof it.gridTemplate === 'number') {
+ return `${it.gridTemplate}fr`;
+ }
+ return it.gridTemplate ?? '1fr';
+ })
+ .join(' ');
+ if (tableProps.enableRowActions) {
+ preGridTemplateColumns = `${preGridTemplateColumns} 0.05fr`;
+ }
+ if (tableProps.enableRowSelection) {
+ preGridTemplateColumns = `0.05fr ${preGridTemplateColumns}`;
+ }
+ return preGridTemplateColumns;
+ }, [tableProps]);
const paginationSelectProps = import.meta.env.UNDER_TEST
? {
@@ -218,6 +230,17 @@ export default function Table>({
},
},
positionActionsColumn: 'last',
+ renderToolbarInternalActions: table => {
+ const isSomeRowsSelected =
+ tableProps.enableRowSelection && table.table.getIsSomeRowsSelected();
+ if (isSomeRowsSelected) {
+ const renderRowSelectionToolbar = tableProps.renderRowSelectionToolbar;
+ if (renderRowSelectionToolbar !== undefined) {
+ return renderRowSelectionToolbar(table);
+ }
+ }
+ return null;
+ },
layoutMode: 'grid',
// Need to provide our own empty message
// because default one breaks with our custom layout
@@ -272,10 +295,7 @@ export default function Table>({
},
muiTableProps: {
sx: {
- gridTemplateColumns:
- tableProps.enableRowActions === true
- ? `${gridTemplateColumns} 0.05fr`
- : gridTemplateColumns,
+ gridTemplateColumns: gridTemplateColumns,
},
},
muiTableHeadProps: {
diff --git a/frontend/src/components/configmap/__snapshots__/List.Items.stories.storyshot b/frontend/src/components/configmap/__snapshots__/List.Items.stories.storyshot
index a43869cb31..7695961f7a 100644
--- a/frontend/src/components/configmap/__snapshots__/List.Items.stories.storyshot
+++ b/frontend/src/components/configmap/__snapshots__/List.Items.stories.storyshot
@@ -246,8 +246,8 @@
class="MuiTableContainer-root css-nhjqqh-MuiTableContainer-root"
>
+
+
+ |
@@ -575,7 +624,7 @@
aria-sort="none"
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignLeft MuiTableCell-sizeMedium css-tb4te8-MuiTableCell-root"
colspan="1"
- data-index="4"
+ data-index="5"
scope="col"
>
+
+
+
+
+
+ |
+
|
|
3
|
|
| | |