Skip to content

Commit a0cc198

Browse files
committed
RunList: Put filter button inside the table menu
- use renderTopToolbarCustomActions to add the filter button inside the table menu - Show what filters are applied at top right of the table. Signed-off-by: Vallari Agrawal <[email protected]>
1 parent 250b597 commit a0cc198

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

src/components/RunList/index.tsx

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -324,25 +324,39 @@ export default function RunList(props: RunListProps) {
324324
if ( category ) return { className: category };
325325
return {};
326326
},
327+
renderTopToolbarCustomActions: ({ table }) => (
328+
<Box sx={{ padding: '4px' }}>
329+
<Badge
330+
color="primary"
331+
overlap="circular"
332+
badgeContent={table.getState().columnFilters.reduce((count, filter) => (filter.value ? count + 1 : count), 0)}
333+
>
334+
<Button
335+
id="filter-button"
336+
onClick={toggleFilterMenu}
337+
>
338+
Filters
339+
</Button>
340+
</Badge>
341+
</Box>
342+
),
327343
...tableOptions,
328344
});
329345

330346
if (query.isError) return null;
331347
return (
332-
<div>
333-
348+
<div>
334349
<div>
335-
<Badge
336-
color="primary"
337-
badgeContent={table.getState().columnFilters.reduce((count, filter) => (filter.value ? count + 1 : count), 0)}
338-
>
339-
<Button
340-
id="filter-button"
341-
onClick={toggleFilterMenu}
342-
>
343-
Filters Runs
344-
</Button>
345-
</Badge>
350+
<Typography variant="body2" gutterBottom color="gray" textAlign={"right"}>
351+
{ table.getState().columnFilters.map((column) => {
352+
let filterValue = column.value;
353+
if (column.id == "scheduled") {
354+
const parsedDate = new Date(column.value as string);
355+
filterValue = (parsedDate.toISOString().split('T')[0])
356+
}
357+
return (column.value ? `${column.id}: '${filterValue}' ` : "")
358+
} )}
359+
</Typography>
346360
<Menu
347361
id="filter-menu"
348362
anchorEl={dropMenuAnchorEl}
@@ -354,9 +368,9 @@ export default function RunList(props: RunListProps) {
354368
>
355369
<FilterMenu isOpen={openFilterMenu} table={table} />
356370
</Menu>
357-
</div>
358-
<MaterialReactTable table={table} />
359-
</div>
371+
</div>
372+
<MaterialReactTable table={table} />
373+
</div>
360374
)
361375
}
362376

0 commit comments

Comments
 (0)