Merge "Update patch range select to use changeComments"

This commit is contained in:
Wyatt Allen
2017-11-13 21:47:29 +00:00
committed by Gerrit Code Review
6 changed files with 30 additions and 25 deletions

View File

@@ -435,7 +435,7 @@ limitations under the License.
all-patch-sets="[[_allPatchSets]]"
change="[[_change]]"
change-num="[[_changeNum]]"
comments="[[_changeComments.comments]]"
change-comments="[[_changeComments]]"
commit-info="[[_commitInfo]]"
change-url="[[_computeChangeUrl(_change)]]"
edit-loaded="[[_editLoaded]]"

View File

@@ -145,7 +145,7 @@ limitations under the License.
<h3 class="label">Files</h3>
<gr-patch-range-select
id="rangeSelect"
comments="[[comments]]"
change-comments="[[changeComments]]"
change-num="[[changeNum]]"
patch-num="[[patchNum]]"
base-patch-num="[[basePatchNum]]"

View File

@@ -27,7 +27,7 @@
change: Object,
changeNum: String,
changeUrl: String,
comments: Object,
changeComments: Object,
commitInfo: Object,
editLoaded: Boolean,
loggedIn: Boolean,

View File

@@ -221,7 +221,7 @@ limitations under the License.
<gr-patch-range-select
id="rangeSelect"
change-num="[[_changeNum]]"
comments="[[_changeComments.comments]]"
change-comments="[[_changeComments]]"
patch-num="[[_patchRange.patchNum]]"
base-patch-num="[[_patchRange.basePatchNum]]"
files-weblinks="[[_filesWeblinks]]"

View File

@@ -34,18 +34,18 @@
_baseDropdownContent: {
type: Object,
computed: '_computeBaseDropdownContent(availablePatches, patchNum,' +
'_sortedRevisions, comments)',
'_sortedRevisions, changeComments)',
},
_patchDropdownContent: {
type: Object,
computed: '_computePatchDropdownContent(availablePatches,' +
'basePatchNum, _sortedRevisions, comments)',
'basePatchNum, _sortedRevisions, changeComments)',
},
changeNum: String,
// In the case of a patch range select (like diff view) comments should
// be an empty array, so that the patch and base content computed values
// get triggered.
comments: {
changeComments: {
type: Object,
value: () => { return {}; },
},
@@ -64,7 +64,7 @@
behaviors: [Gerrit.PatchSetBehavior],
_computeBaseDropdownContent(availablePatches, patchNum, _sortedRevisions,
comments) {
changeComments) {
const dropdownContent = [];
for (const basePatch of availablePatches) {
const basePatchNum = basePatch.num;
@@ -73,9 +73,10 @@
basePatch.num, patchNum, _sortedRevisions),
triggerText: `Patchset ${basePatchNum}`,
text: `Patchset ${basePatchNum}` +
this._computePatchSetCommentsString(this.comments, basePatchNum),
mobileText: this._computeMobileText(basePatchNum, comments,
_sortedRevisions),
this._computePatchSetCommentsString(changeComments.comments,
basePatchNum),
mobileText: this._computeMobileText(basePatchNum,
changeComments.comments, _sortedRevisions),
bottomText: `${this._computePatchSetDescription(
_sortedRevisions, basePatchNum)}`,
value: basePatch.num,
@@ -90,12 +91,12 @@
_computeMobileText(patchNum, comments, revisions) {
return `${patchNum}` +
`${this._computePatchSetCommentsString(this.comments, patchNum)}` +
`${this._computePatchSetCommentsString(comments, patchNum)}` +
`${this._computePatchSetDescription(revisions, patchNum, true)}`;
},
_computePatchDropdownContent(availablePatches, basePatchNum,
_sortedRevisions, comments) {
_sortedRevisions, changeComments) {
const dropdownContent = [];
for (const patch of availablePatches) {
const patchNum = patch.num;
@@ -106,8 +107,8 @@
patchNum,
text: `${patchNum === 'edit' ? '': 'Patchset '}${patchNum}` +
`${this._computePatchSetCommentsString(
this.comments, patchNum)}`,
mobileText: this._computeMobileText(patchNum, comments,
changeComments.comments, patchNum)}`,
mobileText: this._computeMobileText(patchNum, changeComments.comments,
_sortedRevisions),
bottomText: `${this._computePatchSetDescription(
_sortedRevisions, patchNum)}`,

View File

@@ -190,11 +190,13 @@ limitations under the License.
// Should be recomputed for each available patch
sandbox.stub(element, '_computeBaseDropdownContent');
assert.equal(element._computeBaseDropdownContent.callCount, 0);
element.set('comments', {
file: [{
message: 'test',
patch_set: 2,
}],
element.set('changeComments', {
comments: {
file: [{
message: 'test',
patch_set: 2,
}],
},
});
assert.equal(element._computeBaseDropdownContent.callCount, 1);
});
@@ -242,11 +244,13 @@ limitations under the License.
// Should be recomputed for each available patch
sandbox.stub(element, '_computePatchDropdownContent');
assert.equal(element._computePatchDropdownContent.callCount, 0);
element.set('comments', {
file: [{
message: 'test',
patch_set: 2,
}],
element.set('changeComments', {
comments: {
file: [{
message: 'test',
patch_set: 2,
}],
},
});
assert.equal(element._computePatchDropdownContent.callCount, 1);
});