Set projectLookup values in diff and change views
Moving this call from the router to the diff and change views helps dedupe getChange calls when PolyGerrit is using a navigation component other than gr-router, like in the embedded view scenario. Change-Id: I41aff794af510d217792fc4d409d8d7d2dacab3d
This commit is contained in:
@@ -618,6 +618,10 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value.changeNum && value.project) {
|
||||||
|
this.$.restAPI.setInProjectLookup(value.changeNum, value.project);
|
||||||
|
}
|
||||||
|
|
||||||
const patchChanged = this._patchRange &&
|
const patchChanged = this._patchRange &&
|
||||||
(value.patchNum !== undefined && value.basePatchNum !== undefined) &&
|
(value.patchNum !== undefined && value.basePatchNum !== undefined) &&
|
||||||
(this._patchRange.patchNum !== value.patchNum ||
|
(this._patchRange.patchNum !== value.patchNum ||
|
||||||
|
@@ -1729,5 +1729,18 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('_paramsChanged sets in projectLookup', () => {
|
||||||
|
sandbox.stub(element.$.relatedChanges, 'reload');
|
||||||
|
sandbox.stub(element, '_reload').returns(Promise.resolve());
|
||||||
|
const setStub = sandbox.stub(element.$.restAPI, 'setInProjectLookup');
|
||||||
|
element._paramsChanged({
|
||||||
|
view: Gerrit.Nav.View.CHANGE,
|
||||||
|
changeNum: 101,
|
||||||
|
project: 'test-project',
|
||||||
|
});
|
||||||
|
assert.isTrue(setStub.calledOnce);
|
||||||
|
assert.isTrue(setStub.calledWith(101, 'test-project'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1316,8 +1316,6 @@
|
|||||||
this._redirect(this._generateUrl(params));
|
this._redirect(this._generateUrl(params));
|
||||||
} else {
|
} else {
|
||||||
this._setParams(params);
|
this._setParams(params);
|
||||||
this.$.restAPI.setInProjectLookup(params.changeNum,
|
|
||||||
params.project);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -552,6 +552,10 @@
|
|||||||
_paramsChanged(value) {
|
_paramsChanged(value) {
|
||||||
if (value.view !== Gerrit.Nav.View.DIFF) { return; }
|
if (value.view !== Gerrit.Nav.View.DIFF) { return; }
|
||||||
|
|
||||||
|
if (value.changeNum && value.project) {
|
||||||
|
this.$.restAPI.setInProjectLookup(value.changeNum, value.project);
|
||||||
|
}
|
||||||
|
|
||||||
this.$.diff.lineOfInterest = this._getLineOfInterest(this.params);
|
this.$.diff.lineOfInterest = this._getLineOfInterest(this.params);
|
||||||
this._initCursor(this.params);
|
this._initCursor(this.params);
|
||||||
|
|
||||||
|
@@ -1041,5 +1041,19 @@ limitations under the License.
|
|||||||
assert.isFalse(isVisible(element.$.reviewed));
|
assert.isFalse(isVisible(element.$.reviewed));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('_paramsChanged sets in projectLookup', () => {
|
||||||
|
sandbox.stub(element, '_getLineOfInterest');
|
||||||
|
sandbox.stub(element, '_initCursor');
|
||||||
|
const setStub = sandbox.stub(element.$.restAPI, 'setInProjectLookup');
|
||||||
|
element._paramsChanged({
|
||||||
|
view: Gerrit.Nav.View.DIFF,
|
||||||
|
changeNum: 101,
|
||||||
|
project: 'test-project',
|
||||||
|
path: '',
|
||||||
|
});
|
||||||
|
assert.isTrue(setStub.calledOnce);
|
||||||
|
assert.isTrue(setStub.calledWith(101, 'test-project'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user