@@ -9,20 +9,20 @@ import {
99 InputLabel ,
1010} from "@material-ui/core" ;
1111import { Clear } from "@material-ui/icons" ;
12- import { TestRun } from "../types" ;
12+ import { TestRun , TestVariation } from "../types" ;
1313
1414interface IProps {
15- testRuns : TestRun [ ] ;
15+ items : ( TestRun | TestVariation ) [ ] ;
1616 queryState : [ string , React . Dispatch < React . SetStateAction < string > > ] ;
1717 osState : [ string , React . Dispatch < React . SetStateAction < string > > ] ;
1818 deviceState : [ string , React . Dispatch < React . SetStateAction < string > > ] ;
1919 browserState : [ string , React . Dispatch < React . SetStateAction < string > > ] ;
2020 viewportState : [ string , React . Dispatch < React . SetStateAction < string > > ] ;
21- testStatusState : [ string , React . Dispatch < React . SetStateAction < string > > ] ;
21+ testStatusState ? : [ string , React . Dispatch < React . SetStateAction < string > > ] ;
2222}
2323
2424const Filters : React . FunctionComponent < IProps > = ( {
25- testRuns ,
25+ items ,
2626 queryState,
2727 osState,
2828 deviceState,
@@ -35,27 +35,31 @@ const Filters: React.FunctionComponent<IProps> = ({
3535 const [ device , setDevice ] = deviceState ;
3636 const [ browser , setBrowser ] = browserState ;
3737 const [ viewport , setViewport ] = viewportState ;
38- const [ testStatus , setTestStatus ] = testStatusState ;
38+ const [ testStatus , setTestStatus ] = testStatusState
39+ ? testStatusState
40+ : [ null , ( ) => { } ] ;
3941
40- const osList = testRuns
42+ const osList = items
4143 . map ( ( t ) => t . os )
4244 . filter ( ( v , i , array ) => v && array . indexOf ( v ) === i ) ;
4345
44- const deviceList = testRuns
46+ const deviceList = items
4547 . map ( ( t ) => t . device )
4648 . filter ( ( v , i , array ) => v && array . indexOf ( v ) === i ) ;
4749
48- const browserList = testRuns
50+ const browserList = items
4951 . map ( ( t ) => t . browser )
5052 . filter ( ( v , i , array ) => v && array . indexOf ( v ) === i ) ;
5153
52- const viewportList = testRuns
54+ const viewportList = items
5355 . map ( ( t ) => t . viewport )
5456 . filter ( ( v , i , array ) => v && array . indexOf ( v ) === i ) ;
5557
56- const testStatusList = testRuns
57- . map ( ( t ) => t . status )
58- . filter ( ( v , i , array ) => v && array . indexOf ( v ) === i ) ;
58+ const testStatusList =
59+ items . some ( ( i ) => ( i as TestRun ) . status ) &&
60+ ( items as TestRun [ ] )
61+ . map ( ( t ) => t . status )
62+ . filter ( ( v , i , array ) => v && array . indexOf ( v ) === i ) ;
5963
6064 return (
6165 < React . Fragment >
@@ -171,7 +175,7 @@ const Filters: React.FunctionComponent<IProps> = ({
171175 </ FormControl >
172176 </ Grid >
173177 ) }
174- { testStatusList . length > 0 && (
178+ { testStatusList && testStatusList . length > 0 && (
175179 < Grid item xs >
176180 < FormControl fullWidth >
177181 < InputLabel shrink id = "filter_testStatus" >
0 commit comments