Reload actions when new change is loaded, not on new changeNum

In Id4528de9e4, the change actions get reloaded when there is a new
change by reacting to changes in the changeNum or patchNum. However,
the change actions are not based on the selected patch set, instead they
are based on the "latest patch set", and the latest patch set can only
be known when the revisions are loaded (from the change object). As
such, when only the new changeNum was known but the new change object
was not yet loaded, the patchNum based on the change object would be
stale. If the stale patchNum is not valid on the new change this
resulted in a 404 in the actions request.

With this change, the change actions are reloaded when the change object
changes, since this implies that the patchNum will no longer be stale.

Bug: Issue 7622
Change-Id: Ia6fa8ec41b63b02d9f2e6b69cf4225e07b2fae9f
This commit is contained in:
Wyatt Allen
2017-11-02 10:36:27 -07:00
parent 344dbd603a
commit f97f253fa9
2 changed files with 10 additions and 2 deletions

View File

@@ -323,7 +323,7 @@
observers: [
'_actionsChanged(actions.*, revisionActions.*, _additionalActions.*, ' +
'editLoaded, editBasedOnCurrentPatchSet, change)',
'_changeOrPatchNumChanged(changeNum, patchNum)',
'_changeChanged(change)',
],
listeners: {
@@ -354,7 +354,7 @@
});
},
_changeOrPatchNumChanged() {
_changeChanged() {
this.reload();
},

View File

@@ -1150,6 +1150,14 @@ limitations under the License.
assert.isTrue(handler.called);
});
test('changing changeNum or patchNum does not reload', () => {
const reloadStub = sandbox.stub(element, 'reload');
element.changeNum = 123;
assert.isFalse(reloadStub.called);
element.patchNum = 456;
assert.isFalse(reloadStub.called);
});
suite('setActionOverflow', () => {
test('move action from overflow', () => {
assert.isNotOk(element.$$('[data-action-key="cherrypick"]'));