diff --git a/src/components/RunList/index.tsx b/src/components/RunList/index.tsx index 9aad212..2232fb4 100644 --- a/src/components/RunList/index.tsx +++ b/src/components/RunList/index.tsx @@ -18,6 +18,7 @@ import { type MRT_Updater, type MRT_ColumnFiltersState, type MRT_TableOptions, + type MRT_TableInstance, } from 'material-react-table'; import { type Theme } from "@mui/material/styles"; import { parse } from "date-fns"; @@ -35,6 +36,8 @@ import { RunStatuses, } from "../../lib/paddles.d"; import useDefaultTableOptions from "../../lib/table"; +import Typography from '@mui/material/Typography'; +import Box from '@mui/material/Box'; const DEFAULT_PAGE_SIZE = 25; @@ -42,14 +45,6 @@ const NON_FILTER_PARAMS = [ "page", "pageSize", ]; -const FILTER_COLUMNS = [ - "status", - "scheduled", - "suite", - "branch", - "machine_type", - "sha1", -] const _columns: MRT_ColumnDef[] = [ { @@ -289,6 +284,7 @@ export default function RunList(props: RunListProps) { }, onColumnFiltersChange, columnFilterDisplayMode: 'custom', + enableColumnFilters: false, muiFilterTextFieldProps: ({ column }) => ({ label: `Filter by ${column.columnDef.header}`, }), @@ -321,30 +317,76 @@ export default function RunList(props: RunListProps) { if (query.isError) return null; return (
- { openFilterMenu? ( - + + + +
+ ) +} + + +// FilterMenu + +type FilterMenuProps = { + isOpen: boolean; + table: MRT_TableInstance; +}; + + +const FILTER_SECTIONS = ["run", "build", "result"] +const FILTER_SECTIONS_COLUMNS = [ + ["scheduled", "suite", "machine_type"], + ["branch", "sha1"], + ["status"], +] + +function FilterMenu({ isOpen, table}: FilterMenuProps) { + if (!isOpen) { + return null; + } + + return ( + + {FILTER_SECTIONS_COLUMNS.map((_, sectionIndex) => ( + + + Filter by {FILTER_SECTIONS[sectionIndex]} details... + + {table.getLeafHeaders().map((header) => { - console.log(header.id) - if (FILTER_COLUMNS.includes(header.id)) { + if (FILTER_SECTIONS_COLUMNS[sectionIndex].includes(header.id)) { return ( - + - ) - } + ); + } + return null; })} - ) - : ""} - - - - ) + + + ))} + + ) }