Update URL generation in gr-related-changes-list
Change-Id: Idb9d2464e473ca167e6794ca5e0a7cbc52d8e933
This commit is contained in:
@@ -15,9 +15,9 @@ limitations under the License.
|
||||
-->
|
||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||
|
||||
<link rel="import" href="../../../behaviors/base-url-behavior/base-url-behavior.html">
|
||||
<link rel="import" href="../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.html">
|
||||
<link rel="import" href="../../../behaviors/rest-client-behavior/rest-client-behavior.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="../../../styles/shared-styles.html">
|
||||
|
||||
@@ -112,7 +112,7 @@ limitations under the License.
|
||||
items="[[_relatedResponse.changes]]"
|
||||
as="related">
|
||||
<div class$="rightIndent [[_computeChangeContainerClass(change, related)]]">
|
||||
<a href$="[[_computeChangeURL(related._change_number, related._revision_number)]]"
|
||||
<a href$="[[_computeChangeURL(related._change_number, related.project, related._revision_number)]]"
|
||||
class$="[[_computeLinkClass(related)]]"
|
||||
title$="[[related.commit.subject]]">
|
||||
[[related.commit.subject]]
|
||||
@@ -127,7 +127,7 @@ limitations under the License.
|
||||
<h4>Submitted together</h4>
|
||||
<template is="dom-repeat" items="[[_submittedTogether]]" as="change">
|
||||
<div>
|
||||
<a href$="[[_computeChangeURL(change._number)]]"
|
||||
<a href$="[[_computeChangeURL(change._number, change.project)]]"
|
||||
class$="[[_computeLinkClass(change)]]"
|
||||
title$="[[change.project]]: [[change.branch]]: [[change.subject]]">
|
||||
[[change.project]]: [[change.branch]]: [[change.subject]]
|
||||
@@ -143,7 +143,7 @@ limitations under the License.
|
||||
<h4>Same topic</h4>
|
||||
<template is="dom-repeat" items="[[_sameTopic]]" as="change">
|
||||
<div>
|
||||
<a href$="[[_computeChangeURL(change._number)]]"
|
||||
<a href$="[[_computeChangeURL(change._number, change.project)]]"
|
||||
class$="[[_computeLinkClass(change)]]"
|
||||
title$="[[change.project]]: [[change.branch]]: [[change.subject]]">
|
||||
[[change.project]]: [[change.branch]]: [[change.subject]]
|
||||
@@ -155,7 +155,7 @@ limitations under the License.
|
||||
<h4>Merge conflicts</h4>
|
||||
<template is="dom-repeat" items="[[_conflicts]]" as="change">
|
||||
<div>
|
||||
<a href$="[[_computeChangeURL(change._number)]]"
|
||||
<a href$="[[_computeChangeURL(change._number, change.project)]]"
|
||||
class$="[[_computeLinkClass(change)]]"
|
||||
title$="[[change.subject]]">
|
||||
[[change.subject]]
|
||||
@@ -167,7 +167,7 @@ limitations under the License.
|
||||
<h4>Cherry picks</h4>
|
||||
<template is="dom-repeat" items="[[_cherryPicks]]" as="change">
|
||||
<div>
|
||||
<a href$="[[_computeChangeURL(change._number)]]"
|
||||
<a href$="[[_computeChangeURL(change._number, change.project)]]"
|
||||
class$="[[_computeLinkClass(change)]]"
|
||||
title$="[[change.branch]]: [[change.subject]]">
|
||||
[[change.branch]]: [[change.subject]]
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
},
|
||||
|
||||
behaviors: [
|
||||
Gerrit.BaseUrlBehavior,
|
||||
Gerrit.PatchSetBehavior,
|
||||
Gerrit.RESTClientBehavior,
|
||||
],
|
||||
@@ -164,12 +163,14 @@
|
||||
return this.$.restAPI.getChangesWithSameTopic(this.change.topic);
|
||||
},
|
||||
|
||||
_computeChangeURL(changeNum, patchNum) {
|
||||
let urlStr = this.getBaseUrl() + '/c/' + changeNum;
|
||||
if (patchNum != null) {
|
||||
urlStr += '/' + patchNum;
|
||||
}
|
||||
return urlStr;
|
||||
/**
|
||||
* @param {number} changeNum
|
||||
* @param {string} project
|
||||
* @param {number=} opt_patchNum
|
||||
* @return {string}
|
||||
*/
|
||||
_computeChangeURL(changeNum, project, opt_patchNum) {
|
||||
return Gerrit.Nav.getUrlForChangeById(changeNum, project, opt_patchNum);
|
||||
},
|
||||
|
||||
_computeChangeContainerClass(currentChange, relatedChange) {
|
||||
|
||||
@@ -357,5 +357,11 @@ limitations under the License.
|
||||
assert.isFalse(element.hidden);
|
||||
assert.isTrue(updateHandler.called);
|
||||
});
|
||||
|
||||
test('_computeChangeURL uses Gerrit.Nav', () => {
|
||||
const getUrlStub = sandbox.stub(Gerrit.Nav, 'getUrlForChangeById');
|
||||
element._computeChangeURL(123, 'abc/def', 12);
|
||||
assert.isTrue(getUrlStub.called);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -188,6 +188,21 @@ limitations under the License.
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} changeNum
|
||||
* @param {string} project The name of the project.
|
||||
* @param {number=} opt_patchNum
|
||||
* @return {string}
|
||||
*/
|
||||
getUrlForChangeById(changeNum, project, opt_patchNum) {
|
||||
return this._getUrlFor({
|
||||
view: Gerrit.Nav.View.CHANGE,
|
||||
changeNum,
|
||||
project,
|
||||
patchNum: opt_patchNum,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {!Object} change The change object.
|
||||
* @param {number=} opt_patchNum
|
||||
|
||||
Reference in New Issue
Block a user