@@ -694,22 +694,10 @@ function Graphs({ data }: { data: any[] }) {
694694
695695function TestStatus ( {
696696 shas,
697- useOrFilter,
698- fileFilter,
699- jobFilter,
700- labelFilter,
701- fileRegex,
702- jobRegex,
703- labelRegex,
697+ rowMatchesFilters,
704698} : {
705699 shas : { sha : string ; push_date : number } [ ] ;
706- useOrFilter : boolean ;
707- fileFilter : string ;
708- jobFilter : string ;
709- labelFilter : string ;
710- fileRegex : boolean ;
711- jobRegex : boolean ;
712- labelRegex : boolean ;
700+ rowMatchesFilters : ( row : any ) => boolean ;
713701} ) {
714702 const options = shas ;
715703 const [ selectedIndex , setSelectedIndex ] = useState < number > (
@@ -730,20 +718,7 @@ function TestStatus({
730718 ) ;
731719
732720 // Apply the same file/job/label filter to statusChangeData
733- data = data ?. filter ( ( row ) => {
734- const fileMatch = matchField ( row . file , fileFilter , fileRegex ) ;
735- const jobMatch = matchField ( row . short_job_name , jobFilter , jobRegex ) ;
736- const labelMatch = matchLabel ( row . labels , labelFilter , labelRegex ) ;
737- if ( useOrFilter ) {
738- return (
739- ( ! fileFilter && ! jobFilter && ! labelFilter ) ||
740- ( fileFilter && fileMatch ) ||
741- ( jobFilter && jobMatch ) ||
742- ( labelFilter && labelMatch )
743- ) ;
744- }
745- return fileMatch && jobMatch && labelMatch ;
746- } ) ;
721+ data = data ?. filter ( rowMatchesFilters ) ;
747722
748723 const columns : any [ ] = [
749724 { field : "status" , headerName : "Status" , flex : 1 } ,
@@ -922,21 +897,22 @@ export default function Page() {
922897 }
923898
924899 // Filter data by file, job, and label with regex support
925- data = data . filter ( ( row ) => {
900+ function rowMatchesFilters ( row : any ) {
926901 const fileMatch = matchField ( row . file , fileFilter , fileRegex ) ;
927902 const jobMatch = matchField ( row . short_job_name , jobFilter , jobRegex ) ;
928903 const labelMatch = matchLabel ( row . labels , labelFilter , labelRegex ) ;
929904 if ( useOrFilter ) {
930905 return (
931906 ( ! fileFilter && ! jobFilter && ! labelFilter ) ||
932- ( fileFilter && fileMatch ) ||
933- ( jobFilter && jobMatch ) ||
934- ( labelFilter && labelMatch )
907+ ( fileFilter !== "" && fileMatch ) ||
908+ ( jobFilter !== "" && jobMatch ) ||
909+ ( labelFilter !== "" && labelMatch )
935910 ) ;
936911 }
937912 return fileMatch && jobMatch && labelMatch ;
938- } ) ;
913+ }
939914
915+ data = data . filter ( rowMatchesFilters ) ;
940916 return (
941917 < Stack spacing = { 4 } >
942918 < Stack direction = "row" spacing = { 2 } >
@@ -1131,13 +1107,7 @@ export default function Page() {
11311107 headShaIndex - 7 >= 0 ? headShaIndex - 7 : 0 ,
11321108 headShaIndex + 1
11331109 ) }
1134- useOrFilter = { useOrFilter }
1135- fileFilter = { fileFilter }
1136- jobFilter = { jobFilter }
1137- labelFilter = { labelFilter }
1138- fileRegex = { fileRegex }
1139- jobRegex = { jobRegex }
1140- labelRegex = { labelRegex }
1110+ rowMatchesFilters = { rowMatchesFilters }
11411111 />
11421112 </ Stack >
11431113 </ Stack >
0 commit comments