Merge "Redirect to query page with reverted changes instead of showing a dialog"
This commit is contained in:
@@ -269,25 +269,6 @@ limitations under the License.
|
||||
Do you really want to delete the edit?
|
||||
</div>
|
||||
</gr-dialog>
|
||||
<gr-dialog
|
||||
id="showRevertSubmissionChangesDialog"
|
||||
class="confirmDialog"
|
||||
confirm-label="Close"
|
||||
cancel-label=''
|
||||
on-confirm="_handleShowRevertSubmissionChangesConfirm">
|
||||
<div class="header" slot="header">
|
||||
Reverted Changes
|
||||
</div>
|
||||
<div class="main" slot="main">
|
||||
<template is="dom-repeat" items="[[_revertChanges]]">
|
||||
<div>
|
||||
<a href$="[[item.link]]" target="_blank">
|
||||
Change [[item._number]]
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</gr-dialog>
|
||||
</gr-overlay>
|
||||
<gr-js-api-interface id="jsAPI"></gr-js-api-interface>
|
||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||
|
@@ -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',
|
||||
|
@@ -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();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user