@@ -11,22 +11,26 @@ import {
1111import { useSnackbar } from "notistack" ;
1212import {
1313 DataGrid ,
14- ColDef ,
15- RowParams ,
16- CellParams ,
14+ GridCellParams ,
15+ GridColDef ,
16+ GridRowParams ,
17+ GridValueGetterParams ,
18+ GridValueFormatterParams ,
19+ GridFilterModelParams ,
1720} from "@material-ui/data-grid" ;
1821import { DataGridCustomToolbar } from "./DataGridCustomToolbar" ;
1922import { StatusFilterOperators } from "./StatusFilterOperators" ;
2023import { TagFilterOperators } from "./TagFilterOperators" ;
24+ import { TestRun } from "../../types" ;
2125
22- const columnsDef : ColDef [ ] = [
26+ const columnsDef : GridColDef [ ] = [
2327 { field : "id" , hide : true , filterable : false } ,
2428 { field : "name" , headerName : "Name" , flex : 1 } ,
2529 {
2630 field : "tags" ,
2731 headerName : "Tags" ,
2832 flex : 1 ,
29- valueGetter : ( params : CellParams ) => {
33+ valueGetter : ( params : GridValueGetterParams ) => {
3034 const tags : Array < string > = [
3135 params . row [ "os" ] ,
3236 params . row [ "device" ] ,
@@ -39,10 +43,10 @@ const columnsDef: ColDef[] = [
3943 ""
4044 ) ;
4145 } ,
42- renderCell : ( params : CellParams ) => (
46+ renderCell : ( params : GridCellParams ) => (
4347 < React . Fragment >
4448 { params
45- . getValue ( "tags" )
49+ . getValue ( params . id , "tags" )
4650 ?. toString ( )
4751 . split ( ";" )
4852 . map (
@@ -64,8 +68,12 @@ const columnsDef: ColDef[] = [
6468 field : "status" ,
6569 headerName : "Status" ,
6670 flex : 0.3 ,
67- renderCell : ( params : CellParams ) => {
68- return < TestStatusChip status = { params . getValue ( "status" ) ?. toString ( ) } /> ;
71+ renderCell : ( params : GridValueFormatterParams ) => {
72+ return (
73+ < TestStatusChip
74+ status = { params . getValue ( params . id , "status" ) ?. toString ( ) }
75+ />
76+ ) ;
6977 } ,
7078 filterOperators : StatusFilterOperators ,
7179 } ,
@@ -101,16 +109,26 @@ const TestRunList: React.FunctionComponent = () => {
101109 pageSize = { 10 }
102110 rowsPerPageOptions = { [ 10 , 20 , 30 ] }
103111 loading = { loading }
104- showToolbar = { true }
105112 components = { {
106113 Toolbar : DataGridCustomToolbar ,
107114 } }
108115 checkboxSelection
109116 disableColumnSelector
110117 disableColumnMenu
111118 disableSelectionOnClick
112- onRowClick = { ( param : RowParams ) => {
113- selectTestRun ( testRunDispatch , param . getValue ( "id" ) ?. toString ( ) ) ;
119+ onRowClick = { ( param : GridRowParams ) => {
120+ selectTestRun (
121+ testRunDispatch ,
122+ param . getValue ( param . id , "id" ) ?. toString ( )
123+ ) ;
124+ } }
125+ onFilterModelChange = { ( params : GridFilterModelParams ) => {
126+ testRunDispatch ( {
127+ type : "filter" ,
128+ payload : Array . from (
129+ params . visibleRows . values ( )
130+ ) as Array < TestRun > ,
131+ } ) ;
114132 } }
115133 />
116134 ) }
0 commit comments