[gold] Speculative addition of corpus to fix searching.
Change-Id: Ieacdc1574584a054f9b0dc2d8d78ff7893775b79
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/291841
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/golden/frontend/res/imp/search-controls-sk.html b/golden/frontend/res/imp/search-controls-sk.html
index 6371079..a51439d 100644
--- a/golden/frontend/res/imp/search-controls-sk.html
+++ b/golden/frontend/res/imp/search-controls-sk.html
@@ -176,7 +176,15 @@
_handleQueryEdit: function(ev) {
ev.stopPropagation();
- this.set('state.query', ev.detail);
+ // TODO(kjlubick) ev.detail does not include the source_type because there was some
+ // special logic in gold.js to add it on when the state changed. This is very confusing
+ // and no longer works (because the corpus selector was moved into the page). Thus,
+ // we need to append the corpus ourselves. This will be not needed when we port this
+ // page to lit-html.
+ const existingCorpus = sk.query.toParamSet(this.state.query).source_type;
+ const newQuery = `source_type=${encodeURIComponent(existingCorpus)}&${ev.detail}`;
+ console.debug('updating search to ', newQuery);
+ this.set('state.query', newQuery);
},
_handleFilterEdit: function(ev) {
diff --git a/golden/frontend/res/js/gold.js b/golden/frontend/res/js/gold.js
index f0b9915..dc83c3b 100644
--- a/golden/frontend/res/js/gold.js
+++ b/golden/frontend/res/js/gold.js
@@ -395,19 +395,9 @@
// Calculates a new path given the state update and an optional new target
// path.
_getRedirectPath: function(updates, newTargetPath) {
- var newState = this._addCorpus(sk.object.applyDelta(updates, this._state));
+ var newState = sk.object.applyDelta(updates, this._state);
var targetPath = newTargetPath || window.location.pathname;
- // TODO(stephana): Remove below if we can ever assign blame across corpora.
- // Account for the special case when the corpus changes and there is a
- // blame field. Then we want to go back to the by-blame-page.
- if ((this._statusElement) && !!newState.blame) {
- var newParams = sk.query.toParamSet(newState.query);
- var oldParams = sk.query.toParamSet(this._state.query);
- if (newParams.source_type[0] !== oldParams.source_type[0]) {
- this._redirectHome();
- }
- }
return targetPath + gold.queryFromState(newState);
},
@@ -437,16 +427,6 @@
_setUrlFromState: function() {
history.replaceState(this._ctx.state, this._ctx.title, window.location.pathname + gold.queryFromState(this._state));
},
-
- // _addCorpus injects the corpus into the query string of a query object.
- _addCorpus: function(state) {
- var params = sk.query.toParamSet(state.query);
- if ((!params['source_type]']) && this._statusElement) {
- params['source_type'] = [this._statusElement.corpus];
- state.query = sk.query.fromParamSet(params);
- }
- return state;
- }
};
})();