Fix patch range select on diff

Previously, the patch range selector was updated to not use two way
bindings (https://gerrit-review.googlesource.com/c/gerrit/+/130453) but
the diff view's usage was not updated as well. This change updates the
diff view to use the patch range select in the same way as the file
list.

Bug: Issue 7420
Change-Id: I1baaf643e08d1a4661962021be890bafd6d5b4ef
This commit is contained in:
Becky Siegel
2017-10-12 11:35:18 -07:00
parent 5c27db596f
commit af950fd955
3 changed files with 15 additions and 37 deletions

View File

@@ -284,11 +284,12 @@ limitations under the License.
<gr-patch-range-select
id="rangeSelect"
change-num="[[_changeNum]]"
patch-num="{{_patchNum}}"
base-patch-num="{{_basePatchNum}}"
patch-num="[[_patchRange.patchNum]]"
base-patch-num="[[_patchRange.basePatchNum]]"
files-weblinks="[[_filesWeblinks]]"
available-patches="[[_allPatchSets]]"
revisions="[[_change.revisions]]">
revisions="[[_change.revisions]]"
on-patch-range-change="_handlePatchChange">
</gr-patch-range-select>
<span class="download desktop">
<span class="separator">/</span>

View File

@@ -61,24 +61,8 @@
value() { return {}; },
observer: '_changeViewStateChanged',
},
/** @type {?} */
_patchRange: Object,
// These are kept as separate properties from the patchRange so that the
// observer can be aware of the previous value. In order to view sub
// property changes for _patchRange, a complex observer must be used, and
// that only displays the new value.
//
// If a previous value did not exist, the change is not reloaded with the
// new patches. This is just the initial setting from the change view vs.
// an update coming from the two way data binding.
_patchNum: {
type: String,
observer: '_patchOrBaseChanged',
},
_basePatchNum: {
type: String,
observer: '_patchOrBaseChanged',
},
/**
* @type {{
* subject: string,
@@ -166,7 +150,6 @@
'_getProjectConfig(_change.project)',
'_getFiles(_changeNum, _patchRange.*)',
'_setReviewedObserver(_loggedIn, params.*)',
'_patchRangeChanged(_patchRange.*)',
],
keyBindings: {
@@ -584,17 +567,6 @@
this.$.cursor.initialLineNumber = params.lineNum;
},
_patchRangeChanged() {
this._basePatchNum = this._patchRange.basePatchNum;
this._patchNum = this._patchRange.patchNum;
},
_patchOrBaseChanged(patchNew, patchOld) {
if (!patchOld) { return; }
this._handlePatchChange(this._basePatchNum, this._patchNum);
},
_pathChanged(path) {
if (path) {
this.fire('title-change',
@@ -701,7 +673,10 @@
this.$.dropdown.open();
},
_handlePatchChange(basePatchNum, patchNum) {
_handlePatchChange(e) {
const {basePatchNum, patchNum} = e.detail;
if (this.patchNumEquals(basePatchNum, this._patchRange.basePatchNum) &&
this.patchNumEquals(patchNum, this._patchRange.patchNum)) { return; }
Gerrit.Nav.navigateToDiff(
this._change, this._path, patchNum, basePatchNum);
},

View File

@@ -456,11 +456,13 @@ limitations under the License.
patchNum: '3',
};
assert.equal(element._basePatchNum, element._patchRange.basePatchNum);
assert.equal(element._patchNum, element._patchRange.patchNum);
element._patchNum = '1';
const detail = {
basePatchNum: 'PARENT',
patchNum: '1',
};
element.$.rangeSelect.dispatchEvent(
new CustomEvent('patch-range-change', {detail, bubbles: false}));
assert(navigateStub.lastCall.calledWithExactly(element._change,
element._path, '1', 'PARENT'));