Merge "Update URL generation in gr-change-list-item and gr-change-list"
This commit is contained in:
@@ -19,6 +19,7 @@ limitations under the License.
|
|||||||
<link rel="import" href="../../../behaviors/rest-client-behavior/rest-client-behavior.html">
|
<link rel="import" href="../../../behaviors/rest-client-behavior/rest-client-behavior.html">
|
||||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||||
<link rel="import" href="../../../styles/gr-change-list-styles.html">
|
<link rel="import" href="../../../styles/gr-change-list-styles.html">
|
||||||
|
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
|
||||||
<link rel="import" href="../../shared/gr-account-link/gr-account-link.html">
|
<link rel="import" href="../../shared/gr-account-link/gr-account-link.html">
|
||||||
<link rel="import" href="../../shared/gr-change-star/gr-change-star.html">
|
<link rel="import" href="../../shared/gr-change-star/gr-change-star.html">
|
||||||
<link rel="import" href="../../shared/gr-date-formatter/gr-date-formatter.html">
|
<link rel="import" href="../../shared/gr-date-formatter/gr-date-formatter.html">
|
||||||
@@ -72,7 +73,8 @@ limitations under the License.
|
|||||||
}
|
}
|
||||||
a {
|
a {
|
||||||
color: var(--default-text-color);
|
color: var(--default-text-color);
|
||||||
display: block;
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
a:hover {
|
a:hover {
|
||||||
@@ -141,8 +143,11 @@ limitations under the License.
|
|||||||
<td class="cell branch"
|
<td class="cell branch"
|
||||||
hidden$="[[isColumnHidden('Branch', visibleChangeTableColumns)]]">
|
hidden$="[[isColumnHidden('Branch', visibleChangeTableColumns)]]">
|
||||||
<a href$="[[_computeProjectBranchURL(change)]]">
|
<a href$="[[_computeProjectBranchURL(change)]]">
|
||||||
[[_computeBranchText(change)]]
|
[[change.branch]]
|
||||||
</a>
|
</a>
|
||||||
|
<template is="dom-if" if="[[change.topic]]">
|
||||||
|
(<a href$="[[_computeTopicURL(change)]]">[[change.topic]]</a>)
|
||||||
|
</template>
|
||||||
</td>
|
</td>
|
||||||
<td class="cell updated"
|
<td class="cell updated"
|
||||||
hidden$="[[isColumnHidden('Updated', visibleChangeTableColumns)]]">
|
hidden$="[[isColumnHidden('Updated', visibleChangeTableColumns)]]">
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
change: Object,
|
change: Object,
|
||||||
changeURL: {
|
changeURL: {
|
||||||
type: String,
|
type: String,
|
||||||
computed: '_computeChangeURL(change._number)',
|
computed: '_computeChangeURL(change)',
|
||||||
},
|
},
|
||||||
showStar: {
|
showStar: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -43,9 +43,8 @@
|
|||||||
Gerrit.URLEncodingBehavior,
|
Gerrit.URLEncodingBehavior,
|
||||||
],
|
],
|
||||||
|
|
||||||
_computeChangeURL(changeNum) {
|
_computeChangeURL(change) {
|
||||||
if (!changeNum) { return ''; }
|
return Gerrit.Nav.getUrlForChange(change);
|
||||||
return this.getBaseUrl() + '/c/' + changeNum + '/';
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeLabelTitle(change, labelName) {
|
_computeLabelTitle(change, labelName) {
|
||||||
@@ -105,24 +104,16 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_computeProjectURL(project) {
|
_computeProjectURL(project) {
|
||||||
return this.getBaseUrl() + '/q/status:open+project:' +
|
return Gerrit.Nav.getUrlForProject(project, true);
|
||||||
this.encodeURL(project, false);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeProjectBranchURL(change) {
|
_computeProjectBranchURL(change) {
|
||||||
// @see Issue 4255, Issue 6195.
|
return Gerrit.Nav.getUrlForBranch(change.branch, change.project);
|
||||||
let output = this._computeProjectURL(change.project);
|
|
||||||
output += '+branch:' + this.encodeURL(change.branch, false);
|
|
||||||
if (change.topic) {
|
|
||||||
output += '+topic:' + this.encodeURL(change.topic, false);
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeBranchText(change) {
|
_computeTopicURL(change) {
|
||||||
let output = change.branch;
|
if (!change.topic) { return ''; }
|
||||||
if (change.topic) { output += ` (${change.topic})`; }
|
return Gerrit.Nav.getUrlForTopic(change.topic);
|
||||||
return output;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
@@ -112,23 +112,6 @@ limitations under the License.
|
|||||||
{labels: {Verified: {approved: true}}}, 'Verified'), '✓');
|
{labels: {Verified: {approved: true}}}, 'Verified'), '✓');
|
||||||
assert.equal(element._computeLabelValue(
|
assert.equal(element._computeLabelValue(
|
||||||
{labels: {Verified: {rejected: true}}}, 'Verified'), '✕');
|
{labels: {Verified: {rejected: true}}}, 'Verified'), '✕');
|
||||||
|
|
||||||
assert.equal(element._computeProjectURL('combustible/stuff'),
|
|
||||||
'/q/status:open+project:combustible%252Fstuff');
|
|
||||||
|
|
||||||
const change = {project: 'combustible-stuff', branch: 'le/mons'};
|
|
||||||
assert.equal(element._computeProjectBranchURL(change),
|
|
||||||
'/q/status:open+project:combustible-stuff+branch:le%252Fmons');
|
|
||||||
|
|
||||||
change.topic = 'test/test';
|
|
||||||
assert.equal(element._computeProjectBranchURL(change),
|
|
||||||
'/q/status:open+project:combustible-stuff+branch:le%252Fmons' +
|
|
||||||
'+topic:test%252Ftest');
|
|
||||||
|
|
||||||
element.change = {_number: 42};
|
|
||||||
assert.equal(element.changeURL, '/c/42/');
|
|
||||||
element.change = {_number: 43};
|
|
||||||
assert.equal(element.changeURL, '/c/43/');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('no hidden columns', () => {
|
test('no hidden columns', () => {
|
||||||
|
@@ -21,6 +21,7 @@ limitations under the License.
|
|||||||
<link rel="import" href="../../../behaviors/rest-client-behavior/rest-client-behavior.html">
|
<link rel="import" href="../../../behaviors/rest-client-behavior/rest-client-behavior.html">
|
||||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||||
<link rel="import" href="../../../styles/gr-change-list-styles.html">
|
<link rel="import" href="../../../styles/gr-change-list-styles.html">
|
||||||
|
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
|
||||||
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
||||||
<link rel="import" href="../gr-change-list-item/gr-change-list-item.html">
|
<link rel="import" href="../gr-change-list-item/gr-change-list-item.html">
|
||||||
<link rel="import" href="../../../styles/shared-styles.html">
|
<link rel="import" href="../../../styles/shared-styles.html">
|
||||||
|
@@ -238,7 +238,7 @@
|
|||||||
this.modifierPressed(e)) { return; }
|
this.modifierPressed(e)) { return; }
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
page.show(this._changeURLForIndex(this.selectedIndex));
|
Gerrit.Nav.navigateToChange(this._changeForIndex(this.selectedIndex));
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleNKey(e) {
|
_handleNKey(e) {
|
||||||
@@ -285,12 +285,12 @@
|
|||||||
this.$.restAPI.saveChangeStarred(change._number, newVal);
|
this.$.restAPI.saveChangeStarred(change._number, newVal);
|
||||||
},
|
},
|
||||||
|
|
||||||
_changeURLForIndex(index) {
|
_changeForIndex(index) {
|
||||||
const changeEls = this._getListItems();
|
const changeEls = this._getListItems();
|
||||||
if (index < changeEls.length && changeEls[index]) {
|
if (index < changeEls.length && changeEls[index]) {
|
||||||
return changeEls[index].changeURL;
|
return changeEls[index].change;
|
||||||
}
|
}
|
||||||
return '';
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
_getListItems() {
|
_getListItems() {
|
||||||
|
@@ -42,11 +42,15 @@ limitations under the License.
|
|||||||
<script>
|
<script>
|
||||||
suite('gr-change-list basic tests', () => {
|
suite('gr-change-list basic tests', () => {
|
||||||
let element;
|
let element;
|
||||||
|
let sandbox;
|
||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
|
sandbox = sinon.sandbox.create();
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
teardown(() => { sandbox.restore(); });
|
||||||
|
|
||||||
function stubRestAPI(preferences) {
|
function stubRestAPI(preferences) {
|
||||||
const loggedInPromise = Promise.resolve(preferences !== null);
|
const loggedInPromise = Promise.resolve(preferences !== null);
|
||||||
const preferencesPromise = Promise.resolve(preferences);
|
const preferencesPromise = Promise.resolve(preferences);
|
||||||
@@ -149,16 +153,16 @@ limitations under the License.
|
|||||||
assert.equal(element.selectedIndex, 1);
|
assert.equal(element.selectedIndex, 1);
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 74, null, 'j');
|
MockInteractions.pressAndReleaseKeyOn(element, 74, null, 'j');
|
||||||
|
|
||||||
const showStub = sinon.stub(page, 'show');
|
const navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
|
||||||
assert.equal(element.selectedIndex, 2);
|
assert.equal(element.selectedIndex, 2);
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 13, null, 'enter');
|
MockInteractions.pressAndReleaseKeyOn(element, 13, null, 'enter');
|
||||||
assert(showStub.lastCall.calledWithExactly('/c/2/'),
|
assert.deepEqual(navStub.lastCall.args[0], {_number: 2},
|
||||||
'Should navigate to /c/2/');
|
'Should navigate to /c/2/');
|
||||||
|
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
|
MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
|
||||||
assert.equal(element.selectedIndex, 1);
|
assert.equal(element.selectedIndex, 1);
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 13, null, 'enter');
|
MockInteractions.pressAndReleaseKeyOn(element, 13, null, 'enter');
|
||||||
assert(showStub.lastCall.calledWithExactly('/c/1/'),
|
assert.deepEqual(navStub.lastCall.args[0], {_number: 1},
|
||||||
'Should navigate to /c/1/');
|
'Should navigate to /c/1/');
|
||||||
|
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
|
MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
|
||||||
@@ -166,7 +170,6 @@ limitations under the License.
|
|||||||
MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
|
MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
|
||||||
assert.equal(element.selectedIndex, 0);
|
assert.equal(element.selectedIndex, 0);
|
||||||
|
|
||||||
showStub.restore();
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -367,11 +370,15 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('gr-change-list sections', () => {
|
suite('gr-change-list sections', () => {
|
||||||
let element;
|
let element;
|
||||||
|
let sandbox;
|
||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
|
sandbox = sinon.sandbox.create();
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
teardown(() => { sandbox.restore(); });
|
||||||
|
|
||||||
test('keyboard shortcuts', () => {
|
test('keyboard shortcuts', () => {
|
||||||
element.selectedIndex = 0;
|
element.selectedIndex = 0;
|
||||||
element.sections = [
|
element.sections = [
|
||||||
@@ -411,16 +418,17 @@ limitations under the License.
|
|||||||
assert.equal(element.selectedIndex, 1);
|
assert.equal(element.selectedIndex, 1);
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||||
|
|
||||||
const showStub = sinon.stub(page, 'show');
|
const navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
|
||||||
assert.equal(element.selectedIndex, 2);
|
assert.equal(element.selectedIndex, 2);
|
||||||
|
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||||
assert(showStub.lastCall.calledWithExactly('/c/2/'),
|
assert.deepEqual(navStub.lastCall.args[0], {_number: 2},
|
||||||
'Should navigate to /c/2/');
|
'Should navigate to /c/2/');
|
||||||
|
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
|
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
|
||||||
assert.equal(element.selectedIndex, 1);
|
assert.equal(element.selectedIndex, 1);
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||||
assert(showStub.lastCall.calledWithExactly('/c/1/'),
|
assert.deepEqual(navStub.lastCall.args[0], {_number: 1},
|
||||||
'Should navigate to /c/1/');
|
'Should navigate to /c/1/');
|
||||||
|
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||||
@@ -428,9 +436,8 @@ limitations under the License.
|
|||||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||||
assert.equal(element.selectedIndex, 4);
|
assert.equal(element.selectedIndex, 4);
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||||
assert(showStub.lastCall.calledWithExactly('/c/4/'),
|
assert.deepEqual(navStub.lastCall.args[0], {_number: 4},
|
||||||
'Should navigate to /c/4/');
|
'Should navigate to /c/4/');
|
||||||
showStub.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('assigned attribute set in each item', () => {
|
test('assigned attribute set in each item', () => {
|
||||||
|
@@ -123,28 +123,31 @@ limitations under the License.
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} project The name of the project.
|
* @param {!string} project The name of the project.
|
||||||
|
* @param {boolean=} opt_openOnly When true, only search open changes in
|
||||||
|
* the project.
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
getUrlForProject(project) {
|
getUrlForProject(project, opt_openOnly) {
|
||||||
return this._getUrlFor({
|
return this._getUrlFor({
|
||||||
view: Gerrit.Nav.View.SEARCH,
|
view: Gerrit.Nav.View.SEARCH,
|
||||||
project,
|
project,
|
||||||
|
statuses: opt_openOnly ? ['open'] : [],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} branch The name of the branch.
|
* @param {string} branch The name of the branch.
|
||||||
* @param {string} project The name of the project.
|
* @param {string} project The name of the project.
|
||||||
* @param {string} status The status to search.
|
* @param {string=} opt_status The status to search.
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
getUrlForBranch(branch, project, status) {
|
getUrlForBranch(branch, project, opt_status) {
|
||||||
return this._getUrlFor({
|
return this._getUrlFor({
|
||||||
view: Gerrit.Nav.View.SEARCH,
|
view: Gerrit.Nav.View.SEARCH,
|
||||||
branch,
|
branch,
|
||||||
project,
|
project,
|
||||||
statuses: [status],
|
statuses: opt_status ? [opt_status] : undefined,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user