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?
|
Do you really want to delete the edit?
|
||||||
</div>
|
</div>
|
||||||
</gr-dialog>
|
</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-overlay>
|
||||||
<gr-js-api-interface id="jsAPI"></gr-js-api-interface>
|
<gr-js-api-interface id="jsAPI"></gr-js-api-interface>
|
||||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||||
|
|||||||
@@ -420,10 +420,6 @@
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: true,
|
value: true,
|
||||||
},
|
},
|
||||||
_revertChanges: {
|
|
||||||
type: Array,
|
|
||||||
value: [],
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1262,7 +1258,6 @@
|
|||||||
_handleResponse(action, response) {
|
_handleResponse(action, response) {
|
||||||
if (!response) { return; }
|
if (!response) { return; }
|
||||||
return this.$.restAPI.getResponseObject(response).then(obj => {
|
return this.$.restAPI.getResponseObject(response).then(obj => {
|
||||||
let revertChanges = [];
|
|
||||||
switch (action.__key) {
|
switch (action.__key) {
|
||||||
case ChangeActions.REVERT:
|
case ChangeActions.REVERT:
|
||||||
this._waitForChangeReachable(obj._number)
|
this._waitForChangeReachable(obj._number)
|
||||||
@@ -1288,27 +1283,11 @@
|
|||||||
Gerrit.Nav.navigateToChange(this.change);
|
Gerrit.Nav.navigateToChange(this.change);
|
||||||
break;
|
break;
|
||||||
case ChangeActions.REVERT_SUBMISSION:
|
case ChangeActions.REVERT_SUBMISSION:
|
||||||
revertChanges = obj.revert_changes || [];
|
if (!obj.revert_changes || !obj.revert_changes.length) return;
|
||||||
revertChanges = revertChanges.map(change => {
|
/* If there is only 1 change then gerrit will automatically
|
||||||
change.link = '/q/' + encodeURIComponent(change.change_id);
|
redirect to that change */
|
||||||
return change;
|
Gerrit.Nav.navigateToSearchQuery('topic: ' +
|
||||||
});
|
obj.revert_changes[0].topic);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.dispatchEvent(new CustomEvent('reload-change',
|
this.dispatchEvent(new CustomEvent('reload-change',
|
||||||
|
|||||||
@@ -1446,7 +1446,6 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('happy path', () => {
|
suite('happy path', () => {
|
||||||
let sendStub;
|
let sendStub;
|
||||||
let waitForChangeReachableStub;
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox.stub(element, 'fetchChangeUpdates')
|
sandbox.stub(element, 'fetchChangeUpdates')
|
||||||
.returns(Promise.resolve({isLatest: true}));
|
.returns(Promise.resolve({isLatest: true}));
|
||||||
@@ -1454,8 +1453,6 @@ limitations under the License.
|
|||||||
.returns(Promise.resolve({}));
|
.returns(Promise.resolve({}));
|
||||||
getResponseObjectStub = sandbox.stub(element.$.restAPI,
|
getResponseObjectStub = sandbox.stub(element.$.restAPI,
|
||||||
'getResponseObject');
|
'getResponseObject');
|
||||||
waitForChangeReachableStub = sandbox.stub(element,
|
|
||||||
'_waitForChangeReachable').returns(Promise.resolve(true));
|
|
||||||
sandbox.stub(Gerrit.Nav,
|
sandbox.stub(Gerrit.Nav,
|
||||||
'navigateToChange').returns(Promise.resolve(true));
|
'navigateToChange').returns(Promise.resolve(true));
|
||||||
});
|
});
|
||||||
@@ -1471,12 +1468,15 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
suite('single changes revert', () => {
|
suite('single changes revert', () => {
|
||||||
|
let navigateToSearchQueryStub;
|
||||||
setup(() => {
|
setup(() => {
|
||||||
getResponseObjectStub
|
getResponseObjectStub
|
||||||
.returns(Promise.resolve({revert_changes: [
|
.returns(Promise.resolve({revert_changes: [
|
||||||
{change_id: 12345},
|
{change_id: 12345},
|
||||||
]}));
|
]}));
|
||||||
showActionDialogStub = sandbox.stub(element, '_showActionDialog');
|
showActionDialogStub = sandbox.stub(element, '_showActionDialog');
|
||||||
|
navigateToSearchQueryStub = sandbox.stub(Gerrit.Nav,
|
||||||
|
'navigateToSearchQuery');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('revert submission single change', done => {
|
test('revert submission single change', done => {
|
||||||
@@ -1484,7 +1484,7 @@ limitations under the License.
|
|||||||
'/revert_submission', false, cleanup).then(res => {
|
'/revert_submission', false, cleanup).then(res => {
|
||||||
element._handleResponse({__key: 'revert_submission'}, {}).
|
element._handleResponse({__key: 'revert_submission'}, {}).
|
||||||
then(() => {
|
then(() => {
|
||||||
assert.isTrue(waitForChangeReachableStub.called);
|
assert.isTrue(navigateToSearchQueryStub.called);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1493,12 +1493,16 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('multiple changes revert', () => {
|
suite('multiple changes revert', () => {
|
||||||
let showActionDialogStub;
|
let showActionDialogStub;
|
||||||
|
let navigateToSearchQueryStub;
|
||||||
setup(() => {
|
setup(() => {
|
||||||
getResponseObjectStub
|
getResponseObjectStub
|
||||||
.returns(Promise.resolve({revert_changes: [
|
.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');
|
showActionDialogStub = sandbox.stub(element, '_showActionDialog');
|
||||||
|
navigateToSearchQueryStub = sandbox.stub(Gerrit.Nav,
|
||||||
|
'navigateToSearchQuery');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('revert submission multiple change', done => {
|
test('revert submission multiple change', done => {
|
||||||
@@ -1506,7 +1510,9 @@ limitations under the License.
|
|||||||
'/revert_submission', false, cleanup).then(res => {
|
'/revert_submission', false, cleanup).then(res => {
|
||||||
element._handleResponse({__key: 'revert_submission'}, {}).then(
|
element._handleResponse({__key: 'revert_submission'}, {}).then(
|
||||||
() => {
|
() => {
|
||||||
assert.isTrue(showActionDialogStub.called);
|
assert.isFalse(showActionDialogStub.called);
|
||||||
|
assert.isTrue(navigateToSearchQueryStub.calledWith(
|
||||||
|
'topic: T'));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user