diff --git a/src/components/SearchTracePage/TraceSearchForm.js b/src/components/SearchTracePage/TraceSearchForm.js index 202e4af578..8f3fc18069 100644 --- a/src/components/SearchTracePage/TraceSearchForm.js +++ b/src/components/SearchTracePage/TraceSearchForm.js @@ -223,8 +223,19 @@ const mapStateToProps = state => { let lastSearchOperation; if (lastSearch) { - lastSearchService = lastSearch.service; - lastSearchOperation = lastSearch.operation; + // last search is only valid if the service is in the list of services + const { operation: lastOp, service: lastSvc } = lastSearch; + if (lastSvc && lastSvc !== '-') { + if (state.services.services.includes(lastSvc)) { + lastSearchService = lastSvc; + if (lastOp && lastOp !== '-') { + const ops = state.services.operationsForService[lastSvc]; + if (lastOp === 'all' || (ops && ops.includes(lastOp))) { + lastSearchOperation = lastOp; + } + } + } + } } const { @@ -242,6 +253,7 @@ const mapStateToProps = state => { if (traceIDParams) { traceIDs = traceIDParams instanceof Array ? traceIDParams.join(',') : traceIDParams; } + return { destroyOnUnmount: false, initialValues: { diff --git a/src/components/SearchTracePage/index.js b/src/components/SearchTracePage/index.js index 5ba3d124df..e933a03a16 100644 --- a/src/components/SearchTracePage/index.js +++ b/src/components/SearchTracePage/index.js @@ -12,14 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +import React, { Component } from 'react'; import _values from 'lodash/values'; import PropTypes from 'prop-types'; -import React, { Component } from 'react'; import queryString from 'query-string'; -import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import { Field, reduxForm, formValueSelector } from 'redux-form'; import { Link } from 'react-router-dom'; +import { bindActionCreators } from 'redux'; +import { Field, reduxForm, formValueSelector } from 'redux-form'; +import store from 'store'; import JaegerLogo from '../../img/jaeger-logo.svg'; @@ -61,21 +62,27 @@ const traceResultsFiltersFormSelector = formValueSelector('traceResultsFilters') export default class SearchTracePage extends Component { componentDidMount() { - const { searchTraces, urlQueryParams, fetchServices } = this.props; + const { searchTraces, urlQueryParams, fetchServices, fetchServiceOperations } = this.props; if (urlQueryParams.service || urlQueryParams.traceID) { searchTraces(urlQueryParams); } fetchServices(); + const { service } = store.get('lastSearch') || {}; + if (service && service !== '-') { + fetchServiceOperations(service); + } } + render() { const { - traceResults, - services, - numberOfTraceResults, - maxTraceDuration, - loading, errorMessage, isHomepage, + loadingServices, + loadingTraces, + maxTraceDuration, + numberOfTraceResults, + services, + traceResults, } = this.props; const hasTraceResults = traceResults && traceResults.length > 0; return ( @@ -83,13 +90,17 @@ export default class SearchTracePage extends Component {