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/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.js b/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.js
index b850dfe..3c48fbe 100644
--- a/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.js
+++ b/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.js
@@ -1,3 +1,5 @@
+import {GerritNav} from '../../elements/core/gr-navigation/gr-navigation.js';
+
/**
* @license
* Copyright (C) 2018 The Android Open Source Project
@@ -136,25 +138,25 @@
groupOwner) {
const subsection = {
name: groupName,
- view: Gerrit.Nav.View.GROUP,
- url: Gerrit.Nav.getUrlForGroup(groupId),
+ view: GerritNav.View.GROUP,
+ url: GerritNav.getUrlForGroup(groupId),
children: [],
};
if (groupIsInternal) {
subsection.children.push({
name: 'Members',
- detailType: Gerrit.Nav.GroupDetailView.MEMBERS,
- view: Gerrit.Nav.View.GROUP,
- url: Gerrit.Nav.getUrlForGroupMembers(groupId),
+ detailType: GerritNav.GroupDetailView.MEMBERS,
+ view: GerritNav.View.GROUP,
+ url: GerritNav.getUrlForGroupMembers(groupId),
});
}
if (groupIsInternal && (isAdmin || groupOwner)) {
subsection.children.push(
{
name: 'Audit Log',
- detailType: Gerrit.Nav.GroupDetailView.LOG,
- view: Gerrit.Nav.View.GROUP,
- url: Gerrit.Nav.getUrlForGroupLog(groupId),
+ detailType: GerritNav.GroupDetailView.LOG,
+ view: GerritNav.View.GROUP,
+ url: GerritNav.getUrlForGroupLog(groupId),
}
);
}
@@ -164,37 +166,37 @@
getRepoSubsections(repoName) {
return {
name: repoName,
- view: Gerrit.Nav.View.REPO,
- url: Gerrit.Nav.getUrlForRepo(repoName),
+ view: GerritNav.View.REPO,
+ url: GerritNav.getUrlForRepo(repoName),
children: [{
name: 'Access',
- view: Gerrit.Nav.View.REPO,
- detailType: Gerrit.Nav.RepoDetailView.ACCESS,
- url: Gerrit.Nav.getUrlForRepoAccess(repoName),
+ view: GerritNav.View.REPO,
+ detailType: GerritNav.RepoDetailView.ACCESS,
+ url: GerritNav.getUrlForRepoAccess(repoName),
},
{
name: 'Commands',
- view: Gerrit.Nav.View.REPO,
- detailType: Gerrit.Nav.RepoDetailView.COMMANDS,
- url: Gerrit.Nav.getUrlForRepoCommands(repoName),
+ view: GerritNav.View.REPO,
+ detailType: GerritNav.RepoDetailView.COMMANDS,
+ url: GerritNav.getUrlForRepoCommands(repoName),
},
{
name: 'Branches',
- view: Gerrit.Nav.View.REPO,
- detailType: Gerrit.Nav.RepoDetailView.BRANCHES,
- url: Gerrit.Nav.getUrlForRepoBranches(repoName),
+ view: GerritNav.View.REPO,
+ detailType: GerritNav.RepoDetailView.BRANCHES,
+ url: GerritNav.getUrlForRepoBranches(repoName),
},
{
name: 'Tags',
- view: Gerrit.Nav.View.REPO,
- detailType: Gerrit.Nav.RepoDetailView.TAGS,
- url: Gerrit.Nav.getUrlForRepoTags(repoName),
+ view: GerritNav.View.REPO,
+ detailType: GerritNav.RepoDetailView.TAGS,
+ url: GerritNav.getUrlForRepoTags(repoName),
},
{
name: 'Dashboards',
- view: Gerrit.Nav.View.REPO,
- detailType: Gerrit.Nav.RepoDetailView.DASHBOARDS,
- url: Gerrit.Nav.getUrlForRepoDashboards(repoName),
+ view: GerritNav.View.REPO,
+ detailType: GerritNav.RepoDetailView.DASHBOARDS,
+ url: GerritNav.getUrlForRepoDashboards(repoName),
}],
};
},
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.js b/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.js
index dbb481d..d2fde51c 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.js
+++ b/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.js
@@ -18,7 +18,6 @@
import '../../../styles/gr-table-styles.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-dialog/gr-dialog.js';
import '../../shared/gr-list-view/gr-list-view.js';
import '../../shared/gr-overlay/gr-overlay.js';
@@ -30,6 +29,7 @@
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-admin-group-list_html.js';
import {ListViewBehavior} from '../../../behaviors/gr-list-view-behavior/gr-list-view-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/**
* @appliesMixin ListViewMixin
@@ -124,7 +124,7 @@
}
_computeGroupUrl(id) {
- return Gerrit.Nav.getUrlForGroup(id);
+ return GerritNav.getUrlForGroup(id);
}
_getCreateGroupCapability() {
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.js b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.js
index d647fb6..a0841f8 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.js
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.js
@@ -18,7 +18,6 @@
import '../../../styles/gr-menu-page-styles.js';
import '../../../styles/gr-page-nav-styles.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-dropdown-list/gr-dropdown-list.js';
import '../../shared/gr-icons/gr-icons.js';
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
@@ -43,6 +42,7 @@
import {BaseUrlBehavior} from '../../../behaviors/base-url-behavior/base-url-behavior.js';
import {AdminNavBehavior} from '../../../behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.js';
import {URLEncodingBehavior} from '../../../behaviors/gr-url-encoding-behavior/gr-url-encoding-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const INTERNAL_GROUP_REGEX = /^[\da-f]{40}$/;
@@ -182,32 +182,32 @@
if (this._selectedIsCurrentPage(selected)) {
return;
}
- Gerrit.Nav.navigateToRelativeUrl(selected.url);
+ GerritNav.navigateToRelativeUrl(selected.url);
}
_paramsChanged(params) {
- const isGroupView = params.view === Gerrit.Nav.View.GROUP;
- const isRepoView = params.view === Gerrit.Nav.View.REPO;
- const isAdminView = params.view === Gerrit.Nav.View.ADMIN;
+ const isGroupView = params.view === GerritNav.View.GROUP;
+ const isRepoView = params.view === GerritNav.View.REPO;
+ const isAdminView = params.view === GerritNav.View.ADMIN;
this.set('_showGroup', isGroupView && !params.detail);
this.set('_showGroupAuditLog', isGroupView &&
- params.detail === Gerrit.Nav.GroupDetailView.LOG);
+ params.detail === GerritNav.GroupDetailView.LOG);
this.set('_showGroupMembers', isGroupView &&
- params.detail === Gerrit.Nav.GroupDetailView.MEMBERS);
+ params.detail === GerritNav.GroupDetailView.MEMBERS);
this.set('_showGroupList', isAdminView &&
params.adminView === 'gr-admin-group-list');
this.set('_showRepoAccess', isRepoView &&
- params.detail === Gerrit.Nav.RepoDetailView.ACCESS);
+ params.detail === GerritNav.RepoDetailView.ACCESS);
this.set('_showRepoCommands', isRepoView &&
- params.detail === Gerrit.Nav.RepoDetailView.COMMANDS);
+ params.detail === GerritNav.RepoDetailView.COMMANDS);
this.set('_showRepoDetailList', isRepoView &&
- (params.detail === Gerrit.Nav.RepoDetailView.BRANCHES ||
- params.detail === Gerrit.Nav.RepoDetailView.TAGS));
+ (params.detail === GerritNav.RepoDetailView.BRANCHES ||
+ params.detail === GerritNav.RepoDetailView.TAGS));
this.set('_showRepoDashboards', isRepoView &&
- params.detail === Gerrit.Nav.RepoDetailView.DASHBOARDS);
+ params.detail === GerritNav.RepoDetailView.DASHBOARDS);
this.set('_showRepoMain', isRepoView && !params.detail);
this.set('_showRepoList', isAdminView &&
@@ -264,15 +264,15 @@
// Group params are structured differently from admin params. Compute
// selected differently for groups.
// TODO(wyatta): Simplify this when all routes work like group params.
- if (params.view === Gerrit.Nav.View.GROUP &&
- itemView === Gerrit.Nav.View.GROUP) {
+ if (params.view === GerritNav.View.GROUP &&
+ itemView === GerritNav.View.GROUP) {
if (!params.detail && !opt_detailType) { return 'selected'; }
if (params.detail === opt_detailType) { return 'selected'; }
return '';
}
- if (params.view === Gerrit.Nav.View.REPO &&
- itemView === Gerrit.Nav.View.REPO) {
+ if (params.view === GerritNav.View.REPO &&
+ itemView === GerritNav.View.REPO) {
if (!params.detail && !opt_detailType) { return 'selected'; }
if (params.detail === opt_detailType) { return 'selected'; }
return '';
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html
index 173c913..cb3ec0e 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html
@@ -34,6 +34,8 @@
import '../../../test/common-test-setup.js';
import './gr-admin-view.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-admin-view tests', () => {
let element;
let sandbox;
@@ -294,7 +296,7 @@
assert.isTrue(element.reload.called);
done();
});
- element.params = {group: 1, view: Gerrit.Nav.View.GROUP};
+ element.params = {group: 1, view: GerritNav.View.GROUP};
element._groupName = 'oldName';
flushAsynchronousOperations();
element.shadowRoot
@@ -333,8 +335,8 @@
element._repoName = 'my-repo';
element.params = {
repo: 'my-repo',
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.ACCESS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.ACCESS,
};
sandbox.stub(
element.$.restAPI,
@@ -460,7 +462,7 @@
parent: 'my-repo',
},
];
- sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl');
+ sandbox.stub(GerritNav, 'navigateToRelativeUrl');
sandbox.spy(element, '_selectedIsCurrentPage');
sandbox.spy(element, '_handleSubsectionChange');
element.reload().then(() => {
@@ -472,12 +474,12 @@
);
assert.isTrue(element._selectedIsCurrentPage.calledOnce);
// Doesn't trigger navigation from the page select menu.
- assert.isFalse(Gerrit.Nav.navigateToRelativeUrl.called);
+ assert.isFalse(GerritNav.navigateToRelativeUrl.called);
// When explicitly changed, navigation is called
element.shadowRoot.querySelector('#pageSelect').value = 'repo';
assert.isTrue(element._selectedIsCurrentPage.calledTwice);
- assert.isTrue(Gerrit.Nav.navigateToRelativeUrl.calledOnce);
+ assert.isTrue(GerritNav.navigateToRelativeUrl.calledOnce);
done();
});
});
@@ -524,7 +526,7 @@
test('repo list', () => {
element.params = {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
openCreateModal: false,
};
@@ -537,7 +539,7 @@
test('repo', () => {
element.params = {
- view: Gerrit.Nav.View.REPO,
+ view: GerritNav.View.REPO,
repoName: 'foo',
};
element._repoName = 'foo';
@@ -552,8 +554,8 @@
test('repo access', () => {
element.params = {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.ACCESS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.ACCESS,
repoName: 'foo',
};
element._repoName = 'foo';
@@ -568,8 +570,8 @@
test('repo dashboards', () => {
element.params = {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.DASHBOARDS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.DASHBOARDS,
repoName: 'foo',
};
element._repoName = 'foo';
@@ -604,7 +606,7 @@
test('group list', () => {
element.params = {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-admin-group-list',
openCreateModal: false,
};
@@ -617,7 +619,7 @@
test('internal group', () => {
element.params = {
- view: Gerrit.Nav.View.GROUP,
+ view: GerritNav.View.GROUP,
groupId: 1234,
};
element._groupName = 'foo';
@@ -642,7 +644,7 @@
id: 'external-id',
}));
element.params = {
- view: Gerrit.Nav.View.GROUP,
+ view: GerritNav.View.GROUP,
groupId: 1234,
};
element._groupName = 'foo';
@@ -661,8 +663,8 @@
test('group members', () => {
element.params = {
- view: Gerrit.Nav.View.GROUP,
- detail: Gerrit.Nav.GroupDetailView.MEMBERS,
+ view: GerritNav.View.GROUP,
+ detail: GerritNav.GroupDetailView.MEMBERS,
groupId: 1234,
};
element._groupName = 'foo';
diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.js b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.js
index e7d0cbe..3347655 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.js
+++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.js
@@ -20,7 +20,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/gr-form-styles.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-autocomplete/gr-autocomplete.js';
import '../../shared/gr-button/gr-button.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
@@ -32,6 +31,7 @@
import {htmlTemplate} from './gr-create-change-dialog_html.js';
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 {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const SUGGESTIONS_LIMIT = 15;
const REF_PREFIX = 'refs/heads/';
@@ -119,7 +119,7 @@
this.baseCommit || null)
.then(changeCreated => {
if (!changeCreated) { return; }
- Gerrit.Nav.navigateToChange(changeCreated);
+ GerritNav.navigateToChange(changeCreated);
});
}
diff --git a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.js b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.js
index cf4f0fc..a3c05cb 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.js
+++ b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.js
@@ -18,7 +18,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/gr-table-styles.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-date-formatter/gr-date-formatter.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import '../../shared/gr-account-link/gr-account-link.js';
@@ -28,6 +27,7 @@
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-group-audit-log_html.js';
import {ListViewBehavior} from '../../../behaviors/gr-list-view-behavior/gr-list-view-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const GROUP_EVENTS = ['ADD_GROUP', 'REMOVE_GROUP'];
@@ -117,7 +117,7 @@
_computeGroupUrl(group) {
if (group && group.url && group.id) {
- return Gerrit.Nav.getUrlForGroup(group.id);
+ return GerritNav.getUrlForGroup(group.id);
}
return '';
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.js b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.js
index 6b9859f2..9aa81f8 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.js
+++ b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.js
@@ -19,7 +19,6 @@
import '../../../styles/gr-menu-page-styles.js';
import '../../../styles/gr-subpage-styles.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import '../gr-access-section/gr-access-section.js';
import {flush, dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
@@ -31,6 +30,7 @@
import {BaseUrlBehavior} from '../../../behaviors/base-url-behavior/base-url-behavior.js';
import {AccessBehavior} from '../../../behaviors/gr-access-behavior/gr-access-behavior.js';
import {URLEncodingBehavior} from '../../../behaviors/gr-url-encoding-behavior/gr-url-encoding-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const Defs = {};
@@ -486,7 +486,7 @@
return this.$.restAPI
.setRepoAccessRightsForReview(this.repo, obj)
.then(change => {
- Gerrit.Nav.navigateToChange(change);
+ GerritNav.navigateToChange(change);
})
.finally(() => {
this._modified = false;
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access_test.html b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access_test.html
index 83da605..4835dfe 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access_test.html
+++ b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access_test.html
@@ -35,6 +35,8 @@
import '../../../test/common-test-setup.js';
import './gr-repo-access.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-repo-access tests', () => {
let element;
let sandbox;
@@ -1179,7 +1181,7 @@
};
sandbox.stub(element.$.restAPI, 'getRepoAccessRights').returns(
Promise.resolve(JSON.parse(JSON.stringify(accessRes))));
- sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ sandbox.stub(GerritNav, 'navigateToChange');
let resolver;
const saveStub = sandbox.stub(element.$.restAPI,
'setRepoAccessRights')
@@ -1194,7 +1196,7 @@
resolver({_number: 1});
flush(() => {
assert.isTrue(saveStub.called);
- assert.isTrue(Gerrit.Nav.navigateToChange.notCalled);
+ assert.isTrue(GerritNav.navigateToChange.notCalled);
done();
});
});
@@ -1226,7 +1228,7 @@
};
sandbox.stub(element.$.restAPI, 'getRepoAccessRights').returns(
Promise.resolve(JSON.parse(JSON.stringify(accessRes))));
- sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ sandbox.stub(GerritNav, 'navigateToChange');
let resolver;
const saveForReviewStub = sandbox.stub(element.$.restAPI,
'setRepoAccessRightsForReview')
@@ -1241,7 +1243,7 @@
resolver({_number: 1});
flush(() => {
assert.isTrue(saveForReviewStub.called);
- assert.isTrue(Gerrit.Nav.navigateToChange
+ assert.isTrue(GerritNav.navigateToChange
.lastCall.calledWithExactly({_number: 1}));
done();
});
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands.js b/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands.js
index cbe0d0a..1f1dc5b 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands.js
+++ b/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands.js
@@ -31,6 +31,7 @@
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-repo-commands_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const GC_MESSAGE = 'Garbage collection completed successfully.';
@@ -135,7 +136,7 @@
{detail: {message}, bubbles: true, composed: true}));
if (!change) { return; }
- Gerrit.Nav.navigateToRelativeUrl(Gerrit.Nav.getEditUrlForDiff(
+ GerritNav.navigateToRelativeUrl(GerritNav.getEditUrlForDiff(
change, CONFIG_PATH, INITIAL_PATCHSET));
});
}
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands_test.html b/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands_test.html
index 0dad516..948eaa2 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands_test.html
+++ b/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands_test.html
@@ -34,6 +34,8 @@
<script type="module">
import '../../../test/common-test-setup.js';
import './gr-repo-commands.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-repo-commands tests', () => {
let element;
let sandbox;
@@ -86,8 +88,8 @@
setup(() => {
createChangeStub = sandbox.stub(element.$.restAPI, 'createChange');
- urlStub = sandbox.stub(Gerrit.Nav, 'getEditUrlForDiff');
- sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl');
+ urlStub = sandbox.stub(GerritNav, 'getEditUrlForDiff');
+ sandbox.stub(GerritNav, 'navigateToRelativeUrl');
handleSpy = sandbox.spy(element, '_handleEditRepoConfig');
alertStub = sandbox.stub();
element.addEventListener('show-alert', alertStub);
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.js b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.js
index cb72a18..072fc721 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.js
+++ b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.js
@@ -17,13 +17,13 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import {flush} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-repo-dashboards_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/**
* @extends Polymer.Element
@@ -91,7 +91,7 @@
_getUrl(project, id) {
if (!project || !id) { return ''; }
- return Gerrit.Nav.getUrlForRepoDashboard(project, id);
+ return GerritNav.getUrlForRepoDashboard(project, id);
}
_computeLoadingClass(loading) {
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards_test.html b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards_test.html
index 14e67e9..8cae592 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards_test.html
+++ b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards_test.html
@@ -33,6 +33,8 @@
<script type="module">
import '../../../test/common-test-setup.js';
import './gr-repo-dashboards.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-repo-dashboards tests', () => {
let element;
let sandbox;
@@ -129,7 +131,7 @@
suite('test url', () => {
test('_getUrl', () => {
- sandbox.stub(Gerrit.Nav, 'getUrlForRepoDashboard',
+ sandbox.stub(GerritNav, 'getUrlForRepoDashboard',
() => '/r/dashboard/test');
assert.equal(element._getUrl('/dashboard/test', {}), '/r/dashboard/test');
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.js b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.js
index 8378296..59abb72 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.js
+++ b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.js
@@ -29,6 +29,7 @@
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-repo-list_html.js';
import {ListViewBehavior} from '../../../behaviors/gr-list-view-behavior/gr-list-view-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/**
* @appliesMixin ListViewMixin
@@ -130,7 +131,7 @@
}
_computeChangesLink(name) {
- return Gerrit.Nav.getUrlForProjectChanges(name);
+ return GerritNav.getUrlForProjectChanges(name);
}
_getCreateRepoCapability() {
diff --git a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js
index cfc4015..05ae73d 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js
+++ b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js
@@ -31,6 +31,7 @@
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-repo_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const STATES = {
active: {value: 'ACTIVE', label: 'Active'},
@@ -367,7 +368,7 @@
}
_computeChangesUrl(name) {
- return Gerrit.Nav.getUrlForProjectChanges(name);
+ return GerritNav.getUrlForProjectChanges(name);
}
_handlePluginConfigChanged({detail: {name, config, notifyPath}}) {
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js
index 7e42a9f..ec63079 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js
@@ -17,7 +17,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/gr-change-list-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-account-link/gr-account-link.js';
import '../../shared/gr-change-star/gr-change-star.js';
import '../../shared/gr-change-status/gr-change-status.js';
@@ -38,6 +37,7 @@
import {PathListBehavior} from '../../../behaviors/gr-path-list-behavior/gr-path-list-behavior.js';
import {URLEncodingBehavior} from '../../../behaviors/gr-url-encoding-behavior/gr-url-encoding-behavior.js';
import {RESTClientBehavior} from '../../../behaviors/rest-client-behavior/rest-client-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const CHANGE_SIZE = {
XS: 10,
@@ -105,7 +105,7 @@
}
_computeChangeURL(change) {
- return Gerrit.Nav.getUrlForChange(change);
+ return GerritNav.getUrlForChange(change);
}
_computeLabelTitle(change, labelName) {
@@ -166,18 +166,18 @@
}
_computeRepoUrl(change) {
- return Gerrit.Nav.getUrlForProjectChanges(change.project, true,
+ return GerritNav.getUrlForProjectChanges(change.project, true,
change.internalHost);
}
_computeRepoBranchURL(change) {
- return Gerrit.Nav.getUrlForBranch(change.branch, change.project, null,
+ return GerritNav.getUrlForBranch(change.branch, change.project, null,
change.internalHost);
}
_computeTopicURL(change) {
if (!change.topic) { return ''; }
- return Gerrit.Nav.getUrlForTopic(change.topic, change.internalHost);
+ return GerritNav.getUrlForTopic(change.topic, change.internalHost);
}
/**
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html
index 8af8592..f7361d2 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html
@@ -33,6 +33,8 @@
<script type="module">
import '../../../test/common-test-setup.js';
import './gr-change-list-item.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-change-list-item tests', () => {
let element;
let sandbox;
@@ -242,7 +244,7 @@
});
test('change params passed to gr-navigation', () => {
- sandbox.stub(Gerrit.Nav);
+ sandbox.stub(GerritNav);
const change = {
internalHost: 'test-host',
project: 'test-repo',
@@ -252,12 +254,12 @@
element.change = change;
flushAsynchronousOperations();
- assert.deepEqual(Gerrit.Nav.getUrlForChange.lastCall.args, [change]);
- assert.deepEqual(Gerrit.Nav.getUrlForProjectChanges.lastCall.args,
+ assert.deepEqual(GerritNav.getUrlForChange.lastCall.args, [change]);
+ assert.deepEqual(GerritNav.getUrlForProjectChanges.lastCall.args,
[change.project, true, change.internalHost]);
- assert.deepEqual(Gerrit.Nav.getUrlForBranch.lastCall.args,
+ assert.deepEqual(GerritNav.getUrlForBranch.lastCall.args,
[change.branch, change.project, null, change.internalHost]);
- assert.deepEqual(Gerrit.Nav.getUrlForTopic.lastCall.args,
+ assert.deepEqual(GerritNav.getUrlForTopic.lastCall.args,
[change.topic, change.internalHost]);
});
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) {
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view_test.html b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view_test.html
index ab57143e..33e70a0 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view_test.html
@@ -35,6 +35,7 @@
import '../../../test/common-test-setup.js';
import './gr-change-list-view.js';
import page from 'page/page.mjs';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const CHANGE_ID = 'IcA3dAB3edAB9f60B8dcdA6ef71A75980e4B7127';
const COMMIT_HASH = '12345678';
@@ -78,7 +79,7 @@
});
test('_computeNavLink', () => {
- const getUrlStub = sandbox.stub(Gerrit.Nav, 'getUrlForSearchQuery')
+ const getUrlStub = sandbox.stub(GerritNav, 'getUrlForSearchQuery')
.returns('');
const query = 'status:open';
let offset = 0;
@@ -209,44 +210,44 @@
const change = {_number: 1};
sandbox.stub(element, '_getChanges')
.returns(Promise.resolve([change]));
- sandbox.stub(Gerrit.Nav, 'navigateToChange', url => {
+ sandbox.stub(GerritNav, 'navigateToChange', url => {
assert.equal(url, change);
done();
});
- element.params = {view: Gerrit.Nav.View.SEARCH, query: CHANGE_ID};
+ element.params = {view: GerritNav.View.SEARCH, query: CHANGE_ID};
});
test('Searching for a change num redirects to change', done => {
const change = {_number: 1};
sandbox.stub(element, '_getChanges')
.returns(Promise.resolve([change]));
- sandbox.stub(Gerrit.Nav, 'navigateToChange', url => {
+ sandbox.stub(GerritNav, 'navigateToChange', url => {
assert.equal(url, change);
done();
});
- element.params = {view: Gerrit.Nav.View.SEARCH, query: '1'};
+ element.params = {view: GerritNav.View.SEARCH, query: '1'};
});
test('Commit hash redirects to change', done => {
const change = {_number: 1};
sandbox.stub(element, '_getChanges')
.returns(Promise.resolve([change]));
- sandbox.stub(Gerrit.Nav, 'navigateToChange', url => {
+ sandbox.stub(GerritNav, 'navigateToChange', url => {
assert.equal(url, change);
done();
});
- element.params = {view: Gerrit.Nav.View.SEARCH, query: COMMIT_HASH};
+ element.params = {view: GerritNav.View.SEARCH, query: COMMIT_HASH};
});
test('Searching for an invalid change ID searches', () => {
sandbox.stub(element, '_getChanges')
.returns(Promise.resolve([]));
- const stub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ const stub = sandbox.stub(GerritNav, 'navigateToChange');
- element.params = {view: Gerrit.Nav.View.SEARCH, query: CHANGE_ID};
+ element.params = {view: GerritNav.View.SEARCH, query: CHANGE_ID};
flushAsynchronousOperations();
assert.isFalse(stub.called);
@@ -255,9 +256,9 @@
test('Change ID with multiple search results searches', () => {
sandbox.stub(element, '_getChanges')
.returns(Promise.resolve([{}, {}]));
- const stub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ const stub = sandbox.stub(GerritNav, 'navigateToChange');
- element.params = {view: Gerrit.Nav.View.SEARCH, query: CHANGE_ID};
+ element.params = {view: GerritNav.View.SEARCH, query: CHANGE_ID};
flushAsynchronousOperations();
assert.isFalse(stub.called);
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
index d6da71a..9455ba6 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
@@ -17,7 +17,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/gr-change-list-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-cursor-manager/gr-cursor-manager.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import '../gr-change-list-item/gr-change-list-item.js';
@@ -36,6 +35,7 @@
import {URLEncodingBehavior} from '../../../behaviors/gr-url-encoding-behavior/gr-url-encoding-behavior.js';
import {KeyboardShortcutBehavior} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
import {RESTClientBehavior} from '../../../behaviors/rest-client-behavior/rest-client-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const NUMBER_FIXED_COLUMNS = 3;
const CLOSED_STATUS = ['MERGED', 'ABANDONED'];
@@ -271,7 +271,7 @@
}
_sectionHref(query) {
- return Gerrit.Nav.getUrlForSearchQuery(this._processQuery(query));
+ return GerritNav.getUrlForSearchQuery(this._processQuery(query));
}
/**
@@ -333,7 +333,7 @@
this.modifierPressed(e)) { return; }
e.preventDefault();
- Gerrit.Nav.navigateToChange(this._changeForIndex(this.selectedIndex));
+ GerritNav.navigateToChange(this._changeForIndex(this.selectedIndex));
}
_nextPage(e) {
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
index e736682..c535600 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
@@ -43,6 +43,8 @@
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {afterNextRender} from '@polymer/polymer/lib/utils/render-status.js';
import {KeyboardShortcutBinder} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-change-list basic tests', () => {
// Define keybindings before attaching other fixtures.
const kb = KeyboardShortcutBinder;
@@ -192,7 +194,7 @@
assert.equal(element.selectedIndex, 2);
assert.isTrue(elementItems[2].hasAttribute('selected'));
- const navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ const navStub = sandbox.stub(GerritNav, 'navigateToChange');
assert.equal(element.selectedIndex, 2);
MockInteractions.pressAndReleaseKeyOn(element, 13, null, 'enter');
assert.deepEqual(navStub.lastCall.args[0], {_number: 2},
@@ -559,7 +561,7 @@
assert.equal(element.selectedIndex, 1);
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
- const navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ const navStub = sandbox.stub(GerritNav, 'navigateToChange');
assert.equal(element.selectedIndex, 2);
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
index e9ddd1e..8b8b981 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
@@ -33,6 +33,7 @@
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-dashboard-view_html.js';
import {RESTClientBehavior} from '../../../behaviors/rest-client-behavior/rest-client-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const PROJECT_PLACEHOLDER_PATTERN = /\$\{project\}/g;
@@ -155,7 +156,7 @@
}
_isViewActive(params) {
- return params.view === Gerrit.Nav.View.DASHBOARD;
+ return params.view === GerritNav.View.DASHBOARD;
}
_paramsChanged(paramsChangeRecord) {
@@ -178,7 +179,7 @@
const {project, dashboard, title, user, sections} = this.params;
const dashboardPromise = project ?
this._getProjectDashboard(project, dashboard) :
- Promise.resolve(Gerrit.Nav.getUserDashboard(
+ Promise.resolve(GerritNav.getUserDashboard(
user,
sections,
title || this._computeTitle(user)));
@@ -319,7 +320,7 @@
}
_computeDraftsLink() {
- return Gerrit.Nav.getUrlForSearchQuery('has:draft -is:open');
+ return GerritNav.getUrlForSearchQuery('has:draft -is:open');
}
_createChangeTap(e) {
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.html b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.html
index 9e9a8f2..19742a5 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.html
@@ -34,6 +34,8 @@
import '../../../test/common-test-setup.js';
import './gr-dashboard-view.js';
import {isHidden} from '../../../test/test-utils.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-dashboard-view tests', () => {
let element;
let sandbox;
@@ -186,7 +188,7 @@
test('content is refreshed when user param is updated', () => {
element.params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
user: 'self',
};
return paramsChangedPromise.then(() => {
@@ -198,7 +200,7 @@
suite('selfOnly sections', () => {
test('viewing self dashboard includes selfOnly sections', () => {
element.params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
sections: [
{query: '1'},
{query: '2', selfOnly: true},
@@ -213,7 +215,7 @@
test('viewing another user\'s dashboard omits selfOnly sections', () => {
element.params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
sections: [
{query: '1'},
{query: '2', selfOnly: true},
@@ -228,7 +230,7 @@
test('suffixForDashboard is included in getChanges query', () => {
element.params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
sections: [
{query: '1'},
{query: '2', suffixForDashboard: 'suffix'},
@@ -357,7 +359,7 @@
done();
});
element.params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
project: 'project',
dashboard: 'dashboard',
};
@@ -366,7 +368,7 @@
test('params change triggers dashboardDisplayed()', () => {
sandbox.stub(element.$.reporting, 'dashboardDisplayed');
element.params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
project: 'project',
dashboard: 'dashboard',
};
diff --git a/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.js b/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.js
index e9a0387..5f0021e 100644
--- a/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.js
+++ b/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.js
@@ -18,13 +18,13 @@
import '../../../styles/dashboard-header-styles.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-date-formatter/gr-date-formatter.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-repo-header_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/** @extends Polymer.Element */
class GrRepoHeader extends GestureEventListeners(
@@ -51,7 +51,7 @@
this._repoUrl = null;
return;
}
- this._repoUrl = Gerrit.Nav.getUrlForRepo(repoName);
+ this._repoUrl = GerritNav.getUrlForRepo(repoName);
}
}
diff --git a/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header_test.html b/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header_test.html
index a075870..b0a8d1c 100644
--- a/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header_test.html
@@ -33,6 +33,8 @@
<script type="module">
import '../../../test/common-test-setup.js';
import './gr-repo-header.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-repo-header tests', () => {
let element;
let sandbox;
@@ -45,7 +47,7 @@
teardown(() => { sandbox.restore(); });
test('repoUrl reset once repo changed', () => {
- sandbox.stub(Gerrit.Nav, 'getUrlForRepo',
+ sandbox.stub(GerritNav, 'getUrlForRepo',
repoName => `http://test.com/${repoName}`
);
assert.equal(element._repoUrl, undefined);
diff --git a/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.js b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.js
index 3fc4291..6bb1bf8 100644
--- a/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.js
+++ b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.js
@@ -17,7 +17,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator.js';
import '../../plugins/gr-endpoint-param/gr-endpoint-param.js';
import '../../shared/gr-avatar/gr-avatar.js';
@@ -28,6 +27,7 @@
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-user-header_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/**
* @extends Polymer.Element
@@ -105,7 +105,7 @@
const id = accountDetails._account_id;
const email = accountDetails.email;
if (!id && !email ) { return null; }
- return Gerrit.Nav.getUrlForUserDashboard(id ? id : email);
+ return GerritNav.getUrlForUserDashboard(id ? id : email);
}
_computeDashboardLinkClass(showDashboardLink, loggedIn) {
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
index b94b286..2cd5de5 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
@@ -17,7 +17,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../admin/gr-create-change-dialog/gr-create-change-dialog.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../core/gr-reporting/gr-reporting.js';
import '../../shared/gr-button/gr-button.js';
import '../../shared/gr-dialog/gr-dialog.js';
@@ -43,6 +42,7 @@
import {htmlTemplate} from './gr-change-actions_html.js';
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
import {RESTClientBehavior} from '../../../behaviors/rest-client-behavior/rest-client-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const ERR_BRANCH_EMPTY = 'The destination branch can’t be empty.';
const ERR_COMMIT_EMPTY = 'The commit message can’t be empty.';
@@ -1336,30 +1336,30 @@
this._waitForChangeReachable(obj._number)
.then(() => this._setLabelValuesOnRevert(obj._number))
.then(() => {
- Gerrit.Nav.navigateToChange(obj);
+ GerritNav.navigateToChange(obj);
});
break;
case RevisionActions.CHERRYPICK:
this._waitForChangeReachable(obj._number).then(() => {
- Gerrit.Nav.navigateToChange(obj);
+ GerritNav.navigateToChange(obj);
});
break;
case ChangeActions.DELETE:
if (action.__type === ActionType.CHANGE) {
- Gerrit.Nav.navigateToRelativeUrl(Gerrit.Nav.getUrlForRoot());
+ GerritNav.navigateToRelativeUrl(GerritNav.getUrlForRoot());
}
break;
case ChangeActions.WIP:
case ChangeActions.DELETE_EDIT:
case ChangeActions.PUBLISH_EDIT:
case ChangeActions.REBASE_EDIT:
- Gerrit.Nav.navigateToChange(this.change);
+ GerritNav.navigateToChange(this.change);
break;
case ChangeActions.REVERT_SUBMISSION:
if (!obj.revert_changes || !obj.revert_changes.length) return;
/* If there is only 1 change then gerrit will automatically
redirect to that change */
- Gerrit.Nav.navigateToSearchQuery('topic: ' +
+ GerritNav.navigateToSearchQuery('topic: ' +
obj.revert_changes[0].topic);
break;
default:
@@ -1416,7 +1416,7 @@
action: 'Reload',
callback: () => {
// Load the current change without any patch range.
- Gerrit.Nav.navigateToChange(this.change);
+ GerritNav.navigateToChange(this.change);
},
},
composed: true, bubbles: true,
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
index 0218acf..f14ac7e 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
@@ -34,6 +34,7 @@
import '../../../test/common-test-setup.js';
import './gr-change-actions.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const CHERRY_PICK_TYPES = {
SINGLE_CHANGE: 1,
TOPIC: 2,
@@ -1810,7 +1811,7 @@
.returns(Promise.resolve({}));
getResponseObjectStub = sandbox.stub(element.$.restAPI,
'getResponseObject');
- sandbox.stub(Gerrit.Nav,
+ sandbox.stub(GerritNav,
'navigateToChange').returns(Promise.resolve(true));
sandbox.stub(element, 'computeLatestPatchNum')
.returns(element.latestPatchNum);
@@ -1865,7 +1866,7 @@
.returns(Promise.resolve({revert_changes: [
{change_id: 12345},
]}));
- navigateToSearchQueryStub = sandbox.stub(Gerrit.Nav,
+ navigateToSearchQueryStub = sandbox.stub(GerritNav,
'navigateToSearchQuery');
});
@@ -1891,7 +1892,7 @@
{change_id: 23456, topic: 'T'},
]}));
showActionDialogStub = sandbox.stub(element, '_showActionDialog');
- navigateToSearchQueryStub = sandbox.stub(Gerrit.Nav,
+ navigateToSearchQueryStub = sandbox.stub(GerritNav,
'navigateToSearchQuery');
});
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js
index 3878a26..dfd5037 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js
@@ -20,7 +20,6 @@
import '../../../styles/gr-change-metadata-shared-styles.js';
import '../../../styles/gr-change-view-integration-shared-styles.js';
import '../../../styles/gr-voting-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator.js';
import '../../plugins/gr-endpoint-param/gr-endpoint-param.js';
import '../../plugins/gr-external-style/gr-external-style.js';
@@ -45,6 +44,7 @@
import {htmlTemplate} from './gr-change-metadata_html.js';
import {RESTClientBehavior} from '../../../behaviors/rest-client-behavior/rest-client-behavior.js';
import {GrReviewerSuggestionsProvider} from '../../../scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const HASHTAG_ADD_MESSAGE = 'Add Hashtag';
@@ -215,7 +215,7 @@
*/
_computeWebLinks(commitInfo, serverConfig) {
if (!commitInfo) { return null; }
- const weblinks = Gerrit.Nav.getChangeWeblinks(
+ const weblinks = GerritNav.getChangeWeblinks(
this.change ? this.change.repo : '',
commitInfo.commit,
{
@@ -393,26 +393,26 @@
}
_computeProjectUrl(project) {
- return Gerrit.Nav.getUrlForProjectChanges(project);
+ return GerritNav.getUrlForProjectChanges(project);
}
_computeBranchUrl(project, branch) {
if (!this.change || !this.change.status) return '';
- return Gerrit.Nav.getUrlForBranch(branch, project,
+ return GerritNav.getUrlForBranch(branch, project,
this.change.status == this.ChangeStatus.NEW ? 'open' :
this.change.status.toLowerCase());
}
_computeCherryPickOfUrl(change, patchset, project) {
- return Gerrit.Nav.getUrlForChangeById(change, project, patchset);
+ return GerritNav.getUrlForChangeById(change, project, patchset);
}
_computeTopicUrl(topic) {
- return Gerrit.Nav.getUrlForTopic(topic);
+ return GerritNav.getUrlForTopic(topic);
}
_computeHashtagUrl(hashtag) {
- return Gerrit.Nav.getUrlForHashtag(hashtag);
+ return GerritNav.getUrlForHashtag(hashtag);
}
_handleTopicRemoved(e) {
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html
index ce3770f..3288fb0 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html
@@ -34,6 +34,8 @@
import '../../../test/common-test-setup.js';
import '../../core/gr-router/gr-router.js';
import './gr-change-metadata.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-change-metadata tests', () => {
let element;
let sandbox;
@@ -119,8 +121,8 @@
.querySelector('.strategy').hasAttribute('hidden'));
});
- test('weblinks use Gerrit.Nav interface', () => {
- const weblinksStub = sandbox.stub(Gerrit.Nav, '_generateWeblinks')
+ test('weblinks use GerritNav interface', () => {
+ const weblinksStub = sandbox.stub(GerritNav, '_generateWeblinks')
.returns([{name: 'stubb', url: '#s'}]);
element.commitInfo = {};
element.serverConfig = {};
@@ -163,7 +165,7 @@
test('weblinks are visible when other weblinks', () => {
const router = document.createElement('gr-router');
- sandbox.stub(Gerrit.Nav, '_generateWeblinks',
+ sandbox.stub(GerritNav, '_generateWeblinks',
router._generateWeblinks.bind(router));
element.commitInfo = {web_links: [{name: 'test', url: '#'}]};
@@ -179,7 +181,7 @@
test('weblinks are visible when gitiles and other weblinks', () => {
const router = document.createElement('gr-router');
- sandbox.stub(Gerrit.Nav, '_generateWeblinks',
+ sandbox.stub(GerritNav, '_generateWeblinks',
router._generateWeblinks.bind(router));
element.commitInfo = {
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
index af924a8..63bfa3a 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
@@ -18,7 +18,6 @@
import '@polymer/paper-tabs/paper-tabs.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../core/gr-reporting/gr-reporting.js';
import '../../diff/gr-comment-api/gr-comment-api.js';
import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator.js';
@@ -61,6 +60,7 @@
import {GrEditConstants} from '../../edit/gr-edit-constants.js';
import {GrCountStringFormatter} from '../../shared/gr-count-string-formatter/gr-count-string-formatter.js';
import {util} from '../../../scripts/util.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
import {PrimaryTabs, SecondaryTabs} from '../../../constants/constants.js';
import {NO_ROBOT_COMMENTS_THREADS_MSG} from '../../../constants/messages.js';
@@ -1006,7 +1006,7 @@
}
_paramsChanged(value) {
- if (value.view !== Gerrit.Nav.View.CHANGE) {
+ if (value.view !== GerritNav.View.CHANGE) {
this._initialLoadComplete = false;
return;
}
@@ -1132,7 +1132,7 @@
_handleMessageAnchorTap(e) {
const hash = MSG_PREFIX + e.detail.id;
- const url = Gerrit.Nav.getUrlForChange(this._change,
+ const url = GerritNav.getUrlForChange(this._change,
this._patchRange.patchNum, this._patchRange.basePatchNum,
this._editMode, hash);
history.replaceState(null, '', url);
@@ -1258,7 +1258,7 @@
}
_computeChangeUrl(change) {
- return Gerrit.Nav.getUrlForChange(change);
+ return GerritNav.getUrlForChange(change);
}
_computeShowCommitInfo(changeStatus, current_revision) {
@@ -1403,7 +1403,7 @@
_handleRefreshChange(e) {
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
e.preventDefault();
- Gerrit.Nav.navigateToChange(this._change);
+ GerritNav.navigateToChange(this._change);
}
_handleToggleChangeStar(e) {
@@ -1451,8 +1451,8 @@
_determinePageBack() {
// Default backPage to root if user came to change view page
// via an email link, etc.
- Gerrit.Nav.navigateToRelativeUrl(this.backPage ||
- Gerrit.Nav.getUrlForRoot());
+ GerritNav.navigateToRelativeUrl(this.backPage ||
+ GerritNav.getUrlForRoot());
}
_handleLabelRemoved(splices, path) {
@@ -1500,7 +1500,7 @@
// with the latest patch.
const action = e.detail.action;
if (action === 'rebase' || action === 'submit') {
- Gerrit.Nav.navigateToChange(this._change);
+ GerritNav.navigateToChange(this._change);
}
});
}
@@ -2054,7 +2054,7 @@
action: 'Reload',
callback: function() {
// Load the current change without any patch range.
- Gerrit.Nav.navigateToChange(this._change);
+ GerritNav.navigateToChange(this._change);
}.bind(this),
},
composed: true, bubbles: true,
@@ -2108,8 +2108,8 @@
controls.openDeleteDialog(path);
break;
case GrEditConstants.Actions.OPEN.id:
- Gerrit.Nav.navigateToRelativeUrl(
- Gerrit.Nav.getEditUrlForDiff(this._change, path,
+ GerritNav.navigateToRelativeUrl(
+ GerritNav.getEditUrlForDiff(this._change, path,
this._patchRange.patchNum));
break;
case GrEditConstants.Actions.RENAME.id:
@@ -2151,7 +2151,7 @@
info._number === this.EDIT_NAME);
if (editInfo) {
- Gerrit.Nav.navigateToChange(this._change, this.EDIT_NAME);
+ GerritNav.navigateToChange(this._change, this.EDIT_NAME);
return;
}
@@ -2162,11 +2162,11 @@
this.computeLatestPatchNum(this._allPatchSets))) {
patchNum = this._patchRange.patchNum;
}
- Gerrit.Nav.navigateToChange(this._change, patchNum, null, true);
+ GerritNav.navigateToChange(this._change, patchNum, null, true);
}
_handleStopEditTap() {
- Gerrit.Nav.navigateToChange(this._change, this._patchRange.patchNum);
+ GerritNav.navigateToChange(this._change, this._patchRange.patchNum);
}
_resetReplyOverlayFocusStops() {
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html
index 6fce5bc..e12b4bf 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html
@@ -48,6 +48,7 @@
import {GrEditConstants} from '../../edit/gr-edit-constants.js';
import {GrPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
import {util} from '../../../scripts/util.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
suite('gr-change-view tests', () => {
const kb = KeyboardShortcutBinder;
@@ -298,7 +299,7 @@
});
// Since _endpoints are global, must reset state.
Gerrit._endpoints = new GrPluginEndpoints();
- navigateToChangeStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ navigateToChangeStub = sandbox.stub(GerritNav, 'navigateToChange');
stub('gr-rest-api-interface', {
getConfig() { return Promise.resolve({test: 'config'}); },
getAccount() { return Promise.resolve(null); },
@@ -342,7 +343,7 @@
basePatchNum: 'PARENT',
patchNum: 1,
};
- const getUrlStub = sandbox.stub(Gerrit.Nav, 'getUrlForChange');
+ const getUrlStub = sandbox.stub(GerritNav, 'getUrlForChange');
const replaceStateStub = sandbox.stub(history, 'replaceState');
element._handleMessageAnchorTap({detail: {id: 'a12345'}});
@@ -391,7 +392,7 @@
// view is required
element.params = Object.assign(
{
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
},
element.params, {queryMap});
flush(() => {
@@ -407,7 +408,7 @@
// view is required
element.params = Object.assign(
{
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
},
element.params, {queryMap});
flush(() => {
@@ -441,16 +442,16 @@
});
test('U should navigate to root if no backPage set', () => {
- const relativeNavStub = sandbox.stub(Gerrit.Nav,
+ const relativeNavStub = sandbox.stub(GerritNav,
'navigateToRelativeUrl');
MockInteractions.pressAndReleaseKeyOn(element, 85, null, 'u');
assert.isTrue(relativeNavStub.called);
assert.isTrue(relativeNavStub.lastCall.calledWithExactly(
- Gerrit.Nav.getUrlForRoot()));
+ GerritNav.getUrlForRoot()));
});
test('U should navigate to backPage if set', () => {
- const relativeNavStub = sandbox.stub(Gerrit.Nav,
+ const relativeNavStub = sandbox.stub(GerritNav,
'navigateToRelativeUrl');
element.backPage = '/dashboard/self';
MockInteractions.pressAndReleaseKeyOn(element, 85, null, 'u');
@@ -609,7 +610,7 @@
};
navigateToChangeStub.restore();
- navigateToChangeStub = sandbox.stub(Gerrit.Nav, 'navigateToChange',
+ navigateToChangeStub = sandbox.stub(GerritNav, 'navigateToChange',
(change, patchNum, basePatchNum) => {
assert.equal(change, element._change);
assert.isUndefined(patchNum);
@@ -817,7 +818,7 @@
queryMap.set('secondaryTab', SecondaryTabs.COMMENT_THREADS);
// view is required
element.params = Object.assign(
- {view: Gerrit.Nav.View.CHANGE},
+ {view: GerritNav.View.CHANGE},
element.params, {queryMap}
);
flush(() => {
@@ -832,7 +833,7 @@
queryMap.set('secondaryTab', 'random');
// view is required
element.params = Object.assign({
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
}, element.params, {queryMap});
flush(() => {
assert.equal(element._activeTabs[1], SecondaryTabs.CHANGE_LOG);
@@ -1206,7 +1207,7 @@
const collapseStub = sandbox.stub(element.$.fileList, 'collapseAllDiffs');
const value = {
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
patchNum: '1',
};
element._paramsChanged(value);
@@ -1229,7 +1230,7 @@
() => Promise.resolve());
const collapseStub = sandbox.stub(element.$.fileList, 'collapseAllDiffs');
const value = {
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
};
element._paramsChanged(value);
assert.isTrue(reloadStub.calledOnce);
@@ -1288,7 +1289,7 @@
},
current_revision: 'rev3',
};
- sandbox.stub(Gerrit.Nav, 'getUrlForChange')
+ sandbox.stub(GerritNav, 'getUrlForChange')
.returns('/change/123');
assert.equal(
element._computeCopyTextForTitle(change),
@@ -1641,7 +1642,7 @@
// simulate reloading component, which is done when route
// changes to match a regex of change view type.
- element._paramsChanged({view: Gerrit.Nav.View.CHANGE});
+ element._paramsChanged({view: GerritNav.View.CHANGE});
});
test('scrollTop is reset when new change is loaded', () => {
@@ -2025,8 +2026,8 @@
sandbox.stub(controls, 'openDeleteDialog');
sandbox.stub(controls, 'openRenameDialog');
sandbox.stub(controls, 'openRestoreDialog');
- sandbox.stub(Gerrit.Nav, 'getEditUrlForDiff');
- sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl');
+ sandbox.stub(GerritNav, 'getEditUrlForDiff');
+ sandbox.stub(GerritNav, 'navigateToRelativeUrl');
// Delete
fileList.dispatchEvent(new CustomEvent('file-action-tap', {
@@ -2069,10 +2070,10 @@
}));
flushAsynchronousOperations();
- assert.isTrue(Gerrit.Nav.getEditUrlForDiff.called);
- assert.equal(Gerrit.Nav.getEditUrlForDiff.lastCall.args[1], 'foo');
- assert.equal(Gerrit.Nav.getEditUrlForDiff.lastCall.args[2], '1');
- assert.isTrue(Gerrit.Nav.navigateToRelativeUrl.called);
+ assert.isTrue(GerritNav.getEditUrlForDiff.called);
+ assert.equal(GerritNav.getEditUrlForDiff.lastCall.args[1], 'foo');
+ assert.equal(GerritNav.getEditUrlForDiff.lastCall.args[2], '1');
+ assert.isTrue(GerritNav.navigateToRelativeUrl.called);
});
test('_selectedRevision updates when patchNum is changed', () => {
@@ -2153,7 +2154,7 @@
});
test('edit exists in revisions', done => {
- sandbox.stub(Gerrit.Nav, 'navigateToChange', (...args) => {
+ sandbox.stub(GerritNav, 'navigateToChange', (...args) => {
assert.equal(args.length, 2);
assert.equal(args[1], element.EDIT_NAME); // patchNum
done();
@@ -2166,7 +2167,7 @@
});
test('no edit exists in revisions, non-latest patchset', done => {
- sandbox.stub(Gerrit.Nav, 'navigateToChange', (...args) => {
+ sandbox.stub(GerritNav, 'navigateToChange', (...args) => {
assert.equal(args.length, 4);
assert.equal(args[1], 1); // patchNum
assert.equal(args[3], true); // opt_isEdit
@@ -2181,7 +2182,7 @@
});
test('no edit exists in revisions, latest patchset', done => {
- sandbox.stub(Gerrit.Nav, 'navigateToChange', (...args) => {
+ sandbox.stub(GerritNav, 'navigateToChange', (...args) => {
assert.equal(args.length, 4);
// No patch should be specified when patchNum == latest.
assert.isNotOk(args[1]); // patchNum
@@ -2201,7 +2202,7 @@
sandbox.stub(element.$.metadata, '_computeLabelNames');
navigateToChangeStub.restore();
sandbox.stub(element, 'computeLatestPatchNum').returns(1);
- sandbox.stub(Gerrit.Nav, 'navigateToChange', (...args) => {
+ sandbox.stub(GerritNav, 'navigateToChange', (...args) => {
assert.equal(args.length, 2);
assert.equal(args[1], 1); // patchNum
done();
@@ -2277,7 +2278,7 @@
sandbox.stub(element, '_reload').returns(Promise.resolve());
const setStub = sandbox.stub(element.$.restAPI, 'setInProjectLookup');
element._paramsChanged({
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
changeNum: 101,
project: 'test-project',
});
@@ -2332,7 +2333,7 @@
const changeFullyLoadedStub =
sandbox.stub(element.$.reporting, 'changeFullyLoaded');
element._paramsChanged({
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
changeNum: 101,
project: 'test-project',
});
diff --git a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.js b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.js
index 7a60bac..7ca9d6b 100644
--- a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.js
+++ b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.js
@@ -25,7 +25,6 @@
*/
import '../../../scripts/bundled-polymer.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-formatted-text/gr-formatted-text.js';
import '../../../styles/shared-styles.js';
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
@@ -36,6 +35,7 @@
import {BaseUrlBehavior} from '../../../behaviors/base-url-behavior/base-url-behavior.js';
import {PathListBehavior} from '../../../behaviors/gr-path-list-behavior/gr-path-list-behavior.js';
import {URLEncodingBehavior} from '../../../behaviors/gr-url-encoding-behavior/gr-url-encoding-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/**
* @extends Polymer.Element
@@ -78,14 +78,14 @@
const fileComments = this._computeCommentsForFile(allComments, filePath);
// This can happen for files that don't exist anymore in the current ps.
if (fileComments.length === 0) return;
- return Gerrit.Nav.getUrlForDiffById(changeNum, this.projectName,
+ return GerritNav.getUrlForDiffById(changeNum, this.projectName,
filePath, fileComments[0].patch_set);
}
_computeDiffLineURL(filePath, changeNum, patchNum, comment) {
const basePatchNum = comment.hasOwnProperty('parent') ?
-comment.parent : null;
- return Gerrit.Nav.getUrlForDiffById(changeNum, this.projectName,
+ return GerritNav.getUrlForDiffById(changeNum, this.projectName,
filePath, patchNum, basePatchNum, comment.line,
this._isOnParent(comment));
}
diff --git a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list_test.html b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list_test.html
index c064679..e68f1dc 100644
--- a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list_test.html
+++ b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list_test.html
@@ -34,6 +34,8 @@
import '../../../test/common-test-setup.js';
import './gr-comment-list.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-comment-list tests', () => {
let element;
let sandbox;
@@ -41,7 +43,7 @@
setup(() => {
element = fixture('basic');
sandbox = sinon.sandbox.create();
- sandbox.stub(Gerrit.Nav, 'mapCommentlinks', x => x);
+ sandbox.stub(GerritNav, 'mapCommentlinks', x => x);
});
teardown(() => { sandbox.restore(); });
@@ -103,7 +105,7 @@
});
test('_computeDiffLineURL', () => {
- const getUrlStub = sandbox.stub(Gerrit.Nav, 'getUrlForDiffById');
+ const getUrlStub = sandbox.stub(GerritNav, 'getUrlForDiffById');
element.projectName = 'proj';
element.changeNum = 123;
diff --git a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.js b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.js
index 79a3692..4dba3af 100644
--- a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.js
+++ b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.js
@@ -22,6 +22,7 @@
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-commit-info_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/** @extends Polymer.Element */
class GrCommitInfo extends GestureEventListeners(
@@ -49,7 +50,7 @@
}
_getWeblink(change, commitInfo, config) {
- return Gerrit.Nav.getPatchSetWeblink(
+ return GerritNav.getPatchSetWeblink(
change.project,
commitInfo.commit,
{
diff --git a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info_test.html b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info_test.html
index 74d4cca..0da54d1 100644
--- a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info_test.html
+++ b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info_test.html
@@ -34,6 +34,8 @@
import '../../../test/common-test-setup.js';
import '../../core/gr-router/gr-router.js';
import './gr-commit-info.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-commit-info tests', () => {
let element;
let sandbox;
@@ -47,8 +49,8 @@
sandbox.restore();
});
- test('weblinks use Gerrit.Nav interface', () => {
- const weblinksStub = sandbox.stub(Gerrit.Nav, '_generateWeblinks')
+ test('weblinks use GerritNav interface', () => {
+ const weblinksStub = sandbox.stub(GerritNav, '_generateWeblinks')
.returns([{name: 'stubb', url: '#s'}]);
element.change = {};
element.commitInfo = {};
@@ -67,7 +69,7 @@
test('use web link when available', () => {
const router = document.createElement('gr-router');
- sandbox.stub(Gerrit.Nav, '_generateWeblinks',
+ sandbox.stub(GerritNav, '_generateWeblinks',
router._generateWeblinks.bind(router));
element.change = {labels: [], project: ''};
@@ -83,7 +85,7 @@
test('does not relativize web links that begin with scheme', () => {
const router = document.createElement('gr-router');
- sandbox.stub(Gerrit.Nav, '_generateWeblinks',
+ sandbox.stub(GerritNav, '_generateWeblinks',
router._generateWeblinks.bind(router));
element.change = {labels: [], project: ''};
@@ -101,7 +103,7 @@
test('ignore web links that are neither gitweb nor gitiles', () => {
const router = document.createElement('gr-router');
- sandbox.stub(Gerrit.Nav, '_generateWeblinks',
+ sandbox.stub(GerritNav, '_generateWeblinks',
router._generateWeblinks.bind(router));
element.change = {project: 'project-name'};
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js
index 50cc7a2..2802046 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js
@@ -27,6 +27,7 @@
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-confirm-cherrypick-dialog_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const SUGGESTIONS_LIMIT = 15;
const CHANGE_SUBJECT_LIMIT = 50;
@@ -249,7 +250,7 @@
if (!failedOrPending) {
/* This needs some more work, as the new topic may not always be
created, instead we may end up creating a new patchset */
- Gerrit.Nav.navigateToSearchQuery(`topic: "${topic}"`);
+ GerritNav.navigateToSearchQuery(`topic: "${topic}"`);
}
});
});
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.js
index 790fa9c..5d599b7 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.js
@@ -18,7 +18,6 @@
import '@polymer/iron-icon/iron-icon.js';
import '../../shared/gr-icons/gr-icons.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-dialog/gr-dialog.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator.js';
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js
index b1bacf3..73c6721 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js
@@ -17,7 +17,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../diff/gr-diff-mode-selector/gr-diff-mode-selector.js';
import '../../diff/gr-patch-range-select/gr-patch-range-select.js';
import '../../edit/gr-edit-controls/gr-edit-controls.js';
@@ -37,6 +36,7 @@
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
import {KeyboardShortcutBehavior} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
import {GrFileListConstants} from '../gr-file-list-constants.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
// Maximum length for patch set descriptions.
const PATCH_DESC_MAX_LENGTH = 500;
@@ -242,7 +242,7 @@
const {basePatchNum, patchNum} = e.detail;
if (this.patchNumEquals(basePatchNum, this.basePatchNum) &&
this.patchNumEquals(patchNum, this.patchNum)) { return; }
- Gerrit.Nav.navigateToChange(this.change, patchNum, basePatchNum);
+ GerritNav.navigateToChange(this.change, patchNum, basePatchNum);
}
_handlePrefsTap(e) {
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.html b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.html
index 59a6384..ceac41a 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.html
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.html
@@ -42,6 +42,7 @@
import './gr-file-list-header.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {GrFileListConstants} from '../gr-file-list-constants.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
suite('gr-file-list-header tests', () => {
let element;
@@ -238,7 +239,7 @@
});
test('navigateToChange called when range select changes', () => {
- const navigateToChangeStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ const navigateToChangeStub = sandbox.stub(GerritNav, 'navigateToChange');
element.change = {
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
revisions: {
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
index 41b2a322..991ea0b 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
@@ -17,7 +17,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../core/gr-reporting/gr-reporting.js';
import '../../diff/gr-diff-cursor/gr-diff-cursor.js';
import '../../diff/gr-diff-host/gr-diff-host.js';
@@ -44,6 +43,7 @@
import {KeyboardShortcutBehavior} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
import {GrFileListConstants} from '../gr-file-list-constants.js';
import {GrCountStringFormatter} from '../../shared/gr-count-string-formatter/gr-count-string-formatter.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
// Maximum length for patch set descriptions.
const PATCH_DESC_MAX_LENGTH = 500;
@@ -864,7 +864,7 @@
_openCursorFile() {
const diff = this.$.diffCursor.getTargetDiffElement();
- Gerrit.Nav.navigateToDiff(this.change, diff.path,
+ GerritNav.navigateToDiff(this.change, diff.path,
diff.patchRange.patchNum, this.patchRange.basePatchNum);
}
@@ -876,7 +876,7 @@
this.$.fileCursor.setCursorAtIndex(opt_index);
}
if (!this._files[this.$.fileCursor.index]) { return; }
- Gerrit.Nav.navigateToDiff(this.change,
+ GerritNav.navigateToDiff(this.change,
this._files[this.$.fileCursor.index].__path, this.patchRange.patchNum,
this.patchRange.basePatchNum);
}
@@ -909,10 +909,10 @@
return;
}
if (editMode && path !== this.MERGE_LIST_PATH) {
- return Gerrit.Nav.getEditUrlForDiff(change, path, patchRange.patchNum,
+ return GerritNav.getEditUrlForDiff(change, path, patchRange.patchNum,
patchRange.basePatchNum);
}
- return Gerrit.Nav.getUrlForDiff(change, path, patchRange.patchNum,
+ return GerritNav.getUrlForDiff(change, path, patchRange.patchNum,
patchRange.basePatchNum);
}
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html
index c3136c7..08b25ca 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html
@@ -50,6 +50,7 @@
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {KeyboardShortcutBinder} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
import {GrFileListConstants} from '../gr-file-list-constants.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
suite('gr-file-list tests', () => {
const kb = KeyboardShortcutBinder;
@@ -638,7 +639,7 @@
assert.equal(element.selectedIndex, 1);
MockInteractions.pressAndReleaseKeyOn(element, 74, null, 'j');
- const navStub = sandbox.stub(Gerrit.Nav, 'navigateToDiff');
+ const navStub = sandbox.stub(GerritNav, 'navigateToDiff');
assert.equal(element.$.fileCursor.index, 2);
assert.equal(element.selectedIndex, 2);
@@ -1278,7 +1279,7 @@
suite('diff url file list', () => {
test('diff url', () => {
- const diffStub = sandbox.stub(Gerrit.Nav, 'getUrlForDiff')
+ const diffStub = sandbox.stub(GerritNav, 'getUrlForDiff')
.returns('/c/gerrit/+/1/1/index.php');
const change = {
_number: 1,
@@ -1295,7 +1296,7 @@
});
test('diff url commit msg', () => {
- const diffStub = sandbox.stub(Gerrit.Nav, 'getUrlForDiff')
+ const diffStub = sandbox.stub(GerritNav, 'getUrlForDiff')
.returns('/c/gerrit/+/1/1//COMMIT_MSG');
const change = {
_number: 1,
@@ -1312,7 +1313,7 @@
});
test('edit url', () => {
- const editStub = sandbox.stub(Gerrit.Nav, 'getEditUrlForDiff')
+ const editStub = sandbox.stub(GerritNav, 'getEditUrlForDiff')
.returns('/c/gerrit/+/1/edit/index.php,edit');
const change = {
_number: 1,
@@ -1329,7 +1330,7 @@
});
test('edit url commit msg', () => {
- const editStub = sandbox.stub(Gerrit.Nav, 'getEditUrlForDiff')
+ const editStub = sandbox.stub(GerritNav, 'getEditUrlForDiff')
.returns('/c/gerrit/+/1/edit//COMMIT_MSG,edit');
const change = {
_number: 1,
@@ -1762,7 +1763,7 @@
test('_openSelectedFile behavior', () => {
const _filesByPath = element._filesByPath;
element.set('_filesByPath', {});
- const navStub = sandbox.stub(Gerrit.Nav, 'navigateToDiff');
+ const navStub = sandbox.stub(GerritNav, 'navigateToDiff');
// Noop when there are no files.
element._openSelectedFile();
assert.isFalse(navStub.called);
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js
index dca9fb6..631542a 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js
@@ -16,7 +16,6 @@
*/
import '../../../scripts/bundled-polymer.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import '../../../styles/shared-styles.js';
import {flush} from '@polymer/polymer/lib/legacy/polymer.dom.js';
@@ -27,6 +26,7 @@
import {htmlTemplate} from './gr-related-changes-list_html.js';
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
import {RESTClientBehavior} from '../../../behaviors/rest-client-behavior/rest-client-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/**
* @extends Polymer.Element
@@ -221,7 +221,7 @@
* @return {string}
*/
_computeChangeURL(changeNum, project, opt_patchNum) {
- return Gerrit.Nav.getUrlForChangeById(changeNum, project, opt_patchNum);
+ return GerritNav.getUrlForChangeById(changeNum, project, opt_patchNum);
}
_computeChangeContainerClass(currentChange, relatedChange) {
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.html b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.html
index 94e0fe5..2425d8b 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.html
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.html
@@ -33,6 +33,8 @@
<script type="module">
import '../../../test/common-test-setup.js';
import './gr-related-changes-list.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-related-changes-list tests', () => {
let element;
let sandbox;
@@ -461,8 +463,8 @@
});
});
- test('_computeChangeURL uses Gerrit.Nav', () => {
- const getUrlStub = sandbox.stub(Gerrit.Nav, 'getUrlForChangeById');
+ test('_computeChangeURL uses GerritNav', () => {
+ const getUrlStub = sandbox.stub(GerritNav, 'getUrlForChangeById');
element._computeChangeURL(123, 'abc/def', 12);
assert.isTrue(getUrlStub.called);
});
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js
index c3b2a9e..77c09f7 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js
@@ -42,6 +42,7 @@
import {KeyboardShortcutBehavior} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
import {RESTClientBehavior} from '../../../behaviors/rest-client-behavior/rest-client-behavior.js';
import {GrReviewerSuggestionsProvider} from '../../../scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const STORAGE_DEBOUNCE_INTERVAL_MS = 400;
@@ -857,7 +858,7 @@
_reload() {
// Load the current change without any patch range.
- Gerrit.Nav.navigateToChange(this.change);
+ GerritNav.navigateToChange(this.change);
this.cancel();
}
diff --git a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.js b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.js
index c8724c3..2b87548 100644
--- a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.js
+++ b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.js
@@ -14,735 +14,729 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function(window) {
- 'use strict';
- // Navigation parameters object format:
- //
- // Each object has a `view` property with a value from Gerrit.Nav.View. The
- // remaining properties depend on the value used for view.
- //
- // - Gerrit.Nav.View.CHANGE:
- // - `changeNum`, required, String: the numeric ID of the change.
- // - `project`, optional, String: the project name.
- // - `patchNum`, optional, Number: the patch for the right-hand-side of
- // the diff.
- // - `basePatchNum`, optional, Number: the patch for the left-hand-side
- // of the diff. If `basePatchNum` is provided, then `patchNum` must
- // also be provided.
- // - `edit`, optional, Boolean: whether or not to load the file list with
- // edit controls.
- // - `messageHash`, optional, String: the hash of the change message to
- // scroll to.
- //
- // - Gerrit.Nav.View.SEARCH:
- // - `query`, optional, String: the literal search query. If provided,
- // the string will be used as the query, and all other params will be
- // ignored.
- // - `owner`, optional, String: the owner name.
- // - `project`, optional, String: the project name.
- // - `branch`, optional, String: the branch name.
- // - `topic`, optional, String: the topic name.
- // - `hashtag`, optional, String: the hashtag name.
- // - `statuses`, optional, Array<String>: the list of change statuses to
- // search for. If more than one is provided, the search will OR them
- // together.
- // - `offset`, optional, Number: the offset for the query.
- //
- // - Gerrit.Nav.View.DIFF:
- // - `changeNum`, required, String: the numeric ID of the change.
- // - `path`, required, String: the filepath of the diff.
- // - `patchNum`, required, Number: the patch for the right-hand-side of
- // the diff.
- // - `basePatchNum`, optional, Number: the patch for the left-hand-side
- // of the diff. If `basePatchNum` is provided, then `patchNum` must
- // also be provided.
- // - `lineNum`, optional, Number: the line number to be selected on load.
- // - `leftSide`, optional, Boolean: if a `lineNum` is provided, a value
- // of true selects the line from base of the patch range. False by
- // default.
- //
- // - Gerrit.Nav.View.GROUP:
- // - `groupId`, required, String: the ID of the group.
- // - `detail`, optional, String: the name of the group detail view.
- // Takes any value from Gerrit.Nav.GroupDetailView.
- //
- // - Gerrit.Nav.View.REPO:
- // - `repoName`, required, String: the name of the repo
- // - `detail`, optional, String: the name of the repo detail view.
- // Takes any value from Gerrit.Nav.RepoDetailView.
- //
- // - Gerrit.Nav.View.DASHBOARD
- // - `repo`, optional, String.
- // - `sections`, optional, Array of objects with `title` and `query`
- // strings.
- // - `user`, optional, String.
- //
- // - Gerrit.Nav.View.ROOT:
- // - no possible parameters.
+// Navigation parameters object format:
+//
+// Each object has a `view` property with a value from GerritNav.View. The
+// remaining properties depend on the value used for view.
+//
+// - GerritNav.View.CHANGE:
+// - `changeNum`, required, String: the numeric ID of the change.
+// - `project`, optional, String: the project name.
+// - `patchNum`, optional, Number: the patch for the right-hand-side of
+// the diff.
+// - `basePatchNum`, optional, Number: the patch for the left-hand-side
+// of the diff. If `basePatchNum` is provided, then `patchNum` must
+// also be provided.
+// - `edit`, optional, Boolean: whether or not to load the file list with
+// edit controls.
+// - `messageHash`, optional, String: the hash of the change message to
+// scroll to.
+//
+// - GerritNav.View.SEARCH:
+// - `query`, optional, String: the literal search query. If provided,
+// the string will be used as the query, and all other params will be
+// ignored.
+// - `owner`, optional, String: the owner name.
+// - `project`, optional, String: the project name.
+// - `branch`, optional, String: the branch name.
+// - `topic`, optional, String: the topic name.
+// - `hashtag`, optional, String: the hashtag name.
+// - `statuses`, optional, Array<String>: the list of change statuses to
+// search for. If more than one is provided, the search will OR them
+// together.
+// - `offset`, optional, Number: the offset for the query.
+//
+// - GerritNav.View.DIFF:
+// - `changeNum`, required, String: the numeric ID of the change.
+// - `path`, required, String: the filepath of the diff.
+// - `patchNum`, required, Number: the patch for the right-hand-side of
+// the diff.
+// - `basePatchNum`, optional, Number: the patch for the left-hand-side
+// of the diff. If `basePatchNum` is provided, then `patchNum` must
+// also be provided.
+// - `lineNum`, optional, Number: the line number to be selected on load.
+// - `leftSide`, optional, Boolean: if a `lineNum` is provided, a value
+// of true selects the line from base of the patch range. False by
+// default.
+//
+// - GerritNav.View.GROUP:
+// - `groupId`, required, String: the ID of the group.
+// - `detail`, optional, String: the name of the group detail view.
+// Takes any value from GerritNav.GroupDetailView.
+//
+// - GerritNav.View.REPO:
+// - `repoName`, required, String: the name of the repo
+// - `detail`, optional, String: the name of the repo detail view.
+// Takes any value from GerritNav.RepoDetailView.
+//
+// - GerritNav.View.DASHBOARD
+// - `repo`, optional, String.
+// - `sections`, optional, Array of objects with `title` and `query`
+// strings.
+// - `user`, optional, String.
+//
+// - GerritNav.View.ROOT:
+// - no possible parameters.
- window.Gerrit = window.Gerrit || {};
+const uninitialized = () => {
+ console.warn('Use of uninitialized routing');
+};
- // Prevent redefinition.
- if (window.Gerrit.hasOwnProperty('Nav')) { return; }
+const EDIT_PATCHNUM = 'edit';
+const PARENT_PATCHNUM = 'PARENT';
- const uninitialized = () => {
- console.warn('Use of uninitialized routing');
- };
+const USER_PLACEHOLDER_PATTERN = /\$\{user\}/g;
- const EDIT_PATCHNUM = 'edit';
- const PARENT_PATCHNUM = 'PARENT';
+// NOTE: These queries are tested in Java. Any changes made to definitions
+// here require corresponding changes to:
+// javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
+const DEFAULT_SECTIONS = [
+ {
+ // Changes with unpublished draft comments. This section is omitted when
+ // viewing other users, so we don't need to filter anything out.
+ name: 'Has draft comments',
+ query: 'has:draft',
+ selfOnly: true,
+ hideIfEmpty: true,
+ suffixForDashboard: 'limit:10',
+ },
+ {
+ // Changes that are assigned to the viewed user.
+ name: 'Assigned reviews',
+ query: 'assignee:${user} (-is:wip OR owner:self OR assignee:self) ' +
+ 'is:open -is:ignored',
+ hideIfEmpty: true,
+ suffixForDashboard: 'limit:25',
+ },
+ {
+ // WIP open changes owned by viewing user. This section is omitted when
+ // viewing other users, so we don't need to filter anything out.
+ name: 'Work in progress',
+ query: 'is:open owner:${user} is:wip',
+ selfOnly: true,
+ hideIfEmpty: true,
+ suffixForDashboard: 'limit:25',
+ },
+ {
+ // Non-WIP open changes owned by viewed user. Filter out changes ignored
+ // by the viewing user.
+ name: 'Outgoing reviews',
+ query: 'is:open owner:${user} -is:wip -is:ignored',
+ isOutgoing: true,
+ suffixForDashboard: 'limit:25',
+ },
+ {
+ // Non-WIP open changes not owned by the viewed user, that the viewed user
+ // is associated with (as either a reviewer or the assignee). Changes
+ // ignored by the viewing user are filtered out.
+ name: 'Incoming reviews',
+ query: 'is:open -owner:${user} -is:wip -is:ignored ' +
+ '(reviewer:${user} OR assignee:${user})',
+ suffixForDashboard: 'limit:25',
+ },
+ {
+ // Open changes the viewed user is CCed on. Changes ignored by the viewing
+ // user are filtered out.
+ name: 'CCed on',
+ query: 'is:open -is:ignored cc:${user}',
+ suffixForDashboard: 'limit:10',
+ },
+ {
+ name: 'Recently closed',
+ // Closed changes where viewed user is owner, reviewer, or assignee.
+ // Changes ignored by the viewing user are filtered out, and so are WIP
+ // changes not owned by the viewing user (the one instance of
+ // 'owner:self' is intentional and implements this logic).
+ query: 'is:closed -is:ignored (-is:wip OR owner:self) ' +
+ '(owner:${user} OR reviewer:${user} OR assignee:${user} ' +
+ 'OR cc:${user})',
+ suffixForDashboard: '-age:4w limit:10',
+ },
+];
- const USER_PLACEHOLDER_PATTERN = /\$\{user\}/g;
+// TODO(dmfilippov) Convert to class, extract consts, give better name and
+// expose as a service from appContext
+export const GerritNav = {
- // NOTE: These queries are tested in Java. Any changes made to definitions
- // here require corresponding changes to:
- // javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
- const DEFAULT_SECTIONS = [
- {
- // Changes with unpublished draft comments. This section is omitted when
- // viewing other users, so we don't need to filter anything out.
- name: 'Has draft comments',
- query: 'has:draft',
- selfOnly: true,
- hideIfEmpty: true,
- suffixForDashboard: 'limit:10',
- },
- {
- // Changes that are assigned to the viewed user.
- name: 'Assigned reviews',
- query: 'assignee:${user} (-is:wip OR owner:self OR assignee:self) ' +
- 'is:open -is:ignored',
- hideIfEmpty: true,
- suffixForDashboard: 'limit:25',
- },
- {
- // WIP open changes owned by viewing user. This section is omitted when
- // viewing other users, so we don't need to filter anything out.
- name: 'Work in progress',
- query: 'is:open owner:${user} is:wip',
- selfOnly: true,
- hideIfEmpty: true,
- suffixForDashboard: 'limit:25',
- },
- {
- // Non-WIP open changes owned by viewed user. Filter out changes ignored
- // by the viewing user.
- name: 'Outgoing reviews',
- query: 'is:open owner:${user} -is:wip -is:ignored',
- isOutgoing: true,
- suffixForDashboard: 'limit:25',
- },
- {
- // Non-WIP open changes not owned by the viewed user, that the viewed user
- // is associated with (as either a reviewer or the assignee). Changes
- // ignored by the viewing user are filtered out.
- name: 'Incoming reviews',
- query: 'is:open -owner:${user} -is:wip -is:ignored ' +
- '(reviewer:${user} OR assignee:${user})',
- suffixForDashboard: 'limit:25',
- },
- {
- // Open changes the viewed user is CCed on. Changes ignored by the viewing
- // user are filtered out.
- name: 'CCed on',
- query: 'is:open -is:ignored cc:${user}',
- suffixForDashboard: 'limit:10',
- },
- {
- name: 'Recently closed',
- // Closed changes where viewed user is owner, reviewer, or assignee.
- // Changes ignored by the viewing user are filtered out, and so are WIP
- // changes not owned by the viewing user (the one instance of
- // 'owner:self' is intentional and implements this logic).
- query: 'is:closed -is:ignored (-is:wip OR owner:self) ' +
- '(owner:${user} OR reviewer:${user} OR assignee:${user} ' +
- 'OR cc:${user})',
- suffixForDashboard: '-age:4w limit:10',
- },
- ];
+ View: {
+ ADMIN: 'admin',
+ AGREEMENTS: 'agreements',
+ CHANGE: 'change',
+ DASHBOARD: 'dashboard',
+ DIFF: 'diff',
+ DOCUMENTATION_SEARCH: 'documentation-search',
+ EDIT: 'edit',
+ GROUP: 'group',
+ PLUGIN_SCREEN: 'plugin-screen',
+ REPO: 'repo',
+ ROOT: 'root',
+ SEARCH: 'search',
+ SETTINGS: 'settings',
+ },
- window.Gerrit.Nav = {
+ GroupDetailView: {
+ MEMBERS: 'members',
+ LOG: 'log',
+ },
- View: {
- ADMIN: 'admin',
- AGREEMENTS: 'agreements',
- CHANGE: 'change',
- DASHBOARD: 'dashboard',
- DIFF: 'diff',
- DOCUMENTATION_SEARCH: 'documentation-search',
- EDIT: 'edit',
- GROUP: 'group',
- PLUGIN_SCREEN: 'plugin-screen',
- REPO: 'repo',
- ROOT: 'root',
- SEARCH: 'search',
- SETTINGS: 'settings',
- },
+ RepoDetailView: {
+ ACCESS: 'access',
+ BRANCHES: 'branches',
+ COMMANDS: 'commands',
+ DASHBOARDS: 'dashboards',
+ TAGS: 'tags',
+ },
- GroupDetailView: {
- MEMBERS: 'members',
- LOG: 'log',
- },
+ WeblinkType: {
+ CHANGE: 'change',
+ FILE: 'file',
+ PATCHSET: 'patchset',
+ },
- RepoDetailView: {
- ACCESS: 'access',
- BRANCHES: 'branches',
- COMMANDS: 'commands',
- DASHBOARDS: 'dashboards',
- TAGS: 'tags',
- },
+ /** @type {Function} */
+ _navigate: uninitialized,
- WeblinkType: {
- CHANGE: 'change',
- FILE: 'file',
- PATCHSET: 'patchset',
- },
+ /** @type {Function} */
+ _generateUrl: uninitialized,
- /** @type {Function} */
- _navigate: uninitialized,
+ /** @type {Function} */
+ _generateWeblinks: uninitialized,
- /** @type {Function} */
- _generateUrl: uninitialized,
+ /** @type {Function} */
+ mapCommentlinks: uninitialized,
- /** @type {Function} */
- _generateWeblinks: uninitialized,
+ /**
+ * @param {number=} patchNum
+ * @param {number|string=} basePatchNum
+ */
+ _checkPatchRange(patchNum, basePatchNum) {
+ if (basePatchNum && !patchNum) {
+ throw new Error('Cannot use base patch number without patch number.');
+ }
+ },
- /** @type {Function} */
- mapCommentlinks: uninitialized,
+ /**
+ * Setup router implementation.
+ *
+ * @param {function(!string)} navigate the router-abstracted equivalent of
+ * `window.location.href = ...`. Takes a string.
+ * @param {function(!Object): string} generateUrl generates a URL given
+ * navigation parameters, detailed in the file header.
+ * @param {function(!Object): string} generateWeblinks weblinks generator
+ * function takes single payload parameter with type property that
+ * determines which
+ * part of the UI is the consumer of the weblinks. type property can
+ * be one of file, change, or patchset.
+ * - For file type, payload will also contain string properties: repo,
+ * commit, file.
+ * - For patchset type, payload will also contain string properties:
+ * repo, commit.
+ * - For change type, payload will also contain string properties:
+ * repo, commit. If server provides weblinks, those will be passed
+ * as options.weblinks property on the main payload object.
+ * @param {function(!Object): Object} mapCommentlinks provides an escape
+ * hatch to modify the commentlinks object, e.g. if it contains any
+ * relative URLs.
+ */
+ setup(navigate, generateUrl, generateWeblinks, mapCommentlinks) {
+ this._navigate = navigate;
+ this._generateUrl = generateUrl;
+ this._generateWeblinks = generateWeblinks;
+ this.mapCommentlinks = mapCommentlinks;
+ },
- /**
- * @param {number=} patchNum
- * @param {number|string=} basePatchNum
- */
- _checkPatchRange(patchNum, basePatchNum) {
- if (basePatchNum && !patchNum) {
- throw new Error('Cannot use base patch number without patch number.');
- }
- },
+ destroy() {
+ this._navigate = uninitialized;
+ this._generateUrl = uninitialized;
+ this._generateWeblinks = uninitialized;
+ this.mapCommentlinks = uninitialized;
+ },
- /**
- * Setup router implementation.
- *
- * @param {function(!string)} navigate the router-abstracted equivalent of
- * `window.location.href = ...`. Takes a string.
- * @param {function(!Object): string} generateUrl generates a URL given
- * navigation parameters, detailed in the file header.
- * @param {function(!Object): string} generateWeblinks weblinks generator
- * function takes single payload parameter with type property that
- * determines which
- * part of the UI is the consumer of the weblinks. type property can
- * be one of file, change, or patchset.
- * - For file type, payload will also contain string properties: repo,
- * commit, file.
- * - For patchset type, payload will also contain string properties:
- * repo, commit.
- * - For change type, payload will also contain string properties:
- * repo, commit. If server provides weblinks, those will be passed
- * as options.weblinks property on the main payload object.
- * @param {function(!Object): Object} mapCommentlinks provides an escape
- * hatch to modify the commentlinks object, e.g. if it contains any
- * relative URLs.
- */
- setup(navigate, generateUrl, generateWeblinks, mapCommentlinks) {
- this._navigate = navigate;
- this._generateUrl = generateUrl;
- this._generateWeblinks = generateWeblinks;
- this.mapCommentlinks = mapCommentlinks;
- },
+ /**
+ * Generate a URL for the given route parameters.
+ *
+ * @param {Object} params
+ * @return {string}
+ */
+ _getUrlFor(params) {
+ return this._generateUrl(params);
+ },
- destroy() {
- this._navigate = uninitialized;
- this._generateUrl = uninitialized;
- this._generateWeblinks = uninitialized;
- this.mapCommentlinks = uninitialized;
- },
+ getUrlForSearchQuery(query, opt_offset) {
+ return this._getUrlFor({
+ view: GerritNav.View.SEARCH,
+ query,
+ offset: opt_offset,
+ });
+ },
- /**
- * Generate a URL for the given route parameters.
- *
- * @param {Object} params
- * @return {string}
- */
- _getUrlFor(params) {
- return this._generateUrl(params);
- },
+ /**
+ * @param {!string} project The name of the project.
+ * @param {boolean=} opt_openOnly When true, only search open changes in
+ * the project.
+ * @param {string=} opt_host The host in which to search.
+ * @return {string}
+ */
+ getUrlForProjectChanges(project, opt_openOnly, opt_host) {
+ return this._getUrlFor({
+ view: GerritNav.View.SEARCH,
+ project,
+ statuses: opt_openOnly ? ['open'] : [],
+ host: opt_host,
+ });
+ },
- getUrlForSearchQuery(query, opt_offset) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.SEARCH,
- query,
- offset: opt_offset,
- });
- },
+ /**
+ * @param {string} branch The name of the branch.
+ * @param {string} project The name of the project.
+ * @param {string=} opt_status The status to search.
+ * @param {string=} opt_host The host in which to search.
+ * @return {string}
+ */
+ getUrlForBranch(branch, project, opt_status, opt_host) {
+ return this._getUrlFor({
+ view: GerritNav.View.SEARCH,
+ branch,
+ project,
+ statuses: opt_status ? [opt_status] : undefined,
+ host: opt_host,
+ });
+ },
- /**
- * @param {!string} project The name of the project.
- * @param {boolean=} opt_openOnly When true, only search open changes in
- * the project.
- * @param {string=} opt_host The host in which to search.
- * @return {string}
- */
- getUrlForProjectChanges(project, opt_openOnly, opt_host) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.SEARCH,
- project,
- statuses: opt_openOnly ? ['open'] : [],
- host: opt_host,
- });
- },
+ /**
+ * @param {string} topic The name of the topic.
+ * @param {string=} opt_host The host in which to search.
+ * @return {string}
+ */
+ getUrlForTopic(topic, opt_host) {
+ return this._getUrlFor({
+ view: GerritNav.View.SEARCH,
+ topic,
+ statuses: ['open', 'merged'],
+ host: opt_host,
+ });
+ },
- /**
- * @param {string} branch The name of the branch.
- * @param {string} project The name of the project.
- * @param {string=} opt_status The status to search.
- * @param {string=} opt_host The host in which to search.
- * @return {string}
- */
- getUrlForBranch(branch, project, opt_status, opt_host) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.SEARCH,
- branch,
- project,
- statuses: opt_status ? [opt_status] : undefined,
- host: opt_host,
- });
- },
+ /**
+ * @param {string} hashtag The name of the hashtag.
+ * @return {string}
+ */
+ getUrlForHashtag(hashtag) {
+ return this._getUrlFor({
+ view: GerritNav.View.SEARCH,
+ hashtag,
+ statuses: ['open', 'merged'],
+ });
+ },
- /**
- * @param {string} topic The name of the topic.
- * @param {string=} opt_host The host in which to search.
- * @return {string}
- */
- getUrlForTopic(topic, opt_host) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.SEARCH,
- topic,
- statuses: ['open', 'merged'],
- host: opt_host,
- });
- },
+ /**
+ * Navigate to a search for changes with the given status.
+ *
+ * @param {string} status
+ */
+ navigateToStatusSearch(status) {
+ this._navigate(this._getUrlFor({
+ view: GerritNav.View.SEARCH,
+ statuses: [status],
+ }));
+ },
- /**
- * @param {string} hashtag The name of the hashtag.
- * @return {string}
- */
- getUrlForHashtag(hashtag) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.SEARCH,
- hashtag,
- statuses: ['open', 'merged'],
- });
- },
+ /**
+ * Navigate to a search query
+ *
+ * @param {string} query
+ * @param {number=} opt_offset
+ */
+ navigateToSearchQuery(query, opt_offset) {
+ return this._navigate(this.getUrlForSearchQuery(query, opt_offset));
+ },
- /**
- * Navigate to a search for changes with the given status.
- *
- * @param {string} status
- */
- navigateToStatusSearch(status) {
- this._navigate(this._getUrlFor({
- view: Gerrit.Nav.View.SEARCH,
- statuses: [status],
- }));
- },
+ /**
+ * Navigate to the user's dashboard
+ */
+ navigateToUserDashboard() {
+ return this._navigate(this.getUrlForUserDashboard('self'));
+ },
- /**
- * Navigate to a search query
- *
- * @param {string} query
- * @param {number=} opt_offset
- */
- navigateToSearchQuery(query, opt_offset) {
- return this._navigate(this.getUrlForSearchQuery(query, opt_offset));
- },
+ /**
+ * @param {!Object} change The change object.
+ * @param {number=} opt_patchNum
+ * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
+ * used for none.
+ * @param {boolean=} opt_isEdit
+ * @param {string=} opt_messageHash
+ * @return {string}
+ */
+ getUrlForChange(change, opt_patchNum, opt_basePatchNum, opt_isEdit,
+ opt_messageHash) {
+ if (opt_basePatchNum === PARENT_PATCHNUM) {
+ opt_basePatchNum = undefined;
+ }
- /**
- * Navigate to the user's dashboard
- */
- navigateToUserDashboard() {
- return this._navigate(this.getUrlForUserDashboard('self'));
- },
+ this._checkPatchRange(opt_patchNum, opt_basePatchNum);
+ return this._getUrlFor({
+ view: GerritNav.View.CHANGE,
+ changeNum: change._number,
+ project: change.project,
+ patchNum: opt_patchNum,
+ basePatchNum: opt_basePatchNum,
+ edit: opt_isEdit,
+ host: change.internalHost || undefined,
+ messageHash: opt_messageHash,
+ });
+ },
- /**
- * @param {!Object} change The change object.
- * @param {number=} opt_patchNum
- * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
- * used for none.
- * @param {boolean=} opt_isEdit
- * @param {string=} opt_messageHash
- * @return {string}
- */
- getUrlForChange(change, opt_patchNum, opt_basePatchNum, opt_isEdit,
- opt_messageHash) {
- if (opt_basePatchNum === PARENT_PATCHNUM) {
- opt_basePatchNum = undefined;
- }
+ /**
+ * @param {number} changeNum
+ * @param {string} project The name of the project.
+ * @param {number=} opt_patchNum
+ * @return {string}
+ */
+ getUrlForChangeById(changeNum, project, opt_patchNum) {
+ return this._getUrlFor({
+ view: GerritNav.View.CHANGE,
+ changeNum,
+ project,
+ patchNum: opt_patchNum,
+ });
+ },
- this._checkPatchRange(opt_patchNum, opt_basePatchNum);
- return this._getUrlFor({
- view: Gerrit.Nav.View.CHANGE,
- changeNum: change._number,
- project: change.project,
- patchNum: opt_patchNum,
- basePatchNum: opt_basePatchNum,
- edit: opt_isEdit,
- host: change.internalHost || undefined,
- messageHash: opt_messageHash,
- });
- },
+ /**
+ * @param {!Object} change The change object.
+ * @param {number=} opt_patchNum
+ * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
+ * used for none.
+ * @param {boolean=} opt_isEdit
+ */
+ navigateToChange(change, opt_patchNum, opt_basePatchNum, opt_isEdit) {
+ this._navigate(this.getUrlForChange(change, opt_patchNum,
+ opt_basePatchNum, opt_isEdit));
+ },
- /**
- * @param {number} changeNum
- * @param {string} project The name of the project.
- * @param {number=} opt_patchNum
- * @return {string}
- */
- getUrlForChangeById(changeNum, project, opt_patchNum) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.CHANGE,
- changeNum,
- project,
- patchNum: opt_patchNum,
- });
- },
+ /**
+ * @param {{ _number: number, project: string }} change The change object.
+ * @param {string} path The file path.
+ * @param {number=} opt_patchNum
+ * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
+ * used for none.
+ * @param {number|string=} opt_lineNum
+ * @return {string}
+ */
+ getUrlForDiff(change, path, opt_patchNum, opt_basePatchNum, opt_lineNum) {
+ return this.getUrlForDiffById(change._number, change.project, path,
+ opt_patchNum, opt_basePatchNum, opt_lineNum);
+ },
- /**
- * @param {!Object} change The change object.
- * @param {number=} opt_patchNum
- * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
- * used for none.
- * @param {boolean=} opt_isEdit
- */
- navigateToChange(change, opt_patchNum, opt_basePatchNum, opt_isEdit) {
- this._navigate(this.getUrlForChange(change, opt_patchNum,
- opt_basePatchNum, opt_isEdit));
- },
+ /**
+ * @param {number} changeNum
+ * @param {string} project The name of the project.
+ * @param {string} path The file path.
+ * @param {number=} opt_patchNum
+ * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
+ * used for none.
+ * @param {number=} opt_lineNum
+ * @param {boolean=} opt_leftSide
+ * @return {string}
+ */
+ getUrlForDiffById(changeNum, project, path, opt_patchNum,
+ opt_basePatchNum, opt_lineNum, opt_leftSide) {
+ if (opt_basePatchNum === PARENT_PATCHNUM) {
+ opt_basePatchNum = undefined;
+ }
- /**
- * @param {{ _number: number, project: string }} change The change object.
- * @param {string} path The file path.
- * @param {number=} opt_patchNum
- * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
- * used for none.
- * @param {number|string=} opt_lineNum
- * @return {string}
- */
- getUrlForDiff(change, path, opt_patchNum, opt_basePatchNum, opt_lineNum) {
- return this.getUrlForDiffById(change._number, change.project, path,
- opt_patchNum, opt_basePatchNum, opt_lineNum);
- },
+ this._checkPatchRange(opt_patchNum, opt_basePatchNum);
+ return this._getUrlFor({
+ view: GerritNav.View.DIFF,
+ changeNum,
+ project,
+ path,
+ patchNum: opt_patchNum,
+ basePatchNum: opt_basePatchNum,
+ lineNum: opt_lineNum,
+ leftSide: opt_leftSide,
+ });
+ },
- /**
- * @param {number} changeNum
- * @param {string} project The name of the project.
- * @param {string} path The file path.
- * @param {number=} opt_patchNum
- * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
- * used for none.
- * @param {number=} opt_lineNum
- * @param {boolean=} opt_leftSide
- * @return {string}
- */
- getUrlForDiffById(changeNum, project, path, opt_patchNum,
- opt_basePatchNum, opt_lineNum, opt_leftSide) {
- if (opt_basePatchNum === PARENT_PATCHNUM) {
- opt_basePatchNum = undefined;
- }
+ /**
+ * @param {{ _number: number, project: string }} change The change object.
+ * @param {string} path The file path.
+ * @param {number=} opt_patchNum
+ * @return {string}
+ */
+ getEditUrlForDiff(change, path, opt_patchNum) {
+ return this.getEditUrlForDiffById(change._number, change.project, path,
+ opt_patchNum);
+ },
- this._checkPatchRange(opt_patchNum, opt_basePatchNum);
- return this._getUrlFor({
- view: Gerrit.Nav.View.DIFF,
- changeNum,
- project,
- path,
- patchNum: opt_patchNum,
- basePatchNum: opt_basePatchNum,
- lineNum: opt_lineNum,
- leftSide: opt_leftSide,
- });
- },
+ /**
+ * @param {number} changeNum
+ * @param {string} project The name of the project.
+ * @param {string} path The file path.
+ * @param {number|string=} opt_patchNum The patchNum the file content
+ * should be based on, or ${EDIT_PATCHNUM} if left undefined.
+ * @return {string}
+ */
+ getEditUrlForDiffById(changeNum, project, path, opt_patchNum) {
+ return this._getUrlFor({
+ view: GerritNav.View.EDIT,
+ changeNum,
+ project,
+ path,
+ patchNum: opt_patchNum || EDIT_PATCHNUM,
+ });
+ },
- /**
- * @param {{ _number: number, project: string }} change The change object.
- * @param {string} path The file path.
- * @param {number=} opt_patchNum
- * @return {string}
- */
- getEditUrlForDiff(change, path, opt_patchNum) {
- return this.getEditUrlForDiffById(change._number, change.project, path,
- opt_patchNum);
- },
+ /**
+ * @param {!Object} change The change object.
+ * @param {string} path The file path.
+ * @param {number=} opt_patchNum
+ * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
+ * used for none.
+ */
+ navigateToDiff(change, path, opt_patchNum, opt_basePatchNum) {
+ this._navigate(this.getUrlForDiff(change, path, opt_patchNum,
+ opt_basePatchNum));
+ },
- /**
- * @param {number} changeNum
- * @param {string} project The name of the project.
- * @param {string} path The file path.
- * @param {number|string=} opt_patchNum The patchNum the file content
- * should be based on, or ${EDIT_PATCHNUM} if left undefined.
- * @return {string}
- */
- getEditUrlForDiffById(changeNum, project, path, opt_patchNum) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.EDIT,
- changeNum,
- project,
- path,
- patchNum: opt_patchNum || EDIT_PATCHNUM,
- });
- },
+ /**
+ * @param {string} owner The name of the owner.
+ * @return {string}
+ */
+ getUrlForOwner(owner) {
+ return this._getUrlFor({
+ view: GerritNav.View.SEARCH,
+ owner,
+ });
+ },
- /**
- * @param {!Object} change The change object.
- * @param {string} path The file path.
- * @param {number=} opt_patchNum
- * @param {number|string=} opt_basePatchNum The string 'PARENT' can be
- * used for none.
- */
- navigateToDiff(change, path, opt_patchNum, opt_basePatchNum) {
- this._navigate(this.getUrlForDiff(change, path, opt_patchNum,
- opt_basePatchNum));
- },
+ /**
+ * @param {string} user The name of the user.
+ * @return {string}
+ */
+ getUrlForUserDashboard(user) {
+ return this._getUrlFor({
+ view: GerritNav.View.DASHBOARD,
+ user,
+ });
+ },
- /**
- * @param {string} owner The name of the owner.
- * @return {string}
- */
- getUrlForOwner(owner) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.SEARCH,
- owner,
- });
- },
+ /**
+ * @return {string}
+ */
+ getUrlForRoot() {
+ return this._getUrlFor({
+ view: GerritNav.View.ROOT,
+ });
+ },
- /**
- * @param {string} user The name of the user.
- * @return {string}
- */
- getUrlForUserDashboard(user) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.DASHBOARD,
- user,
- });
- },
+ /**
+ * @param {string} repo The name of the repo.
+ * @param {string} dashboard The ID of the dashboard, in the form of
+ * '<ref>:<path>'.
+ * @return {string}
+ */
+ getUrlForRepoDashboard(repo, dashboard) {
+ return this._getUrlFor({
+ view: GerritNav.View.DASHBOARD,
+ repo,
+ dashboard,
+ });
+ },
- /**
- * @return {string}
- */
- getUrlForRoot() {
- return this._getUrlFor({
- view: Gerrit.Nav.View.ROOT,
- });
- },
+ /**
+ * Navigate to an arbitrary relative URL.
+ *
+ * @param {string} relativeUrl
+ */
+ navigateToRelativeUrl(relativeUrl) {
+ if (!relativeUrl.startsWith('/')) {
+ throw new Error('navigateToRelativeUrl with non-relative URL');
+ }
+ this._navigate(relativeUrl);
+ },
- /**
- * @param {string} repo The name of the repo.
- * @param {string} dashboard The ID of the dashboard, in the form of
- * '<ref>:<path>'.
- * @return {string}
- */
- getUrlForRepoDashboard(repo, dashboard) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.DASHBOARD,
- repo,
- dashboard,
- });
- },
+ /**
+ * @param {string} repoName
+ * @return {string}
+ */
+ getUrlForRepo(repoName) {
+ return this._getUrlFor({
+ view: GerritNav.View.REPO,
+ repoName,
+ });
+ },
- /**
- * Navigate to an arbitrary relative URL.
- *
- * @param {string} relativeUrl
- */
- navigateToRelativeUrl(relativeUrl) {
- if (!relativeUrl.startsWith('/')) {
- throw new Error('navigateToRelativeUrl with non-relative URL');
- }
- this._navigate(relativeUrl);
- },
+ /**
+ * Navigate to a repo settings page.
+ *
+ * @param {string} repoName
+ */
+ navigateToRepo(repoName) {
+ this._navigate(this.getUrlForRepo(repoName));
+ },
- /**
- * @param {string} repoName
- * @return {string}
- */
- getUrlForRepo(repoName) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.REPO,
- repoName,
- });
- },
+ /**
+ * @param {string} repoName
+ * @return {string}
+ */
+ getUrlForRepoTags(repoName) {
+ return this._getUrlFor({
+ view: GerritNav.View.REPO,
+ repoName,
+ detail: GerritNav.RepoDetailView.TAGS,
+ });
+ },
- /**
- * Navigate to a repo settings page.
- *
- * @param {string} repoName
- */
- navigateToRepo(repoName) {
- this._navigate(this.getUrlForRepo(repoName));
- },
+ /**
+ * @param {string} repoName
+ * @return {string}
+ */
+ getUrlForRepoBranches(repoName) {
+ return this._getUrlFor({
+ view: GerritNav.View.REPO,
+ repoName,
+ detail: GerritNav.RepoDetailView.BRANCHES,
+ });
+ },
- /**
- * @param {string} repoName
- * @return {string}
- */
- getUrlForRepoTags(repoName) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.REPO,
- repoName,
- detail: Gerrit.Nav.RepoDetailView.TAGS,
- });
- },
+ /**
+ * @param {string} repoName
+ * @return {string}
+ */
+ getUrlForRepoAccess(repoName) {
+ return this._getUrlFor({
+ view: GerritNav.View.REPO,
+ repoName,
+ detail: GerritNav.RepoDetailView.ACCESS,
+ });
+ },
- /**
- * @param {string} repoName
- * @return {string}
- */
- getUrlForRepoBranches(repoName) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.REPO,
- repoName,
- detail: Gerrit.Nav.RepoDetailView.BRANCHES,
- });
- },
+ /**
+ * @param {string} repoName
+ * @return {string}
+ */
+ getUrlForRepoCommands(repoName) {
+ return this._getUrlFor({
+ view: GerritNav.View.REPO,
+ repoName,
+ detail: GerritNav.RepoDetailView.COMMANDS,
+ });
+ },
- /**
- * @param {string} repoName
- * @return {string}
- */
- getUrlForRepoAccess(repoName) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.REPO,
- repoName,
- detail: Gerrit.Nav.RepoDetailView.ACCESS,
- });
- },
+ /**
+ * @param {string} repoName
+ * @return {string}
+ */
+ getUrlForRepoDashboards(repoName) {
+ return this._getUrlFor({
+ view: GerritNav.View.REPO,
+ repoName,
+ detail: GerritNav.RepoDetailView.DASHBOARDS,
+ });
+ },
- /**
- * @param {string} repoName
- * @return {string}
- */
- getUrlForRepoCommands(repoName) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.REPO,
- repoName,
- detail: Gerrit.Nav.RepoDetailView.COMMANDS,
- });
- },
+ /**
+ * @param {string} groupId
+ * @return {string}
+ */
+ getUrlForGroup(groupId) {
+ return this._getUrlFor({
+ view: GerritNav.View.GROUP,
+ groupId,
+ });
+ },
- /**
- * @param {string} repoName
- * @return {string}
- */
- getUrlForRepoDashboards(repoName) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.REPO,
- repoName,
- detail: Gerrit.Nav.RepoDetailView.DASHBOARDS,
- });
- },
+ /**
+ * @param {string} groupId
+ * @return {string}
+ */
+ getUrlForGroupLog(groupId) {
+ return this._getUrlFor({
+ view: GerritNav.View.GROUP,
+ groupId,
+ detail: GerritNav.GroupDetailView.LOG,
+ });
+ },
- /**
- * @param {string} groupId
- * @return {string}
- */
- getUrlForGroup(groupId) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.GROUP,
- groupId,
- });
- },
+ /**
+ * @param {string} groupId
+ * @return {string}
+ */
+ getUrlForGroupMembers(groupId) {
+ return this._getUrlFor({
+ view: GerritNav.View.GROUP,
+ groupId,
+ detail: GerritNav.GroupDetailView.MEMBERS,
+ });
+ },
- /**
- * @param {string} groupId
- * @return {string}
- */
- getUrlForGroupLog(groupId) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.GROUP,
- groupId,
- detail: Gerrit.Nav.GroupDetailView.LOG,
- });
- },
+ getUrlForSettings() {
+ return this._getUrlFor({view: GerritNav.View.SETTINGS});
+ },
- /**
- * @param {string} groupId
- * @return {string}
- */
- getUrlForGroupMembers(groupId) {
- return this._getUrlFor({
- view: Gerrit.Nav.View.GROUP,
- groupId,
- detail: Gerrit.Nav.GroupDetailView.MEMBERS,
- });
- },
+ /**
+ * @param {string} repo
+ * @param {string} commit
+ * @param {string} file
+ * @param {Object=} opt_options
+ * @return {
+ * Array<{label: string, url: string}>|
+ * {label: string, url: string}
+ * }
+ */
+ getFileWebLinks(repo, commit, file, opt_options) {
+ const params = {type: GerritNav.WeblinkType.FILE, repo, commit, file};
+ if (opt_options) {
+ params.options = opt_options;
+ }
+ return [].concat(this._generateWeblinks(params));
+ },
- getUrlForSettings() {
- return this._getUrlFor({view: Gerrit.Nav.View.SETTINGS});
- },
+ /**
+ * @param {string} repo
+ * @param {string} commit
+ * @param {Object=} opt_options
+ * @return {{label: string, url: string}}
+ */
+ getPatchSetWeblink(repo, commit, opt_options) {
+ const params = {type: GerritNav.WeblinkType.PATCHSET, repo, commit};
+ if (opt_options) {
+ params.options = opt_options;
+ }
+ const result = this._generateWeblinks(params);
+ if (Array.isArray(result)) {
+ return result.pop();
+ } else {
+ return result;
+ }
+ },
- /**
- * @param {string} repo
- * @param {string} commit
- * @param {string} file
- * @param {Object=} opt_options
- * @return {
- * Array<{label: string, url: string}>|
- * {label: string, url: string}
- * }
- */
- getFileWebLinks(repo, commit, file, opt_options) {
- const params = {type: Gerrit.Nav.WeblinkType.FILE, repo, commit, file};
- if (opt_options) {
- params.options = opt_options;
- }
- return [].concat(this._generateWeblinks(params));
- },
+ /**
+ * @param {string} repo
+ * @param {string} commit
+ * @param {Object=} opt_options
+ * @return {
+ * Array<{label: string, url: string}>|
+ * {label: string, url: string}
+ * }
+ */
+ getChangeWeblinks(repo, commit, opt_options) {
+ const params = {type: GerritNav.WeblinkType.CHANGE, repo, commit};
+ if (opt_options) {
+ params.options = opt_options;
+ }
+ return [].concat(this._generateWeblinks(params));
+ },
- /**
- * @param {string} repo
- * @param {string} commit
- * @param {Object=} opt_options
- * @return {{label: string, url: string}}
- */
- getPatchSetWeblink(repo, commit, opt_options) {
- const params = {type: Gerrit.Nav.WeblinkType.PATCHSET, repo, commit};
- if (opt_options) {
- params.options = opt_options;
- }
- const result = this._generateWeblinks(params);
- if (Array.isArray(result)) {
- return result.pop();
- } else {
- return result;
- }
- },
-
- /**
- * @param {string} repo
- * @param {string} commit
- * @param {Object=} opt_options
- * @return {
- * Array<{label: string, url: string}>|
- * {label: string, url: string}
- * }
- */
- getChangeWeblinks(repo, commit, opt_options) {
- const params = {type: Gerrit.Nav.WeblinkType.CHANGE, repo, commit};
- if (opt_options) {
- params.options = opt_options;
- }
- return [].concat(this._generateWeblinks(params));
- },
-
- getUserDashboard(user = 'self', sections = DEFAULT_SECTIONS,
- title = '') {
- sections = sections
- .filter(section => (user === 'self' || !section.selfOnly))
- .map(section => Object.assign({}, section, {
- name: section.name,
- query: section.query.replace(USER_PLACEHOLDER_PATTERN, user),
- }));
- return {title, sections};
- },
- };
-})(window);
+ getUserDashboard(user = 'self', sections = DEFAULT_SECTIONS,
+ title = '') {
+ sections = sections
+ .filter(section => (user === 'self' || !section.selfOnly))
+ .map(section => Object.assign({}, section, {
+ name: section.name,
+ query: section.query.replace(USER_PLACEHOLDER_PATTERN, user),
+ }));
+ return {title, sections};
+ },
+};
diff --git a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation_test.html b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation_test.html
index 33f6215..150c23b 100644
--- a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation_test.html
+++ b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation_test.html
@@ -25,10 +25,12 @@
<script src="/components/wct-browser-legacy/browser.js"></script>
<script type="module">
import '../../../test/common-test-setup.js';
+import {GerritNav} from './gr-navigation.js';
+
suite('gr-navigation tests', () => {
test('invalid patch ranges throw exceptions', () => {
- assert.throw(() => Gerrit.Nav.getUrlForChange('123', undefined, 12));
- assert.throw(() => Gerrit.Nav.getUrlForDiff('123', 'x.c', undefined, 12));
+ assert.throw(() => GerritNav.getUrlForChange('123', undefined, 12));
+ assert.throw(() => GerritNav.getUrlForDiff('123', 'x.c', undefined, 12));
});
suite('_getUserDashboard', () => {
@@ -41,7 +43,7 @@
test('dashboard for self', () => {
const dashboard =
- Gerrit.Nav.getUserDashboard('self', sections, 'title');
+ GerritNav.getUserDashboard('self', sections, 'title');
assert.deepEqual(
dashboard,
{
@@ -64,7 +66,7 @@
test('dashboard for other user', () => {
const dashboard =
- Gerrit.Nav.getUserDashboard('user', sections, 'title');
+ GerritNav.getUserDashboard('user', sections, 'title');
assert.deepEqual(
dashboard,
{
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.js b/polygerrit-ui/app/elements/core/gr-router/gr-router.js
index 9aebd97..56e087e 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.js
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.js
@@ -16,7 +16,6 @@
*/
import '../../../scripts/bundled-polymer.js';
-import '../gr-navigation/gr-navigation.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import '../gr-reporting/gr-reporting.js';
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
@@ -28,6 +27,7 @@
import {BaseUrlBehavior} from '../../../behaviors/base-url-behavior/base-url-behavior.js';
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
import {URLEncodingBehavior} from '../../../behaviors/gr-url-encoding-behavior/gr-url-encoding-behavior.js';
+import {GerritNav} from '../gr-navigation/gr-navigation.js';
const RoutePattern = {
ROOT: '/',
@@ -276,7 +276,7 @@
_generateUrl(params) {
const base = this.getBaseUrl();
let url = '';
- const Views = Gerrit.Nav.View;
+ const Views = GerritNav.View;
if (params.view === Views.SEARCH) {
url = this._generateSearchUrl(params);
@@ -304,11 +304,11 @@
_generateWeblinks(params) {
const type = params.type;
switch (type) {
- case Gerrit.Nav.WeblinkType.FILE:
+ case GerritNav.WeblinkType.FILE:
return this._getFileWebLinks(params);
- case Gerrit.Nav.WeblinkType.CHANGE:
+ case GerritNav.WeblinkType.CHANGE:
return this._getChangeWeblinks(params);
- case Gerrit.Nav.WeblinkType.PATCHSET:
+ case GerritNav.WeblinkType.PATCHSET:
return this._getPatchSetWeblink(params);
default:
console.warn(`Unsupported weblink ${type}!`);
@@ -491,7 +491,7 @@
let suffix = `${range}/${this.encodeURL(params.path, true)}`;
- if (params.view === Gerrit.Nav.View.EDIT) { suffix += ',edit'; }
+ if (params.view === GerritNav.View.EDIT) { suffix += ',edit'; }
if (params.lineNum) {
suffix += '#';
@@ -513,9 +513,9 @@
*/
_generateGroupUrl(params) {
let url = `/admin/groups/${this.encodeURL(params.groupId + '', true)}`;
- if (params.detail === Gerrit.Nav.GroupDetailView.MEMBERS) {
+ if (params.detail === GerritNav.GroupDetailView.MEMBERS) {
url += ',members';
- } else if (params.detail === Gerrit.Nav.GroupDetailView.LOG) {
+ } else if (params.detail === GerritNav.GroupDetailView.LOG) {
url += ',audit-log';
}
return url;
@@ -527,15 +527,15 @@
*/
_generateRepoUrl(params) {
let url = `/admin/repos/${this.encodeURL(params.repoName + '', true)}`;
- if (params.detail === Gerrit.Nav.RepoDetailView.ACCESS) {
+ if (params.detail === GerritNav.RepoDetailView.ACCESS) {
url += ',access';
- } else if (params.detail === Gerrit.Nav.RepoDetailView.BRANCHES) {
+ } else if (params.detail === GerritNav.RepoDetailView.BRANCHES) {
url += ',branches';
- } else if (params.detail === Gerrit.Nav.RepoDetailView.TAGS) {
+ } else if (params.detail === GerritNav.RepoDetailView.TAGS) {
url += ',tags';
- } else if (params.detail === Gerrit.Nav.RepoDetailView.COMMANDS) {
+ } else if (params.detail === GerritNav.RepoDetailView.COMMANDS) {
url += ',commands';
- } else if (params.detail === Gerrit.Nav.RepoDetailView.DASHBOARDS) {
+ } else if (params.detail === GerritNav.RepoDetailView.DASHBOARDS) {
url += ',dashboards';
}
return url;
@@ -727,7 +727,7 @@
page.base(base);
}
- Gerrit.Nav.setup(
+ GerritNav.setup(
url => { page.show(url); },
this._generateUrl.bind(this),
params => this._generateWeblinks(params),
@@ -1021,7 +1021,7 @@
}
} else {
this._setParams({
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
user: data.params[0],
});
}
@@ -1067,7 +1067,7 @@
if (sections.length > 0) {
// Custom dashboard view.
this._setParams({
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
user: 'self',
sections,
title,
@@ -1083,7 +1083,7 @@
_handleProjectDashboardRoute(data) {
const project = data.params[0];
this._setParams({
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
project,
dashboard: decodeURIComponent(data.params[1]),
});
@@ -1100,30 +1100,30 @@
_handleGroupRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.GROUP,
+ view: GerritNav.View.GROUP,
groupId: data.params[0],
});
}
_handleGroupAuditLogRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.GROUP,
- detail: Gerrit.Nav.GroupDetailView.LOG,
+ view: GerritNav.View.GROUP,
+ detail: GerritNav.GroupDetailView.LOG,
groupId: data.params[0],
});
}
_handleGroupMembersRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.GROUP,
- detail: Gerrit.Nav.GroupDetailView.MEMBERS,
+ view: GerritNav.View.GROUP,
+ detail: GerritNav.GroupDetailView.MEMBERS,
groupId: data.params[0],
});
}
_handleGroupListOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-admin-group-list',
offset: data.params[1] || 0,
filter: null,
@@ -1133,7 +1133,7 @@
_handleGroupListFilterOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-admin-group-list',
offset: data.params.offset,
filter: data.params.filter,
@@ -1142,7 +1142,7 @@
_handleGroupListFilterRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-admin-group-list',
filter: data.params.filter || null,
});
@@ -1164,8 +1164,8 @@
_handleRepoCommandsRoute(data) {
const repo = data.params[0];
this._setParams({
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.COMMANDS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.COMMANDS,
repo,
});
this.$.reporting.setRepoName(repo);
@@ -1174,8 +1174,8 @@
_handleRepoAccessRoute(data) {
const repo = data.params[0];
this._setParams({
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.ACCESS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.ACCESS,
repo,
});
this.$.reporting.setRepoName(repo);
@@ -1184,8 +1184,8 @@
_handleRepoDashboardsRoute(data) {
const repo = data.params[0];
this._setParams({
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.DASHBOARDS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.DASHBOARDS,
repo,
});
this.$.reporting.setRepoName(repo);
@@ -1193,8 +1193,8 @@
_handleBranchListOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.BRANCHES,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.BRANCHES,
repo: data.params[0],
offset: data.params[2] || 0,
filter: null,
@@ -1203,8 +1203,8 @@
_handleBranchListFilterOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.BRANCHES,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.BRANCHES,
repo: data.params.repo,
offset: data.params.offset,
filter: data.params.filter,
@@ -1213,8 +1213,8 @@
_handleBranchListFilterRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.BRANCHES,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.BRANCHES,
repo: data.params.repo,
filter: data.params.filter || null,
});
@@ -1222,8 +1222,8 @@
_handleTagListOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.TAGS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.TAGS,
repo: data.params[0],
offset: data.params[2] || 0,
filter: null,
@@ -1232,8 +1232,8 @@
_handleTagListFilterOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.TAGS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.TAGS,
repo: data.params.repo,
offset: data.params.offset,
filter: data.params.filter,
@@ -1242,8 +1242,8 @@
_handleTagListFilterRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.TAGS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.TAGS,
repo: data.params.repo,
filter: data.params.filter || null,
});
@@ -1251,7 +1251,7 @@
_handleRepoListOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
offset: data.params[1] || 0,
filter: null,
@@ -1261,7 +1261,7 @@
_handleRepoListFilterOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
offset: data.params.offset,
filter: data.params.filter,
@@ -1270,7 +1270,7 @@
_handleRepoListFilterRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
filter: data.params.filter || null,
});
@@ -1291,7 +1291,7 @@
_handleRepoRoute(data) {
const repo = data.params[0];
this._setParams({
- view: Gerrit.Nav.View.REPO,
+ view: GerritNav.View.REPO,
repo,
});
this.$.reporting.setRepoName(repo);
@@ -1299,7 +1299,7 @@
_handlePluginListOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
offset: data.params[1] || 0,
filter: null,
@@ -1308,7 +1308,7 @@
_handlePluginListFilterOffsetRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
offset: data.params.offset,
filter: data.params.filter,
@@ -1317,7 +1317,7 @@
_handlePluginListFilterRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
filter: data.params.filter || null,
});
@@ -1325,14 +1325,14 @@
_handlePluginListRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
});
}
_handleQueryRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.SEARCH,
+ view: GerritNav.View.SEARCH,
query: data.params[0],
offset: data.params[2],
});
@@ -1353,7 +1353,7 @@
changeNum: ctx.params[1],
basePatchNum: ctx.params[4],
patchNum: ctx.params[6],
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
queryMap: ctx.queryMap,
};
@@ -1369,7 +1369,7 @@
basePatchNum: ctx.params[4],
patchNum: ctx.params[6],
path: ctx.params[8],
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
};
const address = this._parseLineAddress(ctx.hash);
@@ -1387,7 +1387,7 @@
changeNum: ctx.params[0],
basePatchNum: ctx.params[3],
patchNum: ctx.params[5],
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
querystring: ctx.querystring,
};
@@ -1405,7 +1405,7 @@
basePatchNum: ctx.params[2],
patchNum: ctx.params[4],
path: ctx.params[5],
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
};
const address = this._parseLineAddress(ctx.hash);
@@ -1426,7 +1426,7 @@
patchNum: ctx.params[2],
path: ctx.params[3],
lineNum: ctx.hash,
- view: Gerrit.Nav.View.EDIT,
+ view: GerritNav.View.EDIT,
});
this.$.reporting.setRepoName(project);
}
@@ -1438,7 +1438,7 @@
project,
changeNum: ctx.params[1],
patchNum: ctx.params[3],
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
edit: true,
});
this.$.reporting.setRepoName(project);
@@ -1462,7 +1462,7 @@
}
_handleNewAgreementsRoute(data) {
- data.params.view = Gerrit.Nav.View.AGREEMENTS;
+ data.params.view = GerritNav.View.AGREEMENTS;
this._setParams(data.params);
}
@@ -1472,13 +1472,13 @@
// undo that to have valid tokens.
const token = data.params[0].replace(/ /g, '+');
this._setParams({
- view: Gerrit.Nav.View.SETTINGS,
+ view: GerritNav.View.SETTINGS,
emailToken: token,
});
}
_handleSettingsRoute(data) {
- this._setParams({view: Gerrit.Nav.View.SETTINGS});
+ this._setParams({view: GerritNav.View.SETTINGS});
}
_handleRegisterRoute(ctx) {
@@ -1511,7 +1511,7 @@
}
_handlePluginScreen(ctx) {
- const view = Gerrit.Nav.View.PLUGIN_SCREEN;
+ const view = GerritNav.View.PLUGIN_SCREEN;
const plugin = ctx.params[0];
const screen = ctx.params[1];
this._setParams({view, plugin, screen});
@@ -1519,7 +1519,7 @@
_handleDocumentationSearchRoute(data) {
this._setParams({
- view: Gerrit.Nav.View.DOCUMENTATION_SEARCH,
+ view: GerritNav.View.DOCUMENTATION_SEARCH,
filter: data.params.filter || null,
});
}
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html
index 73b6fb0..9e3a7a8 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html
@@ -34,6 +34,8 @@
import '../../../test/common-test-setup.js';
import './gr-router.js';
import page from 'page/page.mjs';
+import {GerritNav} from '../gr-navigation/gr-navigation.js';
+
suite('gr-router tests', () => {
let element;
let sandbox;
@@ -149,7 +151,7 @@
const requiresAuth = {};
const doesNotRequireAuth = {};
- sandbox.stub(Gerrit.Nav, 'setup');
+ sandbox.stub(GerritNav, 'setup');
sandbox.stub(page, 'start');
sandbox.stub(page, 'base');
sandbox.stub(element, '_mapRoute', (pattern, methodName, usesAuth) => {
@@ -268,7 +270,7 @@
suite('generateUrl', () => {
test('search', () => {
let params = {
- view: Gerrit.Nav.View.SEARCH,
+ view: GerritNav.View.SEARCH,
owner: 'a%b',
project: 'c%d',
branch: 'e%f',
@@ -293,7 +295,7 @@
assert.equal(element._generateUrl(params), '/q/foo%2524bar,100');
params = {
- view: Gerrit.Nav.View.SEARCH,
+ view: GerritNav.View.SEARCH,
statuses: ['a', 'b', 'c'],
};
assert.equal(element._generateUrl(params),
@@ -302,12 +304,12 @@
test('change', () => {
const params = {
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
changeNum: '1234',
project: 'test',
};
const paramsWithQuery = {
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
changeNum: '1234',
project: 'test',
querystring: 'revert&foo=bar',
@@ -335,7 +337,7 @@
test('change with repo name encoding', () => {
const params = {
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
changeNum: '1234',
project: 'x+/y+/z+/w',
};
@@ -345,7 +347,7 @@
test('diff', () => {
const params = {
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
changeNum: '42',
path: 'x+y/path.cpp',
patchNum: 12,
@@ -379,7 +381,7 @@
test('diff with repo name encoding', () => {
const params = {
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
changeNum: '42',
path: 'x+y/path.cpp',
patchNum: 12,
@@ -391,7 +393,7 @@
test('edit', () => {
const params = {
- view: Gerrit.Nav.View.EDIT,
+ view: GerritNav.View.EDIT,
changeNum: '42',
project: 'test',
path: 'x+y/path.cpp',
@@ -421,14 +423,14 @@
suite('dashboard', () => {
test('self dashboard', () => {
const params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
};
assert.equal(element._generateUrl(params), '/dashboard/self');
});
test('user dashboard', () => {
const params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
user: 'user',
};
assert.equal(element._generateUrl(params), '/dashboard/user');
@@ -436,7 +438,7 @@
test('custom self dashboard, no title', () => {
const params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
sections: [
{name: 'section 1', query: 'query 1'},
{name: 'section 2', query: 'query 2'},
@@ -449,7 +451,7 @@
test('custom repo dashboard', () => {
const params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
sections: [
{name: 'section 1', query: 'query 1 ${project}'},
{name: 'section 2', query: 'query 2 ${repo}'},
@@ -464,7 +466,7 @@
test('custom user dashboard, with title', () => {
const params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
user: 'user',
sections: [{name: 'name', query: 'query'}],
title: 'custom dashboard',
@@ -476,7 +478,7 @@
test('repo dashboard', () => {
const params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
repo: 'gerrit/repo',
dashboard: 'default:main',
};
@@ -487,7 +489,7 @@
test('project dashboard (legacy)', () => {
const params = {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
project: 'gerrit/project',
dashboard: 'default:main',
};
@@ -500,7 +502,7 @@
suite('groups', () => {
test('group info', () => {
const params = {
- view: Gerrit.Nav.View.GROUP,
+ view: GerritNav.View.GROUP,
groupId: 1234,
};
assert.equal(element._generateUrl(params), '/admin/groups/1234');
@@ -508,7 +510,7 @@
test('group members', () => {
const params = {
- view: Gerrit.Nav.View.GROUP,
+ view: GerritNav.View.GROUP,
groupId: 1234,
detail: 'members',
};
@@ -518,7 +520,7 @@
test('group audit log', () => {
const params = {
- view: Gerrit.Nav.View.GROUP,
+ view: GerritNav.View.GROUP,
groupId: 1234,
detail: 'log',
};
@@ -635,13 +637,13 @@
element._handleNewAgreementsRoute({params: {}});
assert.isTrue(setParamsStub.calledOnce);
assert.equal(setParamsStub.lastCall.args[0].view,
- Gerrit.Nav.View.AGREEMENTS);
+ GerritNav.View.AGREEMENTS);
});
test('_handleSettingsLegacyRoute', () => {
const data = {params: {0: 'my-token'}};
assertDataToParams(data, '_handleSettingsLegacyRoute', {
- view: Gerrit.Nav.View.SETTINGS,
+ view: GerritNav.View.SETTINGS,
emailToken: 'my-token',
});
});
@@ -649,7 +651,7 @@
test('_handleSettingsLegacyRoute with +', () => {
const data = {params: {0: 'my-token test'}};
assertDataToParams(data, '_handleSettingsLegacyRoute', {
- view: Gerrit.Nav.View.SETTINGS,
+ view: GerritNav.View.SETTINGS,
emailToken: 'my-token+test',
});
});
@@ -657,7 +659,7 @@
test('_handleSettingsRoute', () => {
const data = {};
assertDataToParams(data, '_handleSettingsRoute', {
- view: Gerrit.Nav.View.SETTINGS,
+ view: GerritNav.View.SETTINGS,
});
});
@@ -677,7 +679,7 @@
onExit = _onExit;
};
sandbox.stub(page, 'exit', onRegisteringExit);
- sandbox.stub(Gerrit.Nav, 'setup');
+ sandbox.stub(GerritNav, 'setup');
sandbox.stub(page, 'start');
sandbox.stub(page, 'base');
element._startRouter();
@@ -712,14 +714,14 @@
test('_handleQueryRoute', () => {
const data = {params: ['project:foo/bar/baz']};
assertDataToParams(data, '_handleQueryRoute', {
- view: Gerrit.Nav.View.SEARCH,
+ view: GerritNav.View.SEARCH,
query: 'project:foo/bar/baz',
offset: undefined,
});
data.params.push(',123', '123');
assertDataToParams(data, '_handleQueryRoute', {
- view: Gerrit.Nav.View.SEARCH,
+ view: GerritNav.View.SEARCH,
query: 'project:foo/bar/baz',
offset: '123',
});
@@ -734,14 +736,14 @@
test('_handleQueryRoute', () => {
const data = {params: ['project:foo/bar/baz']};
assertDataToParams(data, '_handleQueryRoute', {
- view: Gerrit.Nav.View.SEARCH,
+ view: GerritNav.View.SEARCH,
query: 'project:foo/bar/baz',
offset: undefined,
});
data.params.push(',123', '123');
assertDataToParams(data, '_handleQueryRoute', {
- view: Gerrit.Nav.View.SEARCH,
+ view: GerritNav.View.SEARCH,
query: 'project:foo/bar/baz',
offset: '123',
});
@@ -926,7 +928,7 @@
assert.isFalse(redirectStub.called);
assert.isTrue(setParamsStub.calledOnce);
assert.deepEqual(setParamsStub.lastCall.args[0], {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
user: 'foo',
});
});
@@ -956,7 +958,7 @@
assert.isFalse(redirectStub.called);
assert.isTrue(setParamsStub.calledOnce);
assert.deepEqual(setParamsStub.lastCall.args[0], {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
user: 'self',
sections: [
{name: 'a', query: 'b'},
@@ -976,7 +978,7 @@
assert.isFalse(redirectStub.called);
assert.isTrue(setParamsStub.calledOnce);
assert.deepEqual(setParamsStub.lastCall.args[0], {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
user: 'self',
sections: [
{name: 'a', query: 'b'},
@@ -995,7 +997,7 @@
assert.isFalse(redirectStub.called);
assert.isTrue(setParamsStub.calledOnce);
assert.deepEqual(setParamsStub.lastCall.args[0], {
- view: Gerrit.Nav.View.DASHBOARD,
+ view: GerritNav.View.DASHBOARD,
user: 'self',
sections: [
{name: 'a', query: 'is:open b'},
@@ -1017,7 +1019,7 @@
test('_handleGroupAuditLogRoute', () => {
const data = {params: {0: 1234}};
assertDataToParams(data, '_handleGroupAuditLogRoute', {
- view: Gerrit.Nav.View.GROUP,
+ view: GerritNav.View.GROUP,
detail: 'log',
groupId: 1234,
});
@@ -1026,7 +1028,7 @@
test('_handleGroupMembersRoute', () => {
const data = {params: {0: 1234}};
assertDataToParams(data, '_handleGroupMembersRoute', {
- view: Gerrit.Nav.View.GROUP,
+ view: GerritNav.View.GROUP,
detail: 'members',
groupId: 1234,
});
@@ -1035,7 +1037,7 @@
test('_handleGroupListOffsetRoute', () => {
const data = {params: {}};
assertDataToParams(data, '_handleGroupListOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-admin-group-list',
offset: 0,
filter: null,
@@ -1044,7 +1046,7 @@
data.params[1] = 42;
assertDataToParams(data, '_handleGroupListOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-admin-group-list',
offset: 42,
filter: null,
@@ -1053,7 +1055,7 @@
data.hash = 'create';
assertDataToParams(data, '_handleGroupListOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-admin-group-list',
offset: 42,
filter: null,
@@ -1064,7 +1066,7 @@
test('_handleGroupListFilterOffsetRoute', () => {
const data = {params: {filter: 'foo', offset: 42}};
assertDataToParams(data, '_handleGroupListFilterOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-admin-group-list',
offset: 42,
filter: 'foo',
@@ -1074,7 +1076,7 @@
test('_handleGroupListFilterRoute', () => {
const data = {params: {filter: 'foo'}};
assertDataToParams(data, '_handleGroupListFilterRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-admin-group-list',
filter: 'foo',
});
@@ -1083,7 +1085,7 @@
test('_handleGroupRoute', () => {
const data = {params: {0: 4321}};
assertDataToParams(data, '_handleGroupRoute', {
- view: Gerrit.Nav.View.GROUP,
+ view: GerritNav.View.GROUP,
groupId: 4321,
});
});
@@ -1115,7 +1117,7 @@
test('_handleRepoRoute', () => {
const data = {params: {0: 4321}};
assertDataToParams(data, '_handleRepoRoute', {
- view: Gerrit.Nav.View.REPO,
+ view: GerritNav.View.REPO,
repo: 4321,
});
});
@@ -1123,8 +1125,8 @@
test('_handleRepoCommandsRoute', () => {
const data = {params: {0: 4321}};
assertDataToParams(data, '_handleRepoCommandsRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.COMMANDS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.COMMANDS,
repo: 4321,
});
});
@@ -1132,8 +1134,8 @@
test('_handleRepoAccessRoute', () => {
const data = {params: {0: 4321}};
assertDataToParams(data, '_handleRepoAccessRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.ACCESS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.ACCESS,
repo: 4321,
});
});
@@ -1142,8 +1144,8 @@
test('_handleBranchListOffsetRoute', () => {
const data = {params: {0: 4321}};
assertDataToParams(data, '_handleBranchListOffsetRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.BRANCHES,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.BRANCHES,
repo: 4321,
offset: 0,
filter: null,
@@ -1151,8 +1153,8 @@
data.params[2] = 42;
assertDataToParams(data, '_handleBranchListOffsetRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.BRANCHES,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.BRANCHES,
repo: 4321,
offset: 42,
filter: null,
@@ -1162,8 +1164,8 @@
test('_handleBranchListFilterOffsetRoute', () => {
const data = {params: {repo: 4321, filter: 'foo', offset: 42}};
assertDataToParams(data, '_handleBranchListFilterOffsetRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.BRANCHES,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.BRANCHES,
repo: 4321,
offset: 42,
filter: 'foo',
@@ -1173,8 +1175,8 @@
test('_handleBranchListFilterRoute', () => {
const data = {params: {repo: 4321, filter: 'foo'}};
assertDataToParams(data, '_handleBranchListFilterRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.BRANCHES,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.BRANCHES,
repo: 4321,
filter: 'foo',
});
@@ -1185,8 +1187,8 @@
test('_handleTagListOffsetRoute', () => {
const data = {params: {0: 4321}};
assertDataToParams(data, '_handleTagListOffsetRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.TAGS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.TAGS,
repo: 4321,
offset: 0,
filter: null,
@@ -1196,8 +1198,8 @@
test('_handleTagListFilterOffsetRoute', () => {
const data = {params: {repo: 4321, filter: 'foo', offset: 42}};
assertDataToParams(data, '_handleTagListFilterOffsetRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.TAGS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.TAGS,
repo: 4321,
offset: 42,
filter: 'foo',
@@ -1207,16 +1209,16 @@
test('_handleTagListFilterRoute', () => {
const data = {params: {repo: 4321}};
assertDataToParams(data, '_handleTagListFilterRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.TAGS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.TAGS,
repo: 4321,
filter: null,
});
data.params.filter = 'foo';
assertDataToParams(data, '_handleTagListFilterRoute', {
- view: Gerrit.Nav.View.REPO,
- detail: Gerrit.Nav.RepoDetailView.TAGS,
+ view: GerritNav.View.REPO,
+ detail: GerritNav.RepoDetailView.TAGS,
repo: 4321,
filter: 'foo',
});
@@ -1227,7 +1229,7 @@
test('_handleRepoListOffsetRoute', () => {
const data = {params: {}};
assertDataToParams(data, '_handleRepoListOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
offset: 0,
filter: null,
@@ -1236,7 +1238,7 @@
data.params[1] = 42;
assertDataToParams(data, '_handleRepoListOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
offset: 42,
filter: null,
@@ -1245,7 +1247,7 @@
data.hash = 'create';
assertDataToParams(data, '_handleRepoListOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
offset: 42,
filter: null,
@@ -1256,7 +1258,7 @@
test('_handleRepoListFilterOffsetRoute', () => {
const data = {params: {filter: 'foo', offset: 42}};
assertDataToParams(data, '_handleRepoListFilterOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
offset: 42,
filter: 'foo',
@@ -1266,14 +1268,14 @@
test('_handleRepoListFilterRoute', () => {
const data = {params: {}};
assertDataToParams(data, '_handleRepoListFilterRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
filter: null,
});
data.params.filter = 'foo';
assertDataToParams(data, '_handleRepoListFilterRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-repo-list',
filter: 'foo',
});
@@ -1285,7 +1287,7 @@
test('_handlePluginListOffsetRoute', () => {
const data = {params: {}};
assertDataToParams(data, '_handlePluginListOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
offset: 0,
filter: null,
@@ -1293,7 +1295,7 @@
data.params[1] = 42;
assertDataToParams(data, '_handlePluginListOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
offset: 42,
filter: null,
@@ -1303,7 +1305,7 @@
test('_handlePluginListFilterOffsetRoute', () => {
const data = {params: {filter: 'foo', offset: 42}};
assertDataToParams(data, '_handlePluginListFilterOffsetRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
offset: 42,
filter: 'foo',
@@ -1313,14 +1315,14 @@
test('_handlePluginListFilterRoute', () => {
const data = {params: {}};
assertDataToParams(data, '_handlePluginListFilterRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
filter: null,
});
data.params.filter = 'foo';
assertDataToParams(data, '_handlePluginListFilterRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
filter: 'foo',
});
@@ -1329,7 +1331,7 @@
test('_handlePluginListRoute', () => {
const data = {params: {}};
assertDataToParams(data, '_handlePluginListRoute', {
- view: Gerrit.Nav.View.ADMIN,
+ view: GerritNav.View.ADMIN,
adminView: 'gr-plugin-list',
});
});
@@ -1363,7 +1365,7 @@
changeNum: 1234,
basePatchNum: 6,
patchNum: 9,
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
querystring: '',
});
});
@@ -1390,7 +1392,7 @@
changeNum: 1234,
basePatchNum: 3,
patchNum: 8,
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
path: 'foo/bar',
lineNum: 123,
leftSide: true,
@@ -1453,7 +1455,7 @@
sandbox.stub(element, '_generateUrl').returns('foo');
const ctx = makeParams(null, '');
assertDataToParams(ctx, '_handleChangeRoute', {
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
project: 'foo/bar',
changeNum: 1234,
basePatchNum: 4,
@@ -1507,7 +1509,7 @@
sandbox.stub(element, '_generateUrl').returns('foo');
const ctx = makeParams('foo/bar/baz', 'b44');
assertDataToParams(ctx, '_handleDiffRoute', {
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
project: 'foo/bar',
changeNum: 1234,
basePatchNum: 4,
@@ -1536,7 +1538,7 @@
const appParams = {
project: 'foo/bar',
changeNum: 1234,
- view: Gerrit.Nav.View.EDIT,
+ view: GerritNav.View.EDIT,
path: 'foo/bar/baz',
patchNum: 3,
lineNum: undefined,
@@ -1566,7 +1568,7 @@
const appParams = {
project: 'foo/bar',
changeNum: 1234,
- view: Gerrit.Nav.View.EDIT,
+ view: GerritNav.View.EDIT,
path: 'foo/bar/baz',
patchNum: 3,
lineNum: 4,
@@ -1595,7 +1597,7 @@
const appParams = {
project: 'foo/bar',
changeNum: 1234,
- view: Gerrit.Nav.View.CHANGE,
+ view: GerritNav.View.CHANGE,
patchNum: 3,
edit: true,
};
@@ -1612,7 +1614,7 @@
test('_handlePluginScreen', () => {
const ctx = {params: ['foo', 'bar']};
assertDataToParams(ctx, '_handlePluginScreen', {
- view: Gerrit.Nav.View.PLUGIN_SCREEN,
+ view: GerritNav.View.PLUGIN_SCREEN,
plugin: 'foo',
screen: 'bar',
});
diff --git a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js
index 305d2c1..dcece30 100644
--- a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js
+++ b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js
@@ -16,7 +16,6 @@
*/
import '../../../scripts/bundled-polymer.js';
-import '../gr-navigation/gr-navigation.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import '../gr-search-bar/gr-search-bar.js';
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
@@ -25,6 +24,7 @@
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-smart-search_html.js';
import {DisplayNameBehavior} from '../../../behaviors/gr-display-name-behavior/gr-display-name-behavior.js';
+import {GerritNav} from '../gr-navigation/gr-navigation.js';
const MAX_AUTOCOMPLETE_RESULTS = 10;
const SELF_EXPRESSION = 'self';
@@ -78,7 +78,7 @@
_handleSearch(e) {
const input = e.detail.inputVal;
if (input) {
- Gerrit.Nav.navigateToSearchQuery(input);
+ GerritNav.navigateToSearchQuery(input);
}
}
diff --git a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.js b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.js
index f047198..e2dda2f 100644
--- a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.js
+++ b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.js
@@ -26,6 +26,7 @@
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-apply-fix-dialog_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/**
* @extends Polymer.Element
@@ -229,7 +230,7 @@
)
.then(res => {
if (res && res.ok) {
- Gerrit.Nav.navigateToChange(this.change, 'edit', this._patchNum);
+ GerritNav.navigateToChange(this.change, 'edit', this._patchNum);
this._close();
}
this._isApplyFixLoading = false;
diff --git a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.html b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.html
index 52497a9..8874f71 100644
--- a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.html
@@ -38,6 +38,8 @@
import '../../../test/common-test-setup.js';
import '../../../test/common-test-setup.js';
import './gr-apply-fix-dialog.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-apply-fix-dialog tests', () => {
let element;
let sandbox;
@@ -210,13 +212,13 @@
'and navigate to change view', done => {
sandbox.stub(element.$.restAPI, 'applyFixSuggestion')
.returns(Promise.resolve({ok: true}));
- sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ sandbox.stub(GerritNav, 'navigateToChange');
element._currentFix = {fix_id: '123'};
element._handleApplyFix().then(() => {
assert.isTrue(element.$.restAPI.applyFixSuggestion
.calledWithExactly('1', 2, '123'));
- assert.isTrue(Gerrit.Nav.navigateToChange.calledWithExactly({
+ assert.isTrue(GerritNav.navigateToChange.calledWithExactly({
_number: '1',
project: 'project',
revisions: {
@@ -236,13 +238,13 @@
test('should not navigate to change view if incorect reponse', done => {
sandbox.stub(element.$.restAPI, 'applyFixSuggestion')
.returns(Promise.resolve({}));
- sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ sandbox.stub(GerritNav, 'navigateToChange');
element._currentFix = {fix_id: '123'};
element._handleApplyFix().then(() => {
assert.isTrue(element.$.restAPI.applyFixSuggestion
.calledWithExactly('1', 2, '123'));
- assert.isTrue(Gerrit.Nav.navigateToChange.notCalled);
+ assert.isTrue(GerritNav.navigateToChange.notCalled);
assert.equal(element._isApplyFixLoading, false);
done();
@@ -308,11 +310,11 @@
}));
const errorStub = sinon.stub();
document.addEventListener('network-error', errorStub);
- sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ sandbox.stub(GerritNav, 'navigateToChange');
element._currentFix = {fix_id: '123'};
element._handleApplyFix();
flush(() => {
- assert.isFalse(Gerrit.Nav.navigateToChange.called);
+ assert.isFalse(GerritNav.navigateToChange.called);
assert.isTrue(errorStub.called);
done();
});
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js
index 709ba6f..ba5bc46 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js
@@ -31,6 +31,7 @@
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
import {GrDiffBuilder} from '../gr-diff-builder/gr-diff-builder.js';
import {util} from '../../../scripts/util.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const MSG_EMPTY_BLAME = 'No blame information for this diff.';
@@ -440,10 +441,10 @@
return {};
}
return {
- meta_a: Gerrit.Nav.getFileWebLinks(
+ meta_a: GerritNav.getFileWebLinks(
this.projectName, this.commitRange.baseCommit, this.path,
{weblinks: diff && diff.meta_a && diff.meta_a.web_links}),
- meta_b: Gerrit.Nav.getFileWebLinks(
+ meta_b: GerritNav.getFileWebLinks(
this.projectName, this.commitRange.commit, this.path,
{weblinks: diff && diff.meta_b && diff.meta_b.web_links}),
};
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.html b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.html
index bf32f34..a8565c1 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.html
@@ -34,6 +34,7 @@
import '../../../test/common-test-setup.js';
import './gr-diff-host.js';
import {GrDiffBuilderImage} from '../gr-diff-builder/gr-diff-builder-image.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
suite('gr-diff-host tests', () => {
let element;
@@ -409,7 +410,7 @@
});
test('reload() loads files weblinks', () => {
- const weblinksStub = sandbox.stub(Gerrit.Nav, '_generateWeblinks')
+ const weblinksStub = sandbox.stub(GerritNav, '_generateWeblinks')
.returns({name: 'stubb', url: '#s'});
sandbox.stub(element.$.restAPI, 'getDiff').returns(Promise.resolve({
content: [],
@@ -427,7 +428,7 @@
weblinks: undefined,
},
repo: 'test-project',
- type: Gerrit.Nav.WeblinkType.FILE}));
+ type: GerritNav.WeblinkType.FILE}));
assert.isTrue(weblinksStub.secondCall.calledWith({
commit: 'test-commit',
file: 'test-path',
@@ -435,7 +436,7 @@
weblinks: undefined,
},
repo: 'test-project',
- type: Gerrit.Nav.WeblinkType.FILE}));
+ type: GerritNav.WeblinkType.FILE}));
assert.deepEqual(element.filesWeblinks, {
meta_a: [{name: 'stubb', url: '#s'}],
meta_b: [{name: 'stubb', url: '#s'}],
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
index e87b25c..761660a 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
@@ -19,7 +19,6 @@
import '@polymer/iron-dropdown/iron-dropdown.js';
import '@polymer/iron-input/iron-input.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../core/gr-reporting/gr-reporting.js';
import '../../shared/gr-button/gr-button.js';
import '../../shared/gr-dropdown/gr-dropdown.js';
@@ -47,6 +46,7 @@
import {KeyboardShortcutBehavior} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
import {RESTClientBehavior} from '../../../behaviors/rest-client-behavior/rest-client-behavior.js';
import {GrCountStringFormatter} from '../../shared/gr-count-string-formatter/gr-count-string-formatter.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const ERR_REVIEW_STATUS = 'Couldn’t change file review status.';
const MSG_LOADING_BLAME = 'Loading blame...';
@@ -482,7 +482,7 @@
return;
}
- Gerrit.Nav.navigateToDiff(this._change, this._commentSkips.previous,
+ GerritNav.navigateToDiff(this._change, this._commentSkips.previous,
this._patchRange.patchNum, this._patchRange.basePatchNum);
}
@@ -495,7 +495,7 @@
return;
}
- Gerrit.Nav.navigateToDiff(this._change, this._commentSkips.next,
+ GerritNav.navigateToDiff(this._change, this._commentSkips.next,
this._patchRange.patchNum, this._patchRange.basePatchNum);
}
@@ -615,7 +615,7 @@
return;
}
- Gerrit.Nav.navigateToDiff(this._change, newPath.path,
+ GerritNav.navigateToDiff(this._change, newPath.path,
this._patchRange.patchNum, this._patchRange.basePatchNum);
}
@@ -645,9 +645,9 @@
_goToEditFile() {
// TODO(taoalpha): add a shortcut for editing
- const editUrl = Gerrit.Nav.getEditUrlForDiff(
+ const editUrl = GerritNav.getEditUrlForDiff(
this._change, this._path, this._patchRange.patchNum);
- return Gerrit.Nav.navigateToRelativeUrl(editUrl);
+ return GerritNav.navigateToRelativeUrl(editUrl);
}
/**
@@ -705,7 +705,7 @@
}
_paramsChanged(value) {
- if (value.view !== Gerrit.Nav.View.DIFF) { return; }
+ if (value.view !== GerritNav.View.DIFF) { return; }
if (value.changeNum && value.project) {
this.$.restAPI.setInProjectLookup(value.changeNum, value.project);
@@ -823,7 +823,7 @@
return;
}
- if (params.view === Gerrit.Nav.View.DIFF) {
+ if (params.view === GerritNav.View.DIFF) {
this._setReviewed(true);
}
}
@@ -866,7 +866,7 @@
if ([change, patchRange, path].some(arg => arg === undefined)) {
return '';
}
- return Gerrit.Nav.getUrlForDiff(change, path, patchRange.patchNum,
+ return GerritNav.getUrlForDiff(change, path, patchRange.patchNum,
patchRange.basePatchNum);
}
@@ -908,13 +908,13 @@
return '';
}
const range = this._getChangeUrlRange(patchRange, revisions);
- return Gerrit.Nav.getUrlForChange(change, range.patchNum,
+ return GerritNav.getUrlForChange(change, range.patchNum,
range.basePatchNum);
}
_navigateToChange(change, patchRange, revisions) {
const range = this._getChangeUrlRange(patchRange, revisions);
- Gerrit.Nav.navigateToChange(change, range.patchNum, range.basePatchNum);
+ GerritNav.navigateToChange(change, range.patchNum, range.basePatchNum);
}
_computeChangePath(change, patchRangeRecord, revisions) {
@@ -974,7 +974,7 @@
return;
}
- Gerrit.Nav.navigateToDiff(this._change, path, this._patchRange.patchNum,
+ GerritNav.navigateToDiff(this._change, path, this._patchRange.patchNum,
this._patchRange.basePatchNum);
}
@@ -990,7 +990,7 @@
const {basePatchNum, patchNum} = e.detail;
if (this.patchNumEquals(basePatchNum, this._patchRange.basePatchNum) &&
this.patchNumEquals(patchNum, this._patchRange.patchNum)) { return; }
- Gerrit.Nav.navigateToDiff(
+ GerritNav.navigateToDiff(
this._change, this._path, patchNum, basePatchNum);
}
@@ -1033,7 +1033,7 @@
const cursorAddress = this.$.cursor.getAddress();
const number = cursorAddress ? cursorAddress.number : undefined;
const leftSide = cursorAddress ? cursorAddress.leftSide : undefined;
- const url = Gerrit.Nav.getUrlForDiffById(this._changeNum,
+ const url = GerritNav.getUrlForDiffById(this._changeNum,
this._change.project, this._path, this._patchRange.patchNum,
this._patchRange.basePatchNum, number, leftSide);
history.replaceState(null, '', url);
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
index 881a150..26b900d 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
@@ -42,6 +42,8 @@
import './gr-diff-view.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {KeyboardShortcutBinder} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-diff-view tests', () => {
suite('basic tests', () => {
const kb = KeyboardShortcutBinder;
@@ -115,7 +117,7 @@
sandbox.stub(element.$.diffHost, 'reload').returns(Promise.resolve());
sandbox.spy(element, '_paramsChanged');
element.params = {
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
changeNum: '42',
patchNum: '2',
basePatchNum: '1',
@@ -152,8 +154,8 @@
element.changeViewState.selectedFileIndex = 1;
element._loggedIn = true;
- const diffNavStub = sandbox.stub(Gerrit.Nav, 'navigateToDiff');
- const changeNavStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ const diffNavStub = sandbox.stub(GerritNav, 'navigateToDiff');
+ const changeNavStub = sandbox.stub(GerritNav, 'navigateToChange');
MockInteractions.pressAndReleaseKeyOn(element, 85, null, 'u');
assert(changeNavStub.lastCall.calledWith(element._change),
@@ -258,8 +260,8 @@
['chell.go', 'glados.txt', 'wheatley.md']);
element._path = 'glados.txt';
- const diffNavStub = sandbox.stub(Gerrit.Nav, 'navigateToDiff');
- const changeNavStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ const diffNavStub = sandbox.stub(GerritNav, 'navigateToDiff');
+ const changeNavStub = sandbox.stub(GerritNav, 'navigateToChange');
MockInteractions.pressAndReleaseKeyOn(element, 65, null, 'a');
assert.isTrue(changeNavStub.notCalled, 'The `a` keyboard shortcut ' +
@@ -326,8 +328,8 @@
['chell.go', 'glados.txt', 'wheatley.md']);
element._path = 'glados.txt';
- const diffNavStub = sandbox.stub(Gerrit.Nav, 'navigateToDiff');
- const changeNavStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ const diffNavStub = sandbox.stub(GerritNav, 'navigateToDiff');
+ const changeNavStub = sandbox.stub(GerritNav, 'navigateToChange');
MockInteractions.pressAndReleaseKeyOn(element, 65, null, 'a');
assert.isTrue(changeNavStub.notCalled, 'The `a` keyboard shortcut ' +
@@ -385,7 +387,7 @@
b: {_number: 2, commit: {parents: []}},
},
};
- const redirectStub = sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl');
+ const redirectStub = sandbox.stub(GerritNav, 'navigateToRelativeUrl');
flush(() => {
const editBtn = element.shadowRoot
.querySelector('.editButton gr-button');
@@ -507,11 +509,11 @@
suite('url params', () => {
setup(() => {
sandbox.stub(
- Gerrit.Nav,
+ GerritNav,
'getUrlForDiff',
(c, p, pn, bpn) => `${c._number}-${p}-${pn}-${bpn}`);
sandbox.stub(
- Gerrit.Nav
+ GerritNav
, 'getUrlForChange',
(c, pn, bpn) => `${c._number}-${pn}-${bpn}`);
});
@@ -640,7 +642,7 @@
});
test('_handlePatchChange calls navigateToDiff correctly', () => {
- const navigateStub = sandbox.stub(Gerrit.Nav, 'navigateToDiff');
+ const navigateStub = sandbox.stub(GerritNav, 'navigateToDiff');
element._change = {_number: 321, project: 'foo/bar'};
element._path = 'path/to/file.txt';
@@ -670,7 +672,7 @@
sandbox.stub(element.$.diffHost, 'reload');
element._loggedIn = true;
element.params = {
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
changeNum: '42',
patchNum: '2',
basePatchNum: '1',
@@ -696,7 +698,7 @@
element._loggedIn = true;
element.params = {
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
changeNum: '42',
patchNum: '2',
basePatchNum: '1',
@@ -718,11 +720,11 @@
assert.isTrue(saveReviewedStub.lastCall.calledWithExactly(true));
const callCount = saveReviewedStub.callCount;
- element.set('params.view', Gerrit.Nav.View.CHANGE);
+ element.set('params.view', GerritNav.View.CHANGE);
flushAsynchronousOperations();
// saveReviewedState observer observes params, but should not fire when
- // view !== Gerrit.Nav.View.DIFF.
+ // view !== GerritNav.View.DIFF.
assert.equal(saveReviewedStub.callCount, callCount);
});
@@ -743,7 +745,7 @@
element._loggedIn = true;
element.params = {
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
changeNum: '42',
patchNum: '2',
basePatchNum: '1',
@@ -830,7 +832,7 @@
test('uses the patchNum and basePatchNum ', done => {
element.params = {
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
changeNum: '42',
patchNum: '4',
basePatchNum: '2',
@@ -847,7 +849,7 @@
test('uses the parent when there is no base patch num ', done => {
element.params = {
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
changeNum: '42',
patchNum: '5',
path: '/COMMIT_MSG',
@@ -902,7 +904,7 @@
});
test('_onLineSelected', () => {
- const getUrlStub = sandbox.stub(Gerrit.Nav, 'getUrlForDiffById');
+ const getUrlStub = sandbox.stub(GerritNav, 'getUrlForDiffById');
const replaceStateStub = sandbox.stub(history, 'replaceState');
sandbox.stub(element.$.cursor, 'getAddress')
.returns({number: 123, isLeftSide: false});
@@ -923,7 +925,7 @@
});
test('_onLineSelected w/o line address', () => {
- const getUrlStub = sandbox.stub(Gerrit.Nav, 'getUrlForDiffById');
+ const getUrlStub = sandbox.stub(GerritNav, 'getUrlForDiffById');
sandbox.stub(history, 'replaceState');
sandbox.stub(element.$.cursor, 'moveToLineNumber');
sandbox.stub(element.$.cursor, 'getAddress').returns(null);
@@ -1039,7 +1041,7 @@
setup(() => {
navToChangeStub = sandbox.stub(element, '_navToChangeView');
- navToDiffStub = sandbox.stub(Gerrit.Nav, 'navigateToDiff');
+ navToDiffStub = sandbox.stub(GerritNav, 'navigateToDiff');
element._files = getFilesFromFileList([
'path/one.jpg', 'path/two.m4v', 'path/three.wav',
]);
@@ -1198,7 +1200,7 @@
sandbox.stub(element, '_initCursor');
const setStub = sandbox.stub(element.$.restAPI, 'setInProjectLookup');
element._paramsChanged({
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
changeNum: 101,
project: 'test-project',
path: '',
@@ -1228,25 +1230,25 @@
element._files = getFilesFromFileList(['file1', 'file2', 'file3']);
sandbox.stub(element, '_getLineOfInterest');
sandbox.stub(element, '_initCursor');
- sandbox.stub(Gerrit.Nav, 'navigateToDiff');
+ sandbox.stub(GerritNav, 'navigateToDiff');
// Load file1
element._paramsChanged({
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
patchNum: 1,
changeNum: 101,
project: 'test-project',
path: 'file1',
});
- assert.isTrue(Gerrit.Nav.navigateToDiff.notCalled);
+ assert.isTrue(GerritNav.navigateToDiff.notCalled);
// Switch to file2
element.$.dropdown.value = 'file2';
- assert.isTrue(Gerrit.Nav.navigateToDiff.calledOnce);
+ assert.isTrue(GerritNav.navigateToDiff.calledOnce);
// This is to mock the param change triggered by above navigate
element._paramsChanged({
- view: Gerrit.Nav.View.DIFF,
+ view: GerritNav.View.DIFF,
patchNum: 1,
changeNum: 101,
project: 'test-project',
@@ -1254,7 +1256,7 @@
});
// No extra call
- assert.isTrue(Gerrit.Nav.navigateToDiff.calledOnce);
+ assert.isTrue(GerritNav.navigateToDiff.calledOnce);
});
test('_computeDownloadDropdownLinks', () => {
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js
index 7d4dac8..89491c3 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js
@@ -17,7 +17,6 @@
import '../../../scripts/bundled-polymer.js';
import '@polymer/iron-input/iron-input.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-autocomplete/gr-autocomplete.js';
import '../../shared/gr-button/gr-button.js';
import '../../shared/gr-dialog/gr-dialog.js';
@@ -33,6 +32,7 @@
import {htmlTemplate} from './gr-edit-controls_html.js';
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
import {GrEditConstants} from '../gr-edit-constants.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/**
* @extends Polymer.Element
@@ -208,9 +208,9 @@
}
_handleOpenConfirm(e) {
- const url = Gerrit.Nav.getEditUrlForDiff(this.change, this._path,
+ const url = GerritNav.getEditUrlForDiff(this.change, this._path,
this.patchNum);
- Gerrit.Nav.navigateToRelativeUrl(url);
+ GerritNav.navigateToRelativeUrl(url);
this._closeDialog(this._getDialogFromEvent(e), true);
}
@@ -224,9 +224,9 @@
if (!res.ok) { return; }
this._closeDialog(this.$.openDialog, true);
- const url = Gerrit.Nav.getUrlForChange(
+ const url = GerritNav.getUrlForChange(
this.change, this.patchNum, undefined, true);
- Gerrit.Nav.navigateToRelativeUrl(url);
+ GerritNav.navigateToRelativeUrl(url);
});
}
@@ -238,7 +238,7 @@
.then(res => {
if (!res.ok) { return; }
this._closeDialog(dialog, true);
- Gerrit.Nav.navigateToChange(this.change);
+ GerritNav.navigateToChange(this.change);
});
}
@@ -248,7 +248,7 @@
.then(res => {
if (!res.ok) { return; }
this._closeDialog(dialog, true);
- Gerrit.Nav.navigateToChange(this.change);
+ GerritNav.navigateToChange(this.change);
});
}
@@ -258,7 +258,7 @@
this._path, this._newPath).then(res => {
if (!res.ok) { return; }
this._closeDialog(dialog, true);
- Gerrit.Nav.navigateToChange(this.change);
+ GerritNav.navigateToChange(this.change);
});
}
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.html b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.html
index 262fd50..4b35d1b 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.html
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.html
@@ -34,6 +34,8 @@
import './gr-edit-controls.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-edit-controls tests', () => {
let element;
let sandbox;
@@ -69,8 +71,8 @@
setup(() => {
navStubs = [
- sandbox.stub(Gerrit.Nav, 'getEditUrlForDiff'),
- sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl'),
+ sandbox.stub(GerritNav, 'getEditUrlForDiff'),
+ sandbox.stub(GerritNav, 'navigateToRelativeUrl'),
];
openAutoCcmplete = element.$.openDialog.querySelector('gr-autocomplete');
});
@@ -100,7 +102,7 @@
MockInteractions.tap(element.$.openDialog.shadowRoot
.querySelector('gr-button[primary]'));
for (const stub of navStubs) { assert.isTrue(stub.called); }
- assert.deepEqual(Gerrit.Nav.getEditUrlForDiff.lastCall.args,
+ assert.deepEqual(GerritNav.getEditUrlForDiff.lastCall.args,
[element.change, 'src/test.cpp', element.patchNum]);
assert.isTrue(closeDialogSpy.called);
});
@@ -128,7 +130,7 @@
let deleteAutocomplete;
setup(() => {
- navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ navStub = sandbox.stub(GerritNav, 'navigateToChange');
deleteStub = sandbox.stub(element.$.restAPI, 'deleteFileInChangeEdit');
deleteAutocomplete =
element.$.deleteDialog.querySelector('gr-autocomplete');
@@ -212,7 +214,7 @@
'.newPathInput';
setup(() => {
- navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ navStub = sandbox.stub(GerritNav, 'navigateToChange');
renameStub = sandbox.stub(element.$.restAPI, 'renameFileInChangeEdit');
renameAutocomplete =
element.$.renameDialog.querySelector('gr-autocomplete');
@@ -305,7 +307,7 @@
let restoreStub;
setup(() => {
- navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ navStub = sandbox.stub(GerritNav, 'navigateToChange');
restoreStub = sandbox.stub(element.$.restAPI, 'restoreFileInChangeEdit');
});
diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js
index 0cc3fe6..d2ffa56 100644
--- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js
+++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js
@@ -16,7 +16,6 @@
*/
import '../../../scripts/bundled-polymer.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator.js';
import '../../plugins/gr-endpoint-param/gr-endpoint-param.js';
import '../../shared/gr-button/gr-button.js';
@@ -34,6 +33,7 @@
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
import {PathListBehavior} from '../../../behaviors/gr-path-list-behavior/gr-path-list-behavior.js';
import {KeyboardShortcutBehavior} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const RESTORED_MESSAGE = 'Content restored from a previous edit.';
const SAVING_MESSAGE = 'Saving changes...';
@@ -135,7 +135,7 @@
}
_paramsChanged(value) {
- if (value.view !== Gerrit.Nav.View.EDIT) {
+ if (value.view !== GerritNav.View.EDIT) {
return;
}
@@ -185,7 +185,7 @@
_viewEditInChangeView() {
const patch = this._successfulSave ? this.EDIT_NAME : this._patchNum;
- Gerrit.Nav.navigateToChange(this._change, patch, null,
+ GerritNav.navigateToChange(this._change, patch, null,
patch !== this.EDIT_NAME);
}
diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view_test.html b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view_test.html
index 4659065..79fbfd00 100644
--- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view_test.html
+++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view_test.html
@@ -32,6 +32,8 @@
<script type="module">
import '../../../test/common-test-setup.js';
import './gr-editor-view.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-editor-view tests', () => {
let element;
let sandbox;
@@ -63,7 +65,7 @@
suite('_paramsChanged', () => {
test('incorrect view returns immediately', () => {
element._paramsChanged(
- Object.assign({}, mockParams, {view: Gerrit.Nav.View.DIFF}));
+ Object.assign({}, mockParams, {view: GerritNav.View.DIFF}));
assert.notOk(element._changeNum);
});
@@ -76,7 +78,7 @@
});
const promises = element._paramsChanged(
- Object.assign({}, mockParams, {view: Gerrit.Nav.View.EDIT}));
+ Object.assign({}, mockParams, {view: GerritNav.View.EDIT}));
flushAsynchronousOperations();
assert.equal(element._changeNum, mockParams.changeNum);
@@ -296,7 +298,7 @@
test('_viewEditInChangeView respects _patchNum', () => {
navigateStub.restore();
- const navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
+ const navStub = sandbox.stub(GerritNav, 'navigateToChange');
element._patchNum = element.EDIT_NAME;
element._viewEditInChangeView();
assert.equal(navStub.lastCall.args[1], element.EDIT_NAME);
diff --git a/polygerrit-ui/app/elements/gr-app-element.js b/polygerrit-ui/app/elements/gr-app-element.js
index 56d0a6d..53c1e54 100644
--- a/polygerrit-ui/app/elements/gr-app-element.js
+++ b/polygerrit-ui/app/elements/gr-app-element.js
@@ -25,7 +25,6 @@
import './core/gr-error-manager/gr-error-manager.js';
import './core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.js';
import './core/gr-main-header/gr-main-header.js';
-import './core/gr-navigation/gr-navigation.js';
import './core/gr-reporting/gr-reporting.js';
import './core/gr-router/gr-router.js';
import './core/gr-smart-search/gr-smart-search.js';
@@ -48,6 +47,7 @@
import {htmlTemplate} from './gr-app-element_html.js';
import {BaseUrlBehavior} from '../behaviors/base-url-behavior/base-url-behavior.js';
import {KeyboardShortcutBehavior} from '../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
+import {GerritNav} from './core/gr-navigation/gr-navigation.js';
/**
* @extends Polymer.Element
@@ -202,7 +202,7 @@
// Note: this is evaluated here to ensure that it only happens after the
// router has been initialized. @see Issue 7837
- this._settingsUrl = Gerrit.Nav.getUrlForSettings();
+ this._settingsUrl = GerritNav.getUrlForSettings();
this._viewState = {
changeView: {
@@ -374,16 +374,16 @@
_viewChanged(view) {
this.$.errorView.classList.remove('show');
- this.set('_showChangeListView', view === Gerrit.Nav.View.SEARCH);
- this.set('_showDashboardView', view === Gerrit.Nav.View.DASHBOARD);
- this.set('_showChangeView', view === Gerrit.Nav.View.CHANGE);
- this.set('_showDiffView', view === Gerrit.Nav.View.DIFF);
- this.set('_showSettingsView', view === Gerrit.Nav.View.SETTINGS);
- this.set('_showAdminView', view === Gerrit.Nav.View.ADMIN ||
- view === Gerrit.Nav.View.GROUP || view === Gerrit.Nav.View.REPO);
- this.set('_showCLAView', view === Gerrit.Nav.View.AGREEMENTS);
- this.set('_showEditorView', view === Gerrit.Nav.View.EDIT);
- const isPluginScreen = view === Gerrit.Nav.View.PLUGIN_SCREEN;
+ this.set('_showChangeListView', view === GerritNav.View.SEARCH);
+ this.set('_showDashboardView', view === GerritNav.View.DASHBOARD);
+ this.set('_showChangeView', view === GerritNav.View.CHANGE);
+ this.set('_showDiffView', view === GerritNav.View.DIFF);
+ this.set('_showSettingsView', view === GerritNav.View.SETTINGS);
+ this.set('_showAdminView', view === GerritNav.View.ADMIN ||
+ view === GerritNav.View.GROUP || view === GerritNav.View.REPO);
+ this.set('_showCLAView', view === GerritNav.View.AGREEMENTS);
+ this.set('_showEditorView', view === GerritNav.View.EDIT);
+ const isPluginScreen = view === GerritNav.View.PLUGIN_SCREEN;
this.set('_showPluginScreen', false);
// Navigation within plugin screens does not restamp gr-endpoint-decorator
// because _showPluginScreen value does not change. To force restamp,
@@ -392,7 +392,7 @@
this.async(() => this.set('_showPluginScreen', true), 1);
}
this.set('_showDocumentationSearch',
- view === Gerrit.Nav.View.DOCUMENTATION_SEARCH);
+ view === GerritNav.View.DOCUMENTATION_SEARCH);
if (this.params.justRegistered) {
this.$.registrationOverlay.open();
this.$.registrationDialog.loadData().then(() => {
@@ -476,7 +476,7 @@
_paramsChanged(paramsRecord) {
const params = paramsRecord.base;
- const viewsToCheck = [Gerrit.Nav.View.SEARCH, Gerrit.Nav.View.DASHBOARD];
+ const viewsToCheck = [GerritNav.View.SEARCH, GerritNav.View.DASHBOARD];
if (viewsToCheck.includes(params.view)) {
this.set('_lastSearchPage', location.pathname);
}
@@ -507,7 +507,7 @@
_handleAccountDetailUpdate(e) {
this.$.mainHeader.reload();
- if (this.params.view === Gerrit.Nav.View.SETTINGS) {
+ if (this.params.view === GerritNav.View.SETTINGS) {
this.shadowRoot.querySelector('gr-settings-view').reloadAccountDetail();
}
}
@@ -518,24 +518,24 @@
}
_goToOpenedChanges() {
- Gerrit.Nav.navigateToStatusSearch('open');
+ GerritNav.navigateToStatusSearch('open');
}
_goToUserDashboard() {
- Gerrit.Nav.navigateToUserDashboard();
+ GerritNav.navigateToUserDashboard();
}
_goToMergedChanges() {
- Gerrit.Nav.navigateToStatusSearch('merged');
+ GerritNav.navigateToStatusSearch('merged');
}
_goToAbandonedChanges() {
- Gerrit.Nav.navigateToStatusSearch('abandoned');
+ GerritNav.navigateToStatusSearch('abandoned');
}
_goToWatchedChanges() {
// The query is hardcoded, and doesn't respect custom menu entries
- Gerrit.Nav.navigateToSearchQuery('is:watched is:open');
+ GerritNav.navigateToSearchQuery('is:watched is:open');
}
_computePluginScreenName({plugin, screen}) {
diff --git a/polygerrit-ui/app/elements/gr-app-global-var-init.js b/polygerrit-ui/app/elements/gr-app-global-var-init.js
index 5369102..f928c5b 100644
--- a/polygerrit-ui/app/elements/gr-app-global-var-init.js
+++ b/polygerrit-ui/app/elements/gr-app-global-var-init.js
@@ -73,6 +73,7 @@
PRELOADED_PROTOCOL,
send,
} from './shared/gr-js-api-interface/gr-api-utils.js';
+import {GerritNav} from './core/gr-navigation/gr-navigation.js';
export function initGlobalVariables() {
window.GrDisplayNameUtils = GrDisplayNameUtils;
@@ -130,4 +131,7 @@
PRELOADED_PROTOCOL,
PLUGIN_LOADING_TIMEOUT_MS,
};
+
+ window.Gerrit = window.Gerrit || {};
+ window.Gerrit.Nav = GerritNav;
}
diff --git a/polygerrit-ui/app/elements/gr-app_test.html b/polygerrit-ui/app/elements/gr-app_test.html
index 71ebaa7..c65edb0 100644
--- a/polygerrit-ui/app/elements/gr-app_test.html
+++ b/polygerrit-ui/app/elements/gr-app_test.html
@@ -33,6 +33,8 @@
<script type="module">
import '../test/common-test-setup.js';
import './gr-app.js';
+import {GerritNav} from './core/gr-navigation/gr-navigation.js';
+
suite('gr-app tests', () => {
let sandbox;
let element;
@@ -95,9 +97,9 @@
});
test('_paramsChanged sets search page', () => {
- appElement()._paramsChanged({base: {view: Gerrit.Nav.View.CHANGE}});
+ appElement()._paramsChanged({base: {view: GerritNav.View.CHANGE}});
assert.notOk(appElement()._lastSearchPage);
- appElement()._paramsChanged({base: {view: Gerrit.Nav.View.SEARCH}});
+ appElement()._paramsChanged({base: {view: GerritNav.View.SEARCH}});
assert.ok(appElement()._lastSearchPage);
});
});
diff --git a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js
index 01739cd..1cc1369 100644
--- a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js
+++ b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js
@@ -18,12 +18,12 @@
import '../../../styles/shared-styles.js';
import '../../../styles/gr-form-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-group-list_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/** @extends Polymer.Element */
class GrGroupList extends GestureEventListeners(
@@ -54,7 +54,7 @@
// Group ID is already encoded from the API
// Decode it here to match with our router encoding behavior
- return Gerrit.Nav.getUrlForGroup(decodeURIComponent(group.id));
+ return GerritNav.getUrlForGroup(decodeURIComponent(group.id));
}
}
diff --git a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list_test.html b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list_test.html
index 52a3edc..0d24948 100644
--- a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list_test.html
+++ b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list_test.html
@@ -34,6 +34,8 @@
import '../../../test/common-test-setup.js';
import './gr-group-list.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-group-list tests', () => {
let sandbox;
let element;
@@ -92,7 +94,7 @@
});
test('_computeGroupPath', () => {
- sandbox.stub(Gerrit.Nav, 'getUrlForGroup',
+ sandbox.stub(GerritNav, 'getUrlForGroup',
() => '/admin/groups/e2cd66f88a2db4d391ac068a92d987effbe872f5');
let group = {
diff --git a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js
index 1972715..6635de2 100644
--- a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js
+++ b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js
@@ -18,7 +18,6 @@
import '@polymer/iron-input/iron-input.js';
import '../../../styles/gr-form-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../shared/gr-button/gr-button.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import '../../../styles/shared-styles.js';
diff --git a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.js b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.js
index ca37659..27de4b3 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.js
+++ b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.js
@@ -16,7 +16,6 @@
*/
import '../../../scripts/bundled-polymer.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../gr-account-label/gr-account-label.js';
import '../../../styles/shared-styles.js';
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
@@ -25,6 +24,7 @@
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-account-link_html.js';
import {BaseUrlBehavior} from '../../../behaviors/base-url-behavior/base-url-behavior.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/**
* @extends Polymer.Element
@@ -59,7 +59,7 @@
_computeOwnerLink(account) {
if (!account) { return; }
- return Gerrit.Nav.getUrlForOwner(
+ return GerritNav.getUrlForOwner(
account.email || account.username || account.name ||
account._account_id);
}
diff --git a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link_test.html b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link_test.html
index dc9cbda..aa1c575 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link_test.html
@@ -33,6 +33,8 @@
<script type="module">
import '../../../test/common-test-setup.js';
import './gr-account-link.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-account-link tests', () => {
let element;
let sandbox;
@@ -51,7 +53,7 @@
test('computed fields', () => {
const url = 'test/url';
- const urlStub = sandbox.stub(Gerrit.Nav, 'getUrlForOwner').returns(url);
+ const urlStub = sandbox.stub(GerritNav, 'getUrlForOwner').returns(url);
const account = {
email: 'email',
username: 'username',
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js
index e352d81..f4e4d80 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js
@@ -17,7 +17,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import '../../core/gr-reporting/gr-reporting.js';
import '../gr-rest-api-interface/gr-rest-api-interface.js';
import '../gr-storage/gr-storage.js';
@@ -31,6 +30,7 @@
import {PathListBehavior} from '../../../behaviors/gr-path-list-behavior/gr-path-list-behavior.js';
import {KeyboardShortcutBehavior} from '../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js';
import {util} from '../../../scripts/util.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
const UNRESOLVED_EXPAND_COUNT = 5;
const NEWLINE_PATTERN = /\n/g;
@@ -218,7 +218,7 @@
}
_getDiffUrlForComment(projectName, changeNum, path, patchNum) {
- return Gerrit.Nav.getUrlForDiffById(changeNum,
+ return GerritNav.getUrlForDiffById(changeNum,
projectName, path, patchNum,
null, this.lineNum);
}
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html
index f1fe07a..d7c493c 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html
@@ -40,6 +40,8 @@
import '../../../test/common-test-setup.js';
import './gr-comment-thread.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-comment-thread tests', () => {
suite('basic test', () => {
let element;
@@ -199,7 +201,7 @@
assert.isNotOk(element.shadowRoot
.querySelector('.pathInfo'));
- sandbox.stub(Gerrit.Nav, 'getUrlForDiffById');
+ sandbox.stub(GerritNav, 'getUrlForDiffById');
element.changeNum = 123;
element.projectName = 'test project';
element.path = 'path/to/file';
@@ -212,7 +214,7 @@
assert.notEqual(getComputedStyle(element.shadowRoot
.querySelector('.pathInfo')).display,
'none');
- assert.isTrue(Gerrit.Nav.getUrlForDiffById.lastCall.calledWithExactly(
+ assert.isTrue(GerritNav.getUrlForDiffById.lastCall.calledWithExactly(
element.changeNum, element.projectName, element.path,
element.patchNum, null, element.lineNum));
});
diff --git a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js
index ad9b852..2c5589f 100644
--- a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js
+++ b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js
@@ -29,6 +29,7 @@
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-label-info_html.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/** @extends Polymer.Element */
class GrLabelInfo extends GestureEventListeners(
@@ -148,7 +149,7 @@
.then(response => {
target.disabled = false;
if (!response.ok) { return; }
- Gerrit.Nav.navigateToChange(this.change);
+ GerritNav.navigateToChange(this.change);
})
.catch(err => {
target.disabled = false;
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.js b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.js
index 7e55652..6ea4b78 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.js
+++ b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.js
@@ -17,7 +17,6 @@
import '../../../scripts/bundled-polymer.js';
import '../../../styles/shared-styles.js';
-import '../../core/gr-navigation/gr-navigation.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
@@ -25,6 +24,7 @@
import 'ba-linkify/ba-linkify.js';
import {htmlTemplate} from './gr-linked-text_html.js';
import {GrLinkTextParser} from './link-text-parser.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
/** @extends Polymer.Element */
class GrLinkedText extends GestureEventListeners(
@@ -79,8 +79,8 @@
* commentLink patterns
*/
_contentOrConfigChanged(content, config) {
- if (!Gerrit.Nav || !Gerrit.Nav.mapCommentlinks) return;
- config = Gerrit.Nav.mapCommentlinks(config);
+ if (!GerritNav.mapCommentlinks) return;
+ config = GerritNav.mapCommentlinks(config);
const output = dom(this.$.output);
output.textContent = '';
const parser = new GrLinkTextParser(config,
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text_test.html b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text_test.html
index 86dfd62..6e46df1 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text_test.html
@@ -36,6 +36,8 @@
import '../../../test/common-test-setup.js';
import './gr-linked-text.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
suite('gr-linked-text tests', () => {
let element;
let sandbox;
@@ -43,7 +45,7 @@
setup(() => {
element = fixture('basic');
sandbox = sinon.sandbox.create();
- sandbox.stub(Gerrit.Nav, 'mapCommentlinks', x => x);
+ sandbox.stub(GerritNav, 'mapCommentlinks', x => x);
element.config = {
ph: {
match: '([Bb]ug|[Ii]ssue)\\s*#?(\\d+)',
diff --git a/polygerrit-ui/app/test/test-router.js b/polygerrit-ui/app/test/test-router.js
index 914537c..9b89744 100644
--- a/polygerrit-ui/app/test/test-router.js
+++ b/polygerrit-ui/app/test/test-router.js
@@ -14,6 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import '../elements/core/gr-navigation/gr-navigation.js';
+import {GerritNav} from '../elements/core/gr-navigation/gr-navigation.js';
-Gerrit.Nav.setup(url => { /* noop */ }, params => '', () => []);
+GerritNav.setup(url => { /* noop */ }, params => '', () => []);