1+ import { applyFilterModel } from '../datagrid/filterUtils'
12import { CapabilitiesContext } from '../App'
23import { CompReadyVarsContext } from './CompReadyVars'
3- import { DataGrid , GridToolbar } from '@mui/x-data-grid'
4+ import { DataGrid } from '@mui/x-data-grid'
45import { FileCopy } from '@mui/icons-material'
56import { formColumnName , generateTestDetailsReportLink } from './CompReadyUtils'
67import { NumberParam , StringParam , useQueryParam } from 'use-query-params'
78import { Popover , Snackbar , Tooltip } from '@mui/material'
8- import { relativeTime } from '../helpers'
9+ import { relativeTime , SafeJSONParam } from '../helpers'
910import Alert from '@mui/material/Alert'
1011import Button from '@mui/material/Button'
1112import CompSeverityIcon from './CompSeverityIcon'
13+ import GridToolbar from '../datagrid/GridToolbar'
1214import IconButton from '@mui/material/IconButton'
1315import PropTypes from 'prop-types'
1416import React , { Fragment , useContext } from 'react'
@@ -25,12 +27,57 @@ export default function RegressedTestsPanel(props) {
2527 NumberParam ,
2628 { updateType : 'replaceIn' }
2729 )
30+ const [ filterModel = { items : [ ] } , setFilterModel ] = useQueryParam (
31+ 'regressedModalFilters' ,
32+ SafeJSONParam ,
33+ { updateType : 'replaceIn' }
34+ )
2835 const { expandEnvironment, views, view } = useContext ( CompReadyVarsContext )
2936 const { filterVals, regressedTests, setTriageActionTaken } = props
3037 const [ sortModel , setSortModel ] = React . useState ( [
3138 { field : 'component' , sort : 'asc' } ,
3239 ] )
3340
41+ const addFilters = ( filter ) => {
42+ const currentFilters = filterModel . items . filter ( ( item ) => item . value !== '' )
43+
44+ filter . forEach ( ( item ) => {
45+ if ( item . value && item . value !== '' ) {
46+ currentFilters . push ( item )
47+ }
48+ } )
49+ setFilterModel ( {
50+ items : currentFilters ,
51+ linkOperator : filterModel . linkOperator || 'and' ,
52+ } )
53+ }
54+
55+ // Quick search functionality - searches test_name field
56+ const requestSearch = ( searchValue ) => {
57+ const currentFilters = { ...filterModel }
58+ currentFilters . items = currentFilters . items . filter (
59+ ( f ) => f . columnField !== 'test_name'
60+ )
61+ if ( searchValue && searchValue !== '' ) {
62+ currentFilters . items . push ( {
63+ id : 99 ,
64+ columnField : 'test_name' ,
65+ operatorValue : 'contains' ,
66+ value : searchValue ,
67+ } )
68+ }
69+ setFilterModel ( {
70+ items : currentFilters . items ,
71+ linkOperator : currentFilters . linkOperator || 'and' ,
72+ } )
73+ }
74+
75+ // Apply client-side filtering using shared utility
76+ const filteredTests = React . useMemo (
77+ ( ) => applyFilterModel ( regressedTests , filterModel ) ,
78+ [ regressedTests , filterModel ]
79+ )
80+
3481 // Helpers for copying the test ID to clipboard
3582 const [ copyPopoverEl , setCopyPopoverEl ] = React . useState ( null )
3683 const copyPopoverOpen = Boolean ( copyPopoverEl )
@@ -86,6 +133,7 @@ export default function RegressedTestsPanel(props) {
86133 field : 'triage' ,
87134 headerName : 'Triage' ,
88135 flex : 4 ,
136+ filterable : false ,
89137 valueGetter : ( params ) => {
90138 if ( ! params . row . regression ?. opened ) {
91139 // For a regression we haven't yet detected:
@@ -110,30 +158,35 @@ export default function RegressedTestsPanel(props) {
110158 field : 'component' ,
111159 headerName : 'Component' ,
112160 flex : 20 ,
161+ autocomplete : 'component' ,
113162 renderCell : ( param ) => < div className = "test-name" > { param . value } </ div > ,
114163 } ,
115164 {
116165 field : 'capability' ,
117166 headerName : 'Capability' ,
118167 flex : 12 ,
168+ autocomplete : 'capability' ,
119169 renderCell : ( param ) => < div className = "test-name" > { param . value } </ div > ,
120170 } ,
121171 {
122172 field : 'test_name' ,
123173 headerName : 'Test Name' ,
124174 flex : 40 ,
175+ autocomplete : 'test_name' ,
125176 renderCell : ( param ) => < div className = "test-name" > { param . value } </ div > ,
126177 } ,
127178 {
128179 field : 'test_suite' ,
129180 headerName : 'Test Suite' ,
130181 flex : 15 ,
182+ autocomplete : 'test_suite' ,
131183 renderCell : ( param ) => < div className = "test-name" > { param . value } </ div > ,
132184 } ,
133185 {
134186 field : 'variants' ,
135187 headerName : 'Variants' ,
136188 flex : 30 ,
189+ filterable : false ,
137190 valueGetter : ( params ) => {
138191 return formColumnName ( { variants : params . row . variants } )
139192 } ,
@@ -143,6 +196,7 @@ export default function RegressedTestsPanel(props) {
143196 field : 'regression' ,
144197 headerName : 'Regressed Since' ,
145198 flex : 12 ,
199+ filterable : false ,
146200 valueGetter : ( params ) => {
147201 if ( ! params . row . regression ?. opened ) {
148202 // For a regression we haven't yet detected:
@@ -172,6 +226,7 @@ export default function RegressedTestsPanel(props) {
172226 field : 'last_failure' ,
173227 headerName : 'Last Failure' ,
174228 flex : 12 ,
229+ filterable : false ,
175230 valueGetter : ( params ) => {
176231 if ( ! params . row . last_failure ) {
177232 return null
@@ -192,6 +247,7 @@ export default function RegressedTestsPanel(props) {
192247 field : 'test_id' ,
193248 flex : 5 ,
194249 headerName : 'ID' ,
250+ filterable : false ,
195251 renderCell : ( params ) => {
196252 return (
197253 < IconButton
@@ -211,6 +267,7 @@ export default function RegressedTestsPanel(props) {
211267 {
212268 field : 'status' ,
213269 headerName : 'Status' ,
270+ filterable : false ,
214271 renderCell : ( params ) => (
215272 < div
216273 style = { {
@@ -258,7 +315,7 @@ export default function RegressedTestsPanel(props) {
258315 sortModel = { sortModel }
259316 onSortModelChange = { setSortModel }
260317 components = { { Toolbar : GridToolbar } }
261- rows = { regressedTests }
318+ rows = { filteredTests }
262319 columns = { columns }
263320 getRowId = { ( row ) =>
264321 row . test_id +
@@ -285,7 +342,12 @@ export default function RegressedTestsPanel(props) {
285342 componentsProps = { {
286343 toolbar : {
287344 columns : columns ,
288- showQuickFilter : true ,
345+ addFilters : addFilters ,
346+ filterModel : filterModel ,
347+ setFilterModel : setFilterModel ,
348+ clearSearch : ( ) => requestSearch ( '' ) ,
349+ doSearch : requestSearch ,
350+ autocompleteData : regressedTests ,
289351 } ,
290352 } }
291353 />
0 commit comments