12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ import React , { Component } from 'react' ;
15
16
import _values from 'lodash/values' ;
16
17
import PropTypes from 'prop-types' ;
17
- import React , { Component } from 'react' ;
18
18
import queryString from 'query-string' ;
19
- import { bindActionCreators } from 'redux' ;
20
19
import { connect } from 'react-redux' ;
21
- import { Field , reduxForm , formValueSelector } from 'redux-form' ;
22
20
import { Link } from 'react-router-dom' ;
21
+ import { bindActionCreators } from 'redux' ;
22
+ import { Field , reduxForm , formValueSelector } from 'redux-form' ;
23
+ import store from 'store' ;
23
24
24
25
import JaegerLogo from '../../img/jaeger-logo.svg' ;
25
26
@@ -61,35 +62,45 @@ const traceResultsFiltersFormSelector = formValueSelector('traceResultsFilters')
61
62
62
63
export default class SearchTracePage extends Component {
63
64
componentDidMount ( ) {
64
- const { searchTraces, urlQueryParams, fetchServices } = this . props ;
65
+ const { searchTraces, urlQueryParams, fetchServices, fetchServiceOperations } = this . props ;
65
66
if ( urlQueryParams . service || urlQueryParams . traceID ) {
66
67
searchTraces ( urlQueryParams ) ;
67
68
}
68
69
fetchServices ( ) ;
70
+ const { service } = store . get ( 'lastSearch' ) || { } ;
71
+ if ( service && service !== '-' ) {
72
+ fetchServiceOperations ( service ) ;
73
+ }
69
74
}
75
+
70
76
render ( ) {
71
77
const {
72
- traceResults,
73
- services,
74
- numberOfTraceResults,
75
- maxTraceDuration,
76
- loading,
77
78
errorMessage,
78
79
isHomepage,
80
+ loadingServices,
81
+ loadingTraces,
82
+ maxTraceDuration,
83
+ numberOfTraceResults,
84
+ services,
85
+ traceResults,
79
86
} = this . props ;
80
87
const hasTraceResults = traceResults && traceResults . length > 0 ;
81
88
return (
82
89
< div className = "trace-search ui grid padded" >
83
90
< div className = "four wide column" >
84
91
< div className = "ui tertiary segment" style = { { background : 'whitesmoke' } } >
85
92
< h3 > Find Traces</ h3 >
86
- < TraceSearchForm services = { services } />
93
+ { ! loadingServices && services
94
+ ? < TraceSearchForm services = { services } />
95
+ : < div className = "m1" >
96
+ < div className = "ui active centered inline loader" />
97
+ </ div > }
87
98
</ div >
88
99
</ div >
89
100
< div className = "twelve wide column padded" >
90
- { loading && < div className = "ui active centered inline loader" /> }
101
+ { loadingTraces && < div className = "ui active centered inline loader" /> }
91
102
{ errorMessage &&
92
- ! loading &&
103
+ ! loadingTraces &&
93
104
< div className = "ui message red trace-search--error" >
94
105
There was an error querying for traces:< br />
95
106
{ errorMessage }
@@ -103,11 +114,11 @@ export default class SearchTracePage extends Component {
103
114
</ div > }
104
115
{ ! isHomepage &&
105
116
! hasTraceResults &&
106
- ! loading &&
117
+ ! loadingTraces &&
107
118
! errorMessage &&
108
119
< div className = "ui message trace-search--no-results" > No trace results. Try another query.</ div > }
109
120
{ hasTraceResults &&
110
- ! loading &&
121
+ ! loadingTraces &&
111
122
< div >
112
123
< div >
113
124
< div style = { { border : '1px solid #e6e6e6' } } >
@@ -165,7 +176,8 @@ SearchTracePage.propTypes = {
165
176
traceResults : PropTypes . array ,
166
177
numberOfTraceResults : PropTypes . number ,
167
178
maxTraceDuration : PropTypes . number ,
168
- loading : PropTypes . bool ,
179
+ loadingServices : PropTypes . bool ,
180
+ loadingTraces : PropTypes . bool ,
169
181
urlQueryParams : PropTypes . shape ( {
170
182
service : PropTypes . string ,
171
183
limit : PropTypes . string ,
@@ -180,30 +192,38 @@ SearchTracePage.propTypes = {
180
192
history : PropTypes . shape ( {
181
193
push : PropTypes . func ,
182
194
} ) ,
195
+ fetchServiceOperations : PropTypes . func ,
183
196
fetchServices : PropTypes . func ,
184
197
errorMessage : PropTypes . string ,
185
198
} ;
186
199
187
200
const stateTraceXformer = getLastXformCacher ( stateTrace => {
188
- const { traces : traceMap , loading, error : traceError } = stateTrace ;
201
+ const { traces : traceMap , loading : loadingTraces , error : traceError } = stateTrace ;
189
202
const { traces, maxDuration } = getTraceSummaries ( _values ( traceMap ) ) ;
190
- return { traces, maxDuration, loading , traceError } ;
203
+ return { traces, maxDuration, traceError , loadingTraces } ;
191
204
} ) ;
192
205
193
206
const stateServicesXformer = getLastXformCacher ( stateServices => {
194
- const { services : serviceList , operationsForService : opsBySvc , error : serviceError } = stateServices ;
195
- const services = serviceList . map ( name => ( {
196
- name,
197
- operations : opsBySvc [ name ] || [ ] ,
198
- } ) ) ;
199
- return { services, serviceError } ;
207
+ const {
208
+ loading : loadingServices ,
209
+ services : serviceList ,
210
+ operationsForService : opsBySvc ,
211
+ error : serviceError ,
212
+ } = stateServices ;
213
+ const services =
214
+ serviceList &&
215
+ serviceList . map ( name => ( {
216
+ name,
217
+ operations : opsBySvc [ name ] || [ ] ,
218
+ } ) ) ;
219
+ return { loadingServices, services, serviceError } ;
200
220
} ) ;
201
221
202
222
function mapStateToProps ( state ) {
203
223
const query = queryString . parse ( state . router . location . search ) ;
204
224
const isHomepage = ! Object . keys ( query ) . length ;
205
- const { traces, maxDuration, loading , traceError } = stateTraceXformer ( state . trace ) ;
206
- const { services, serviceError } = stateServicesXformer ( state . services ) ;
225
+ const { traces, maxDuration, traceError , loadingTraces } = stateTraceXformer ( state . trace ) ;
226
+ const { loadingServices , services, serviceError } = stateServicesXformer ( state . services ) ;
207
227
const errorMessage = serviceError || traceError ? `${ serviceError || '' } ${ traceError || '' } ` : '' ;
208
228
const sortBy = traceResultsFiltersFormSelector ( state , 'sortBy' ) ;
209
229
sortTraces ( traces , sortBy ) ;
@@ -216,16 +236,21 @@ function mapStateToProps(state) {
216
236
maxTraceDuration : maxDuration ,
217
237
urlQueryParams : query ,
218
238
services,
219
- loading,
239
+ loadingTraces,
240
+ loadingServices,
220
241
errorMessage,
221
242
} ;
222
243
}
223
244
224
245
function mapDispatchToProps ( dispatch ) {
225
- const { searchTraces, fetchServices } = bindActionCreators ( jaegerApiActions , dispatch ) ;
246
+ const { searchTraces, fetchServices, fetchServiceOperations } = bindActionCreators (
247
+ jaegerApiActions ,
248
+ dispatch
249
+ ) ;
226
250
return {
227
- searchTraces ,
251
+ fetchServiceOperations ,
228
252
fetchServices,
253
+ searchTraces,
229
254
} ;
230
255
}
231
256
export const ConnectedSearchTracePage = connect ( mapStateToProps , mapDispatchToProps ) ( SearchTracePage ) ;
0 commit comments