@@ -108,15 +108,27 @@ function findLongestCommonPrefix(strings: string[]): string {
108
108
return prefix ;
109
109
}
110
110
111
+ enum TestResultType {
112
+ All ,
113
+ Success ,
114
+ Failed
115
+ }
116
+
117
+ export function StatisticsCtr ( props : { scenarios :Scenario [ ] , onSetFilter : ( type :TestResultType ) => void } ) {
118
+ var success = props . scenarios . filter ( value => value . Status === 0 ) . length ;
119
+ var failed = props . scenarios . filter ( value => value . Status === 1 ) . length ;
120
+ const [ typeState , setTypeState ] = useState ( TestResultType . All )
121
+ const setFilter = ( type :TestResultType ) => {
122
+ type = typeState === type ? TestResultType . All : type ;
123
+ props . onSetFilter ( type ) ;
124
+ setTypeState ( type ) ;
125
+ } ;
111
126
112
127
113
- export function StatisticsCtr ( props : { scenarios :Scenario [ ] } ) {
114
- var success = props . scenarios . filter ( value => value . Status === 0 ) . length
115
- var failed = props . scenarios . filter ( value => value . Status === 1 ) . length
116
128
return (
117
- < Row gutter = { 16 } style = { { width :"100%" } } >
129
+ < Row gutter = { 16 } style = { { width :"100%" } } className = "filter-row" >
118
130
< Col span = { 8 } >
119
- < Card bordered = { false } >
131
+ < Card bordered = { false } onClick = { ( ) => setFilter ( TestResultType . All ) } className = { typeState === TestResultType . All ? "selected-filter" : "" } >
120
132
< Statistic
121
133
title = "Total"
122
134
value = { props . scenarios . length }
@@ -126,7 +138,7 @@ export function StatisticsCtr(props: {scenarios:Scenario[]}) {
126
138
</ Card >
127
139
</ Col >
128
140
< Col span = { 8 } >
129
- < Card bordered = { false } >
141
+ < Card bordered = { false } onClick = { ( ) => setFilter ( TestResultType . Success ) } className = { typeState === TestResultType . Success ? "selected-filter" : "" } >
130
142
< Statistic
131
143
title = "Success"
132
144
value = { success }
@@ -136,7 +148,7 @@ export function StatisticsCtr(props: {scenarios:Scenario[]}) {
136
148
</ Card >
137
149
</ Col >
138
150
< Col span = { 8 } >
139
- < Card bordered = { false } >
151
+ < Card bordered = { false } onClick = { ( ) => setFilter ( TestResultType . Failed ) } className = { typeState === TestResultType . Failed ? "selected-filter" : "" } >
140
152
< Statistic
141
153
title = "Failed"
142
154
value = { failed }
@@ -183,7 +195,7 @@ export function ScenarioTitleCtr(props: {data:Scenario}) {
183
195
}
184
196
const ScenarioCtr = React . memo ( ( props : { data :Scenario , isSelected :boolean } ) => {
185
197
return (
186
- < Card id = { props . data . ScenarioTitle . replace ( / \W + / g, "-" ) } title = { ( < ScenarioTitleCtr data = { props . data } /> ) } style = { { width :"auto " , border : props . isSelected ? "1px solid blue" : "1px solid transparent" , transition : "border-color 0.5s ease" } } >
198
+ < Card className = { `scenario- ${ props . data . Status } ` } id = { props . data . ScenarioTitle . replace ( / \W + / g, "-" ) } title = { ( < ScenarioTitleCtr data = { props . data } /> ) } style = { { width :"100% " , border : props . isSelected ? "1px solid blue" : "1px solid transparent" , transition : "border-color 0.5s ease" , marginBottom : "20px " } } >
187
199
< Timeline
188
200
style = { { paddingBottom :0 } }
189
201
mode = { "left" }
@@ -248,7 +260,7 @@ function App() {
248
260
const [ treeState , setTreeState ] = useState ( treeData )
249
261
const [ selectedScenario , setSelectedScenario ] = useState ( "" )
250
262
const [ sourceControlState , setSourceControlState ] = useState ( scenarioData . SourceControlInfo )
251
-
263
+ const [ typeState , setTypeState ] = useState ( TestResultType . All )
252
264
let pathResolver = RepoPathResolver . TryToGetPathBuilder ( sourceControlState , sourceControlState . RepositoryRootDir )
253
265
254
266
useEffect ( ( ) => {
@@ -265,7 +277,7 @@ function App() {
265
277
} ) ;
266
278
267
279
return (
268
- < div className = " App" style = { { textAlign :"left" , margin :0 , padding :0 } } >
280
+ < div className = { ` App filter- ${ typeState } ` } style = { { textAlign :"left" , margin :0 , padding :0 } } >
269
281
< GlobalServicesContext . Provider value = { { pathResolver : pathResolver } } >
270
282
< Row style = { { height : "calc(100vh - 10px)" , background : "#EFEFEF" } } >
271
283
< Col span = { 8 } style = { { height :"100%" , padding :"20px 0 20px 20px" , overflowY :"scroll" , overflowX :"hidden" } } >
@@ -280,12 +292,10 @@ function App() {
280
292
</ Col >
281
293
< Col span = { 16 } style = { { height : "100%" } } >
282
294
< Row justify = { "center" } style = { { height : "150px" , padding : "20px 20px 20px 10px" } } >
283
- < StatisticsCtr scenarios = { scenarioState } />
295
+ < StatisticsCtr scenarios = { scenarioState } onSetFilter = { type => { setTypeState ( type ) } } />
284
296
</ Row >
285
297
< Row style = { { height :"calc(100% - 200px)" , padding :"0px 20px 20px 20px" , overflowY : "scroll" } } >
286
- < Space direction = { "vertical" } size = "middle" style = { { display : 'flex' , width : "100%" } } >
287
- { scenarioState . map ( value => < ScenarioCtr data = { value } isSelected = { selectedScenario === value . ScenarioTitle } /> ) }
288
- </ Space >
298
+ { scenarioState . map ( value => < ScenarioCtr data = { value } isSelected = { selectedScenario === value . ScenarioTitle } /> ) }
289
299
</ Row >
290
300
< Row align = { "bottom" } style = { { height :"50px" , } } >
291
301
< Col span = { 24 } style = { { textAlign :"center" , padding : "20px" } } >
0 commit comments