diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html index 670365166f..0817762ae0 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html @@ -269,25 +269,6 @@ limitations under the License. Do you really want to delete the edit? - -
- Reverted Changes -
-
- -
-
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js index 8ad2a06ed2..9d2854aae2 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js @@ -420,10 +420,6 @@ type: Boolean, value: true, }, - _revertChanges: { - type: Array, - value: [], - }, }; } @@ -1262,7 +1258,6 @@ _handleResponse(action, response) { if (!response) { return; } return this.$.restAPI.getResponseObject(response).then(obj => { - let revertChanges = []; switch (action.__key) { case ChangeActions.REVERT: this._waitForChangeReachable(obj._number) @@ -1288,27 +1283,11 @@ Gerrit.Nav.navigateToChange(this.change); break; case ChangeActions.REVERT_SUBMISSION: - revertChanges = obj.revert_changes || []; - revertChanges = revertChanges.map(change => { - change.link = '/q/' + encodeURIComponent(change.change_id); - return change; - }); - // list of reverted changes can never be 0 - if (revertChanges.length === 1) { - // redirect to the change if only 1 change is reverted - const change = revertChanges[0]; - this._waitForChangeReachable(change._number).then(success => { - if (success) { - Gerrit.Nav.navigateToChange(change); - } else { - console.error('Change ' + change._number + ' not reachable'); - } - }); - } else { - // show multiple reverted changes in a dialog - this._revertChanges = revertChanges; - this._showActionDialog(this.$.showRevertSubmissionChangesDialog); - } + if (!obj.revert_changes || !obj.revert_changes.length) return; + /* If there is only 1 change then gerrit will automatically + redirect to that change */ + Gerrit.Nav.navigateToSearchQuery('topic: ' + + obj.revert_changes[0].topic); break; default: this.dispatchEvent(new CustomEvent('reload-change', diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html index d9b7986816..50f6fb0fee 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html @@ -1446,7 +1446,6 @@ limitations under the License. suite('happy path', () => { let sendStub; - let waitForChangeReachableStub; setup(() => { sandbox.stub(element, 'fetchChangeUpdates') .returns(Promise.resolve({isLatest: true})); @@ -1454,8 +1453,6 @@ limitations under the License. .returns(Promise.resolve({})); getResponseObjectStub = sandbox.stub(element.$.restAPI, 'getResponseObject'); - waitForChangeReachableStub = sandbox.stub(element, - '_waitForChangeReachable').returns(Promise.resolve(true)); sandbox.stub(Gerrit.Nav, 'navigateToChange').returns(Promise.resolve(true)); }); @@ -1471,12 +1468,15 @@ limitations under the License. }); suite('single changes revert', () => { + let navigateToSearchQueryStub; setup(() => { getResponseObjectStub .returns(Promise.resolve({revert_changes: [ {change_id: 12345}, ]})); showActionDialogStub = sandbox.stub(element, '_showActionDialog'); + navigateToSearchQueryStub = sandbox.stub(Gerrit.Nav, + 'navigateToSearchQuery'); }); test('revert submission single change', done => { @@ -1484,7 +1484,7 @@ limitations under the License. '/revert_submission', false, cleanup).then(res => { element._handleResponse({__key: 'revert_submission'}, {}). then(() => { - assert.isTrue(waitForChangeReachableStub.called); + assert.isTrue(navigateToSearchQueryStub.called); done(); }); }); @@ -1493,12 +1493,16 @@ limitations under the License. suite('multiple changes revert', () => { let showActionDialogStub; + let navigateToSearchQueryStub; setup(() => { getResponseObjectStub .returns(Promise.resolve({revert_changes: [ - {change_id: 12345}, {change_id: 23456}, + {change_id: 12345, topic: 'T'}, + {change_id: 23456, topic: 'T'}, ]})); showActionDialogStub = sandbox.stub(element, '_showActionDialog'); + navigateToSearchQueryStub = sandbox.stub(Gerrit.Nav, + 'navigateToSearchQuery'); }); test('revert submission multiple change', done => { @@ -1506,7 +1510,9 @@ limitations under the License. '/revert_submission', false, cleanup).then(res => { element._handleResponse({__key: 'revert_submission'}, {}).then( () => { - assert.isTrue(showActionDialogStub.called); + assert.isFalse(showActionDialogStub.called); + assert.isTrue(navigateToSearchQueryStub.calledWith( + 'topic: T')); done(); }); });