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
This commit is contained in:
@@ -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 @@ export const AdminNavBehavior = {
|
||||
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 @@ export const AdminNavBehavior = {
|
||||
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),
|
||||
}],
|
||||
};
|
||||
},
|
||||
|
@@ -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-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 {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
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 @@ class GrAdminGroupList extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_computeGroupUrl(id) {
|
||||
return Gerrit.Nav.getUrlForGroup(id);
|
||||
return GerritNav.getUrlForGroup(id);
|
||||
}
|
||||
|
||||
_getCreateGroupCapability() {
|
||||
|
@@ -18,7 +18,6 @@ import '../../../scripts/bundled-polymer.js';
|
||||
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 {htmlTemplate} from './gr-admin-view_html.js';
|
||||
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 @@ class GrAdminView extends mixinBehaviors( [
|
||||
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 @@ class GrAdminView extends mixinBehaviors( [
|
||||
// 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 '';
|
||||
|
@@ -34,6 +34,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-admin-view tests', () => {
|
||||
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 @@ suite('gr-admin-view tests', () => {
|
||||
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 @@ suite('gr-admin-view tests', () => {
|
||||
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 @@ suite('gr-admin-view tests', () => {
|
||||
);
|
||||
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 @@ suite('gr-admin-view tests', () => {
|
||||
|
||||
test('repo list', () => {
|
||||
element.params = {
|
||||
view: Gerrit.Nav.View.ADMIN,
|
||||
view: GerritNav.View.ADMIN,
|
||||
adminView: 'gr-repo-list',
|
||||
openCreateModal: false,
|
||||
};
|
||||
@@ -537,7 +539,7 @@ suite('gr-admin-view tests', () => {
|
||||
|
||||
test('repo', () => {
|
||||
element.params = {
|
||||
view: Gerrit.Nav.View.REPO,
|
||||
view: GerritNav.View.REPO,
|
||||
repoName: 'foo',
|
||||
};
|
||||
element._repoName = 'foo';
|
||||
@@ -552,8 +554,8 @@ suite('gr-admin-view tests', () => {
|
||||
|
||||
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 @@ suite('gr-admin-view tests', () => {
|
||||
|
||||
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 @@ suite('gr-admin-view tests', () => {
|
||||
|
||||
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 @@ suite('gr-admin-view tests', () => {
|
||||
|
||||
test('internal group', () => {
|
||||
element.params = {
|
||||
view: Gerrit.Nav.View.GROUP,
|
||||
view: GerritNav.View.GROUP,
|
||||
groupId: 1234,
|
||||
};
|
||||
element._groupName = 'foo';
|
||||
@@ -642,7 +644,7 @@ suite('gr-admin-view tests', () => {
|
||||
id: 'external-id',
|
||||
}));
|
||||
element.params = {
|
||||
view: Gerrit.Nav.View.GROUP,
|
||||
view: GerritNav.View.GROUP,
|
||||
groupId: 1234,
|
||||
};
|
||||
element._groupName = 'foo';
|
||||
@@ -661,8 +663,8 @@ suite('gr-admin-view tests', () => {
|
||||
|
||||
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';
|
||||
|
@@ -20,7 +20,6 @@ import '@polymer/iron-input/iron-input.js';
|
||||
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 {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
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 @@ class GrCreateChangeDialog extends mixinBehaviors( [
|
||||
this.baseCommit || null)
|
||||
.then(changeCreated => {
|
||||
if (!changeCreated) { return; }
|
||||
Gerrit.Nav.navigateToChange(changeCreated);
|
||||
GerritNav.navigateToChange(changeCreated);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -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 {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
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 @@ class GrGroupAuditLog extends mixinBehaviors( [
|
||||
|
||||
_computeGroupUrl(group) {
|
||||
if (group && group.url && group.id) {
|
||||
return Gerrit.Nav.getUrlForGroup(group.id);
|
||||
return GerritNav.getUrlForGroup(group.id);
|
||||
}
|
||||
|
||||
return '';
|
||||
|
@@ -19,7 +19,6 @@ import '../../../scripts/bundled-polymer.js';
|
||||
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 {htmlTemplate} from './gr-repo-access_html.js';
|
||||
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 @@ class GrRepoAccess extends mixinBehaviors( [
|
||||
return this.$.restAPI
|
||||
.setRepoAccessRightsForReview(this.repo, obj)
|
||||
.then(change => {
|
||||
Gerrit.Nav.navigateToChange(change);
|
||||
GerritNav.navigateToChange(change);
|
||||
})
|
||||
.finally(() => {
|
||||
this._modified = false;
|
||||
|
@@ -35,6 +35,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-repo-access tests', () => {
|
||||
};
|
||||
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 @@ suite('gr-repo-access tests', () => {
|
||||
resolver({_number: 1});
|
||||
flush(() => {
|
||||
assert.isTrue(saveStub.called);
|
||||
assert.isTrue(Gerrit.Nav.navigateToChange.notCalled);
|
||||
assert.isTrue(GerritNav.navigateToChange.notCalled);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -1226,7 +1228,7 @@ suite('gr-repo-access tests', () => {
|
||||
};
|
||||
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 @@ suite('gr-repo-access tests', () => {
|
||||
resolver({_number: 1});
|
||||
flush(() => {
|
||||
assert.isTrue(saveForReviewStub.called);
|
||||
assert.isTrue(Gerrit.Nav.navigateToChange
|
||||
assert.isTrue(GerritNav.navigateToChange
|
||||
.lastCall.calledWithExactly({_number: 1}));
|
||||
done();
|
||||
});
|
||||
|
@@ -31,6 +31,7 @@ import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-l
|
||||
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 @@ class GrRepoCommands extends GestureEventListeners(
|
||||
{detail: {message}, bubbles: true, composed: true}));
|
||||
if (!change) { return; }
|
||||
|
||||
Gerrit.Nav.navigateToRelativeUrl(Gerrit.Nav.getEditUrlForDiff(
|
||||
GerritNav.navigateToRelativeUrl(GerritNav.getEditUrlForDiff(
|
||||
change, CONFIG_PATH, INITIAL_PATCHSET));
|
||||
});
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@ limitations under the License.
|
||||
<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 @@ suite('gr-repo-commands tests', () => {
|
||||
|
||||
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);
|
||||
|
@@ -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 @@ class GrRepoDashboards extends GestureEventListeners(
|
||||
_getUrl(project, id) {
|
||||
if (!project || !id) { return ''; }
|
||||
|
||||
return Gerrit.Nav.getUrlForRepoDashboard(project, id);
|
||||
return GerritNav.getUrlForRepoDashboard(project, id);
|
||||
}
|
||||
|
||||
_computeLoadingClass(loading) {
|
||||
|
@@ -33,6 +33,8 @@ limitations under the License.
|
||||
<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('gr-repo-dashboards tests', () => {
|
||||
|
||||
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');
|
||||
|
@@ -29,6 +29,7 @@ import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
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 @@ class GrRepoList extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_computeChangesLink(name) {
|
||||
return Gerrit.Nav.getUrlForProjectChanges(name);
|
||||
return GerritNav.getUrlForProjectChanges(name);
|
||||
}
|
||||
|
||||
_getCreateRepoCapability() {
|
||||
|
@@ -31,6 +31,7 @@ import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-l
|
||||
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 @@ class GrRepo extends GestureEventListeners(
|
||||
}
|
||||
|
||||
_computeChangesUrl(name) {
|
||||
return Gerrit.Nav.getUrlForProjectChanges(name);
|
||||
return GerritNav.getUrlForProjectChanges(name);
|
||||
}
|
||||
|
||||
_handlePluginConfigChanged({detail: {name, config, notifyPath}}) {
|
||||
|
@@ -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 {ChangeTableBehavior} from '../../../behaviors/gr-change-table-behavior/g
|
||||
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 @@ class GrChangeListItem extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_computeChangeURL(change) {
|
||||
return Gerrit.Nav.getUrlForChange(change);
|
||||
return GerritNav.getUrlForChange(change);
|
||||
}
|
||||
|
||||
_computeLabelTitle(change, labelName) {
|
||||
@@ -166,18 +166,18 @@ class GrChangeListItem extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -33,6 +33,8 @@ limitations under the License.
|
||||
<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 @@ suite('gr-change-list-item tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-change-list-item tests', () => {
|
||||
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]);
|
||||
});
|
||||
|
||||
|
@@ -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 {htmlTemplate} from './gr-change-list-view_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 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 @@ class GrChangeListView extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_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 @@ class GrChangeListView extends mixinBehaviors( [
|
||||
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 @@ class GrChangeListView extends mixinBehaviors( [
|
||||
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) {
|
||||
|
@@ -35,6 +35,7 @@ limitations under the License.
|
||||
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 @@ suite('gr-change-list-view tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-change-list-view tests', () => {
|
||||
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 @@ suite('gr-change-list-view tests', () => {
|
||||
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);
|
||||
|
@@ -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 {ChangeTableBehavior} from '../../../behaviors/gr-change-table-behavior/g
|
||||
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 @@ class GrChangeList extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_sectionHref(query) {
|
||||
return Gerrit.Nav.getUrlForSearchQuery(this._processQuery(query));
|
||||
return GerritNav.getUrlForSearchQuery(this._processQuery(query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,7 +333,7 @@ class GrChangeList extends mixinBehaviors( [
|
||||
this.modifierPressed(e)) { return; }
|
||||
|
||||
e.preventDefault();
|
||||
Gerrit.Nav.navigateToChange(this._changeForIndex(this.selectedIndex));
|
||||
GerritNav.navigateToChange(this._changeForIndex(this.selectedIndex));
|
||||
}
|
||||
|
||||
_nextPage(e) {
|
||||
|
@@ -43,6 +43,8 @@ import './gr-change-list.js';
|
||||
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 @@ suite('gr-change-list basic tests', () => {
|
||||
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 @@ suite('gr-change-list basic tests', () => {
|
||||
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'
|
||||
|
@@ -33,6 +33,7 @@ import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
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 @@ class GrDashboardView extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_isViewActive(params) {
|
||||
return params.view === Gerrit.Nav.View.DASHBOARD;
|
||||
return params.view === GerritNav.View.DASHBOARD;
|
||||
}
|
||||
|
||||
_paramsChanged(paramsChangeRecord) {
|
||||
@@ -178,7 +179,7 @@ class GrDashboardView extends mixinBehaviors( [
|
||||
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 @@ class GrDashboardView extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_computeDraftsLink() {
|
||||
return Gerrit.Nav.getUrlForSearchQuery('has:draft -is:open');
|
||||
return GerritNav.getUrlForSearchQuery('has:draft -is:open');
|
||||
}
|
||||
|
||||
_createChangeTap(e) {
|
||||
|
@@ -34,6 +34,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-dashboard-view tests', () => {
|
||||
|
||||
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('gr-dashboard-view tests', () => {
|
||||
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 @@ suite('gr-dashboard-view tests', () => {
|
||||
|
||||
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 @@ suite('gr-dashboard-view tests', () => {
|
||||
|
||||
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 @@ suite('gr-dashboard-view tests', () => {
|
||||
done();
|
||||
});
|
||||
element.params = {
|
||||
view: Gerrit.Nav.View.DASHBOARD,
|
||||
view: GerritNav.View.DASHBOARD,
|
||||
project: 'project',
|
||||
dashboard: 'dashboard',
|
||||
};
|
||||
@@ -366,7 +368,7 @@ suite('gr-dashboard-view tests', () => {
|
||||
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',
|
||||
};
|
||||
|
@@ -18,13 +18,13 @@ import '../../../scripts/bundled-polymer.js';
|
||||
|
||||
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 @@ class GrRepoHeader extends GestureEventListeners(
|
||||
this._repoUrl = null;
|
||||
return;
|
||||
}
|
||||
this._repoUrl = Gerrit.Nav.getUrlForRepo(repoName);
|
||||
this._repoUrl = GerritNav.getUrlForRepo(repoName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,8 @@ limitations under the License.
|
||||
<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 @@ suite('gr-repo-header tests', () => {
|
||||
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);
|
||||
|
@@ -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 {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-l
|
||||
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 @@ class GrUserHeader extends GestureEventListeners(
|
||||
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) {
|
||||
|
@@ -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 {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
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 @@ class GrChangeActions extends mixinBehaviors( [
|
||||
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 @@ class GrChangeActions extends mixinBehaviors( [
|
||||
action: 'Reload',
|
||||
callback: () => {
|
||||
// Load the current change without any patch range.
|
||||
Gerrit.Nav.navigateToChange(this.change);
|
||||
GerritNav.navigateToChange(this.change);
|
||||
},
|
||||
},
|
||||
composed: true, bubbles: true,
|
||||
|
@@ -34,6 +34,7 @@ limitations under the License.
|
||||
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 @@ suite('gr-change-actions tests', () => {
|
||||
.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 @@ suite('gr-change-actions tests', () => {
|
||||
.returns(Promise.resolve({revert_changes: [
|
||||
{change_id: 12345},
|
||||
]}));
|
||||
navigateToSearchQueryStub = sandbox.stub(Gerrit.Nav,
|
||||
navigateToSearchQueryStub = sandbox.stub(GerritNav,
|
||||
'navigateToSearchQuery');
|
||||
});
|
||||
|
||||
@@ -1891,7 +1892,7 @@ suite('gr-change-actions tests', () => {
|
||||
{change_id: 23456, topic: 'T'},
|
||||
]}));
|
||||
showActionDialogStub = sandbox.stub(element, '_showActionDialog');
|
||||
navigateToSearchQueryStub = sandbox.stub(Gerrit.Nav,
|
||||
navigateToSearchQueryStub = sandbox.stub(GerritNav,
|
||||
'navigateToSearchQuery');
|
||||
});
|
||||
|
||||
|
@@ -20,7 +20,6 @@ import '../../../styles/shared-styles.js';
|
||||
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 {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
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 @@ class GrChangeMetadata extends mixinBehaviors( [
|
||||
*/
|
||||
_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 @@ class GrChangeMetadata extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_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) {
|
||||
|
@@ -34,6 +34,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-change-metadata tests', () => {
|
||||
.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 @@ suite('gr-change-metadata tests', () => {
|
||||
|
||||
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 @@ suite('gr-change-metadata tests', () => {
|
||||
|
||||
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 = {
|
||||
|
@@ -18,7 +18,6 @@ import '../../../scripts/bundled-polymer.js';
|
||||
|
||||
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 {RESTClientBehavior} from '../../../behaviors/rest-client-behavior/rest-c
|
||||
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 @@ class GrChangeView extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_paramsChanged(value) {
|
||||
if (value.view !== Gerrit.Nav.View.CHANGE) {
|
||||
if (value.view !== GerritNav.View.CHANGE) {
|
||||
this._initialLoadComplete = false;
|
||||
return;
|
||||
}
|
||||
@@ -1132,7 +1132,7 @@ class GrChangeView extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrChangeView extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_computeChangeUrl(change) {
|
||||
return Gerrit.Nav.getUrlForChange(change);
|
||||
return GerritNav.getUrlForChange(change);
|
||||
}
|
||||
|
||||
_computeShowCommitInfo(changeStatus, current_revision) {
|
||||
@@ -1403,7 +1403,7 @@ class GrChangeView extends mixinBehaviors( [
|
||||
_handleRefreshChange(e) {
|
||||
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
||||
e.preventDefault();
|
||||
Gerrit.Nav.navigateToChange(this._change);
|
||||
GerritNav.navigateToChange(this._change);
|
||||
}
|
||||
|
||||
_handleToggleChangeStar(e) {
|
||||
@@ -1451,8 +1451,8 @@ class GrChangeView extends mixinBehaviors( [
|
||||
_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 @@ class GrChangeView extends mixinBehaviors( [
|
||||
// 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 @@ class GrChangeView extends mixinBehaviors( [
|
||||
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 @@ class GrChangeView extends mixinBehaviors( [
|
||||
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 @@ class GrChangeView extends mixinBehaviors( [
|
||||
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 @@ class GrChangeView extends mixinBehaviors( [
|
||||
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() {
|
||||
|
@@ -48,6 +48,7 @@ import {KeyboardShortcutBinder} from '../../../behaviors/keyboard-shortcut-behav
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
});
|
||||
// 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 @@ suite('gr-change-view tests', () => {
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
// view is required
|
||||
element.params = Object.assign(
|
||||
{
|
||||
view: Gerrit.Nav.View.CHANGE,
|
||||
view: GerritNav.View.CHANGE,
|
||||
},
|
||||
element.params, {queryMap});
|
||||
flush(() => {
|
||||
@@ -407,7 +408,7 @@ suite('gr-change-view tests', () => {
|
||||
// view is required
|
||||
element.params = Object.assign(
|
||||
{
|
||||
view: Gerrit.Nav.View.CHANGE,
|
||||
view: GerritNav.View.CHANGE,
|
||||
},
|
||||
element.params, {queryMap});
|
||||
flush(() => {
|
||||
@@ -441,16 +442,16 @@ suite('gr-change-view tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
};
|
||||
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
() => 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 @@ suite('gr-change-view tests', () => {
|
||||
},
|
||||
current_revision: 'rev3',
|
||||
};
|
||||
sandbox.stub(Gerrit.Nav, 'getUrlForChange')
|
||||
sandbox.stub(GerritNav, 'getUrlForChange')
|
||||
.returns('/change/123');
|
||||
assert.equal(
|
||||
element._computeCopyTextForTitle(change),
|
||||
@@ -1641,7 +1642,7 @@ suite('gr-change-view tests', () => {
|
||||
|
||||
// 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 @@ suite('gr-change-view tests', () => {
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
}));
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
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 @@ suite('gr-change-view tests', () => {
|
||||
const changeFullyLoadedStub =
|
||||
sandbox.stub(element.$.reporting, 'changeFullyLoaded');
|
||||
element._paramsChanged({
|
||||
view: Gerrit.Nav.View.CHANGE,
|
||||
view: GerritNav.View.CHANGE,
|
||||
changeNum: 101,
|
||||
project: 'test-project',
|
||||
});
|
||||
|
@@ -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 {htmlTemplate} from './gr-comment-list_html.js';
|
||||
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 @@ class GrCommentList extends mixinBehaviors( [
|
||||
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));
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-comment-list tests', () => {
|
||||
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 @@ suite('gr-comment-list tests', () => {
|
||||
});
|
||||
|
||||
test('_computeDiffLineURL', () => {
|
||||
const getUrlStub = sandbox.stub(Gerrit.Nav, 'getUrlForDiffById');
|
||||
const getUrlStub = sandbox.stub(GerritNav, 'getUrlForDiffById');
|
||||
element.projectName = 'proj';
|
||||
element.changeNum = 123;
|
||||
|
||||
|
@@ -22,6 +22,7 @@ import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-l
|
||||
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 @@ class GrCommitInfo extends GestureEventListeners(
|
||||
}
|
||||
|
||||
_getWeblink(change, commitInfo, config) {
|
||||
return Gerrit.Nav.getPatchSetWeblink(
|
||||
return GerritNav.getPatchSetWeblink(
|
||||
change.project,
|
||||
commitInfo.commit,
|
||||
{
|
||||
|
@@ -34,6 +34,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-commit-info tests', () => {
|
||||
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 @@ suite('gr-commit-info tests', () => {
|
||||
|
||||
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 @@ suite('gr-commit-info tests', () => {
|
||||
|
||||
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 @@ suite('gr-commit-info tests', () => {
|
||||
|
||||
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'};
|
||||
|
@@ -27,6 +27,7 @@ import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-l
|
||||
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 @@ class GrConfirmCherrypickDialog extends GestureEventListeners(
|
||||
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}"`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -18,7 +18,6 @@ import '../../../scripts/bundled-polymer.js';
|
||||
|
||||
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';
|
||||
|
@@ -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 {htmlTemplate} from './gr-file-list-header_html.js';
|
||||
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 @@ class GrFileListHeader extends mixinBehaviors( [
|
||||
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) {
|
||||
|
@@ -42,6 +42,7 @@ import '../../../test/common-test-setup.js';
|
||||
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 @@ suite('gr-file-list-header tests', () => {
|
||||
});
|
||||
|
||||
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: {
|
||||
|
@@ -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 {PathListBehavior} from '../../../behaviors/gr-path-list-behavior/gr-path
|
||||
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 @@ class GrFileList extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrFileList extends mixinBehaviors( [
|
||||
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 @@ class GrFileList extends mixinBehaviors( [
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -50,6 +50,7 @@ import '../../diff/gr-comment-api/gr-comment-api-mock_test.js';
|
||||
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 @@ suite('gr-file-list tests', () => {
|
||||
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('gr-file-list tests', () => {
|
||||
|
||||
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 @@ suite('gr-file-list tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-file-list tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-file-list tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-file-list tests', () => {
|
||||
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);
|
||||
|
@@ -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 {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
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 @@ class GrRelatedChangesList extends mixinBehaviors( [
|
||||
* @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) {
|
||||
|
@@ -33,6 +33,8 @@ limitations under the License.
|
||||
<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 @@ suite('gr-related-changes-list tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
@@ -42,6 +42,7 @@ import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patc
|
||||
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 @@ class GrReplyDialog extends mixinBehaviors( [
|
||||
|
||||
_reload() {
|
||||
// Load the current change without any patch range.
|
||||
Gerrit.Nav.navigateToChange(this.change);
|
||||
GerritNav.navigateToChange(this.change);
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,10 +25,12 @@ limitations under the License.
|
||||
<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 @@ suite('gr-navigation tests', () => {
|
||||
|
||||
test('dashboard for self', () => {
|
||||
const dashboard =
|
||||
Gerrit.Nav.getUserDashboard('self', sections, 'title');
|
||||
GerritNav.getUserDashboard('self', sections, 'title');
|
||||
assert.deepEqual(
|
||||
dashboard,
|
||||
{
|
||||
@@ -64,7 +66,7 @@ suite('gr-navigation tests', () => {
|
||||
|
||||
test('dashboard for other user', () => {
|
||||
const dashboard =
|
||||
Gerrit.Nav.getUserDashboard('user', sections, 'title');
|
||||
GerritNav.getUserDashboard('user', sections, 'title');
|
||||
assert.deepEqual(
|
||||
dashboard,
|
||||
{
|
||||
|
@@ -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 {htmlTemplate} from './gr-router_html.js';
|
||||
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 @@ class GrRouter extends mixinBehaviors( [
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
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 @@ class GrRouter extends mixinBehaviors( [
|
||||
*/
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
*/
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
page.base(base);
|
||||
}
|
||||
|
||||
Gerrit.Nav.setup(
|
||||
GerritNav.setup(
|
||||
url => { page.show(url); },
|
||||
this._generateUrl.bind(this),
|
||||
params => this._generateWeblinks(params),
|
||||
@@ -1021,7 +1021,7 @@ class GrRouter extends mixinBehaviors( [
|
||||
}
|
||||
} else {
|
||||
this._setParams({
|
||||
view: Gerrit.Nav.View.DASHBOARD,
|
||||
view: GerritNav.View.DASHBOARD,
|
||||
user: data.params[0],
|
||||
});
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ class GrRouter extends mixinBehaviors( [
|
||||
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 @@ class GrRouter extends mixinBehaviors( [
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
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 @@ class GrRouter extends mixinBehaviors( [
|
||||
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 @@ class GrRouter extends mixinBehaviors( [
|
||||
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 @@ class GrRouter extends mixinBehaviors( [
|
||||
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 @@ class GrRouter extends mixinBehaviors( [
|
||||
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 @@ class GrRouter extends mixinBehaviors( [
|
||||
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 @@ class GrRouter extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_handleNewAgreementsRoute(data) {
|
||||
data.params.view = Gerrit.Nav.View.AGREEMENTS;
|
||||
data.params.view = GerritNav.View.AGREEMENTS;
|
||||
this._setParams(data.params);
|
||||
}
|
||||
|
||||
@@ -1472,13 +1472,13 @@ class GrRouter extends mixinBehaviors( [
|
||||
// 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 @@ class GrRouter extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_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 @@ class GrRouter extends mixinBehaviors( [
|
||||
|
||||
_handleDocumentationSearchRoute(data) {
|
||||
this._setParams({
|
||||
view: Gerrit.Nav.View.DOCUMENTATION_SEARCH,
|
||||
view: GerritNav.View.DOCUMENTATION_SEARCH,
|
||||
filter: data.params.filter || null,
|
||||
});
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
test('repo dashboard', () => {
|
||||
const params = {
|
||||
view: Gerrit.Nav.View.DASHBOARD,
|
||||
view: GerritNav.View.DASHBOARD,
|
||||
repo: 'gerrit/repo',
|
||||
dashboard: 'default:main',
|
||||
};
|
||||
@@ -487,7 +489,7 @@ suite('gr-router tests', () => {
|
||||
|
||||
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('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
test('group members', () => {
|
||||
const params = {
|
||||
view: Gerrit.Nav.View.GROUP,
|
||||
view: GerritNav.View.GROUP,
|
||||
groupId: 1234,
|
||||
detail: 'members',
|
||||
};
|
||||
@@ -518,7 +520,7 @@ suite('gr-router tests', () => {
|
||||
|
||||
test('group audit log', () => {
|
||||
const params = {
|
||||
view: Gerrit.Nav.View.GROUP,
|
||||
view: GerritNav.View.GROUP,
|
||||
groupId: 1234,
|
||||
detail: 'log',
|
||||
};
|
||||
@@ -635,13 +637,13 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
test('_handleSettingsRoute', () => {
|
||||
const data = {};
|
||||
assertDataToParams(data, '_handleSettingsRoute', {
|
||||
view: Gerrit.Nav.View.SETTINGS,
|
||||
view: GerritNav.View.SETTINGS,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -677,7 +679,7 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
changeNum: 1234,
|
||||
basePatchNum: 6,
|
||||
patchNum: 9,
|
||||
view: Gerrit.Nav.View.CHANGE,
|
||||
view: GerritNav.View.CHANGE,
|
||||
querystring: '',
|
||||
});
|
||||
});
|
||||
@@ -1390,7 +1392,7 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
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 @@ suite('gr-router tests', () => {
|
||||
const appParams = {
|
||||
project: 'foo/bar',
|
||||
changeNum: 1234,
|
||||
view: Gerrit.Nav.View.CHANGE,
|
||||
view: GerritNav.View.CHANGE,
|
||||
patchNum: 3,
|
||||
edit: true,
|
||||
};
|
||||
@@ -1612,7 +1614,7 @@ suite('gr-router tests', () => {
|
||||
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',
|
||||
});
|
||||
|
@@ -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 {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
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 @@ class GrSmartSearch extends mixinBehaviors( [
|
||||
_handleSearch(e) {
|
||||
const input = e.detail.inputVal;
|
||||
if (input) {
|
||||
Gerrit.Nav.navigateToSearchQuery(input);
|
||||
GerritNav.navigateToSearchQuery(input);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,7 @@ import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-l
|
||||
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 @@ class GrApplyFixDialog extends GestureEventListeners(
|
||||
)
|
||||
.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;
|
||||
|
@@ -38,6 +38,8 @@ void (0);
|
||||
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 @@ suite('gr-apply-fix-dialog tests', () => {
|
||||
'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 @@ suite('gr-apply-fix-dialog tests', () => {
|
||||
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 @@ suite('gr-apply-fix-dialog tests', () => {
|
||||
}));
|
||||
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();
|
||||
});
|
||||
|
@@ -31,6 +31,7 @@ import {htmlTemplate} from './gr-diff-host_html.js';
|
||||
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 @@ class GrDiffHost extends mixinBehaviors( [
|
||||
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}),
|
||||
};
|
||||
|
@@ -34,6 +34,7 @@ limitations under the License.
|
||||
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 @@ suite('gr-diff-host tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-diff-host tests', () => {
|
||||
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 @@ suite('gr-diff-host tests', () => {
|
||||
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'}],
|
||||
|
@@ -19,7 +19,6 @@ import '../../../scripts/bundled-polymer.js';
|
||||
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 {PathListBehavior} from '../../../behaviors/gr-path-list-behavior/gr-path
|
||||
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 @@ class GrDiffView extends mixinBehaviors( [
|
||||
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 @@ class GrDiffView extends mixinBehaviors( [
|
||||
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 @@ class GrDiffView extends mixinBehaviors( [
|
||||
return;
|
||||
}
|
||||
|
||||
Gerrit.Nav.navigateToDiff(this._change, newPath.path,
|
||||
GerritNav.navigateToDiff(this._change, newPath.path,
|
||||
this._patchRange.patchNum, this._patchRange.basePatchNum);
|
||||
}
|
||||
|
||||
@@ -645,9 +645,9 @@ class GrDiffView extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrDiffView extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_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 @@ class GrDiffView extends mixinBehaviors( [
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.view === Gerrit.Nav.View.DIFF) {
|
||||
if (params.view === GerritNav.View.DIFF) {
|
||||
this._setReviewed(true);
|
||||
}
|
||||
}
|
||||
@@ -866,7 +866,7 @@ class GrDiffView extends mixinBehaviors( [
|
||||
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 @@ class GrDiffView extends mixinBehaviors( [
|
||||
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 @@ class GrDiffView extends mixinBehaviors( [
|
||||
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 @@ class GrDiffView extends mixinBehaviors( [
|
||||
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 @@ class GrDiffView extends mixinBehaviors( [
|
||||
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);
|
||||
|
@@ -42,6 +42,8 @@ import '../../../test/common-test-setup.js';
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
['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 @@ suite('gr-diff-view tests', () => {
|
||||
['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 @@ suite('gr-diff-view tests', () => {
|
||||
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('gr-diff-view tests', () => {
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
|
||||
element._loggedIn = true;
|
||||
element.params = {
|
||||
view: Gerrit.Nav.View.DIFF,
|
||||
view: GerritNav.View.DIFF,
|
||||
changeNum: '42',
|
||||
patchNum: '2',
|
||||
basePatchNum: '1',
|
||||
@@ -718,11 +720,11 @@ suite('gr-diff-view tests', () => {
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
|
||||
element._loggedIn = true;
|
||||
element.params = {
|
||||
view: Gerrit.Nav.View.DIFF,
|
||||
view: GerritNav.View.DIFF,
|
||||
changeNum: '42',
|
||||
patchNum: '2',
|
||||
basePatchNum: '1',
|
||||
@@ -830,7 +832,7 @@ suite('gr-diff-view tests', () => {
|
||||
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
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 @@ suite('gr-diff-view tests', () => {
|
||||
});
|
||||
|
||||
// No extra call
|
||||
assert.isTrue(Gerrit.Nav.navigateToDiff.calledOnce);
|
||||
assert.isTrue(GerritNav.navigateToDiff.calledOnce);
|
||||
});
|
||||
|
||||
test('_computeDownloadDropdownLinks', () => {
|
||||
|
@@ -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 {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
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 @@ class GrEditControls extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_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 @@ class GrEditControls extends mixinBehaviors( [
|
||||
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 @@ class GrEditControls extends mixinBehaviors( [
|
||||
.then(res => {
|
||||
if (!res.ok) { return; }
|
||||
this._closeDialog(dialog, true);
|
||||
Gerrit.Nav.navigateToChange(this.change);
|
||||
GerritNav.navigateToChange(this.change);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ class GrEditControls extends mixinBehaviors( [
|
||||
.then(res => {
|
||||
if (!res.ok) { return; }
|
||||
this._closeDialog(dialog, true);
|
||||
Gerrit.Nav.navigateToChange(this.change);
|
||||
GerritNav.navigateToChange(this.change);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ class GrEditControls extends mixinBehaviors( [
|
||||
this._path, this._newPath).then(res => {
|
||||
if (!res.ok) { return; }
|
||||
this._closeDialog(dialog, true);
|
||||
Gerrit.Nav.navigateToChange(this.change);
|
||||
GerritNav.navigateToChange(this.change);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,8 @@ import '../../../test/common-test-setup.js';
|
||||
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 @@ suite('gr-edit-controls tests', () => {
|
||||
|
||||
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 @@ suite('gr-edit-controls tests', () => {
|
||||
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 @@ suite('gr-edit-controls tests', () => {
|
||||
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 @@ suite('gr-edit-controls tests', () => {
|
||||
'.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 @@ suite('gr-edit-controls tests', () => {
|
||||
let restoreStub;
|
||||
|
||||
setup(() => {
|
||||
navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
|
||||
navStub = sandbox.stub(GerritNav, 'navigateToChange');
|
||||
restoreStub = sandbox.stub(element.$.restAPI, 'restoreFileInChangeEdit');
|
||||
});
|
||||
|
||||
|
@@ -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 {htmlTemplate} from './gr-editor-view_html.js';
|
||||
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 @@ class GrEditorView extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_paramsChanged(value) {
|
||||
if (value.view !== Gerrit.Nav.View.EDIT) {
|
||||
if (value.view !== GerritNav.View.EDIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ class GrEditorView extends mixinBehaviors( [
|
||||
|
||||
_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);
|
||||
}
|
||||
|
||||
|
@@ -32,6 +32,8 @@ limitations under the License.
|
||||
<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('gr-editor-view tests', () => {
|
||||
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 @@ suite('gr-editor-view tests', () => {
|
||||
});
|
||||
|
||||
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 @@ suite('gr-editor-view tests', () => {
|
||||
|
||||
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);
|
||||
|
@@ -25,7 +25,6 @@ import './change/gr-change-view/gr-change-view.js';
|
||||
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 {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
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 @@ class GrAppElement extends mixinBehaviors( [
|
||||
|
||||
// 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 @@ class GrAppElement extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrAppElement extends mixinBehaviors( [
|
||||
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 @@ class GrAppElement extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrAppElement extends mixinBehaviors( [
|
||||
|
||||
_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 @@ class GrAppElement extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_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}) {
|
||||
|
@@ -73,6 +73,7 @@ import {
|
||||
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 @@ export function initGlobalVariables() {
|
||||
PRELOADED_PROTOCOL,
|
||||
PLUGIN_LOADING_TIMEOUT_MS,
|
||||
};
|
||||
|
||||
window.Gerrit = window.Gerrit || {};
|
||||
window.Gerrit.Nav = GerritNav;
|
||||
}
|
||||
|
@@ -33,6 +33,8 @@ limitations under the License.
|
||||
<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 @@ suite('gr-app tests', () => {
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
@@ -18,12 +18,12 @@ import '../../../scripts/bundled-polymer.js';
|
||||
|
||||
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 @@ class GrGroupList extends GestureEventListeners(
|
||||
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-group-list tests', () => {
|
||||
});
|
||||
|
||||
test('_computeGroupPath', () => {
|
||||
sandbox.stub(Gerrit.Nav, 'getUrlForGroup',
|
||||
sandbox.stub(GerritNav, 'getUrlForGroup',
|
||||
() => '/admin/groups/e2cd66f88a2db4d391ac068a92d987effbe872f5');
|
||||
|
||||
let group = {
|
||||
|
@@ -18,7 +18,6 @@ import '../../../scripts/bundled-polymer.js';
|
||||
|
||||
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';
|
||||
|
@@ -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 {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
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 @@ class GrAccountLink extends mixinBehaviors( [
|
||||
|
||||
_computeOwnerLink(account) {
|
||||
if (!account) { return; }
|
||||
return Gerrit.Nav.getUrlForOwner(
|
||||
return GerritNav.getUrlForOwner(
|
||||
account.email || account.username || account.name ||
|
||||
account._account_id);
|
||||
}
|
||||
|
@@ -33,6 +33,8 @@ limitations under the License.
|
||||
<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 @@ suite('gr-account-link tests', () => {
|
||||
|
||||
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',
|
||||
|
@@ -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 {htmlTemplate} from './gr-comment-thread_html.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 {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 @@ class GrCommentThread extends mixinBehaviors( [
|
||||
}
|
||||
|
||||
_getDiffUrlForComment(projectName, changeNum, path, patchNum) {
|
||||
return Gerrit.Nav.getUrlForDiffById(changeNum,
|
||||
return GerritNav.getUrlForDiffById(changeNum,
|
||||
projectName, path, patchNum,
|
||||
null, this.lineNum);
|
||||
}
|
||||
|
@@ -40,6 +40,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-comment-thread tests', () => {
|
||||
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 @@ suite('gr-comment-thread tests', () => {
|
||||
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));
|
||||
});
|
||||
|
@@ -29,6 +29,7 @@ import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-l
|
||||
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 @@ class GrLabelInfo extends GestureEventListeners(
|
||||
.then(response => {
|
||||
target.disabled = false;
|
||||
if (!response.ok) { return; }
|
||||
Gerrit.Nav.navigateToChange(this.change);
|
||||
GerritNav.navigateToChange(this.change);
|
||||
})
|
||||
.catch(err => {
|
||||
target.disabled = false;
|
||||
|
@@ -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 {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
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 @@ class GrLinkedText extends GestureEventListeners(
|
||||
* 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,
|
||||
|
@@ -36,6 +36,8 @@ limitations under the License.
|
||||
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 @@ suite('gr-linked-text tests', () => {
|
||||
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+)',
|
||||
|
@@ -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 => '', () => []);
|
||||
|
Reference in New Issue
Block a user