Get rid of global Gerrit.Nav
* Replace the global Gerrit.Nav variable with named imports.
* Update gr-app-global-var-init.js
Note: This is not a recommended approach. The change focuses on
removing global variable. See todo in gr-navigation.js
Change-Id: If389574d6d3bc1d643538f6776740bca82f71049
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js
index ba68027..c416b11 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js
@@ -16,7 +16,6 @@
*/
import '../../../scripts/bundled-polymer.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-icons/gr-icons.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import '../gr-change-list/gr-change-list.js';
@@ -31,6 +30,7 @@
import {BaseUrlBehavior} from '../../../behaviors/base-url-behavior/base-url-behavior.js';
import {URLEncodingBehavior} from '../../../behaviors/gr-url-encoding-behavior/gr-url-encoding-behavior.js';
import page from 'page/page.mjs';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const LookupQueryPatterns = {
CHANGE_ID: /^\s*i?[0-9a-f]{7,40}\s*$/i,
@@ -163,7 +163,7 @@
}
_paramsChanged(value) {
- if (value.view !== Gerrit.Nav.View.SEARCH) { return; }
+ if (value.view !== GerritNav.View.SEARCH) { return; }
this._loading = true;
this._query = value.query;
@@ -193,7 +193,7 @@
for (const query in LookupQueryPatterns) {
if (LookupQueryPatterns.hasOwnProperty(query) &&
this._query.match(LookupQueryPatterns[query])) {
- Gerrit.Nav.navigateToChange(changes[0]);
+ GerritNav.navigateToChange(changes[0]);
return;
}
}
@@ -237,7 +237,7 @@
offset = +(offset || 0);
const limit = this._limitFor(query, changesPerPage);
const newOffset = Math.max(0, offset + (limit * direction));
- return Gerrit.Nav.getUrlForSearchQuery(query, newOffset);
+ return GerritNav.getUrlForSearchQuery(query, newOffset);
}
_computePrevArrowClass(offset) {