Preserve the base patch when selecting a new patch in the change view
The GR-CHANGE-VIEW element responds to changes in "Patch Set" select input by constructing and loading a new router URL. However, if the base patch did not have PARENT selected, it would not be included in the new route, effectively resetting the base patch to PARENT whenever the patch is changed. With this change, the base patch selection is included in such router URLs. Bug: Issue 5254 Change-Id: I757bba23f6e23d4b63bc57183c65d2365cb88f5f
This commit is contained in:
@@ -511,7 +511,7 @@
|
||||
|
||||
/**
|
||||
* Change active patch to the provided patch num.
|
||||
* @param {int} patchNum the patchn number to be viewed.
|
||||
* @param {number} patchNum the patchn number to be viewed.
|
||||
*/
|
||||
_changePatchNum: function(patchNum) {
|
||||
var currentPatchNum;
|
||||
@@ -521,11 +521,14 @@
|
||||
} else {
|
||||
currentPatchNum = this._computeLatestPatchNum(this._allPatchSets);
|
||||
}
|
||||
if (patchNum === currentPatchNum) {
|
||||
if (patchNum === currentPatchNum &&
|
||||
this._patchRange.basePatchNum === 'PARENT') {
|
||||
page.show(this.changePath(this._changeNum));
|
||||
return;
|
||||
}
|
||||
page.show(this.changePath(this._changeNum) + '/' + patchNum);
|
||||
var patchExpr = this._patchRange.basePatchNum === 'PARENT' ? patchNum :
|
||||
this._patchRange.basePatchNum + '..' + patchNum;
|
||||
page.show(this.changePath(this._changeNum) + '/' + patchExpr);
|
||||
},
|
||||
|
||||
_computeChangePermalink: function(changeNum) {
|
||||
|
@@ -499,6 +499,35 @@ limitations under the License.
|
||||
assert.isTrue(reloadStub.calledTwice);
|
||||
});
|
||||
|
||||
test('include base patch when not parent', function() {
|
||||
element._changeNum = '42';
|
||||
element._patchRange = {
|
||||
basePatchNum: '2',
|
||||
patchNum: '3',
|
||||
};
|
||||
element._change = {
|
||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
||||
revisions: {
|
||||
rev2: {_number: 2},
|
||||
rev1: {_number: 1},
|
||||
rev13: {_number: 13},
|
||||
rev3: {_number: 3},
|
||||
},
|
||||
status: 'NEW',
|
||||
labels: {},
|
||||
};
|
||||
|
||||
var showStub = sandbox.stub(page, 'show');
|
||||
|
||||
element._changePatchNum(13);
|
||||
assert(showStub.lastCall.calledWithExactly('/c/42/2..13'));
|
||||
|
||||
element._patchRange.basePatchNum = 'PARENT';
|
||||
|
||||
element._changePatchNum(3);
|
||||
assert(showStub.lastCall.calledWithExactly('/c/42/3'));
|
||||
});
|
||||
|
||||
test('related changes are updated after rebase', function(done) {
|
||||
sandbox.stub(element, '_reload',
|
||||
function() { return Promise.resolve(); });
|
||||
|
Reference in New Issue
Block a user