Await plugin load before auto-opening revert dialog
The `?revert` query parameter will automatically open the revert dialog when the change view loads, but would sometimes do so before plugins had a chance to bind listeners for the revert event. With this change, the revert dialog is not automatically opened until all plugins have loaded. Bug: Issue 5189 Change-Id: Id731c2d140e01236175142ea9d3b88d53e3c4709
This commit is contained in:
@@ -445,15 +445,18 @@
|
||||
},
|
||||
|
||||
_maybeShowRevertDialog: function() {
|
||||
this._getLoggedIn().then(function(loggedIn) {
|
||||
if (!loggedIn || this._change.status !== this.ChangeStatus.MERGED) {
|
||||
// Do not display dialog if not logged-in or the change is not merged.
|
||||
return;
|
||||
}
|
||||
if (!!this._getUrlParameter('revert')) {
|
||||
this.$.actions.showRevertDialog();
|
||||
}
|
||||
}.bind(this));
|
||||
Gerrit.awaitPluginsLoaded()
|
||||
.then(this._getLoggedIn.bind(this))
|
||||
.then(function(loggedIn) {
|
||||
if (!loggedIn || this._change.status !== this.ChangeStatus.MERGED) {
|
||||
// Do not display dialog if not logged-in or the change is not
|
||||
// merged.
|
||||
return;
|
||||
}
|
||||
if (!!this._getUrlParameter('revert')) {
|
||||
this.$.actions.showRevertDialog();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_maybeShowReplyDialog: function() {
|
||||
|
||||
@@ -612,6 +612,9 @@ limitations under the License.
|
||||
sandbox.stub(element.$.restAPI, 'getLoggedIn', function() {
|
||||
return Promise.resolve(true);
|
||||
});
|
||||
sandbox.stub(Gerrit, 'awaitPluginsLoaded', function() {
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
element._patchRange = {
|
||||
basePatchNum: 'PARENT',
|
||||
@@ -638,6 +641,7 @@ limitations under the License.
|
||||
done);
|
||||
|
||||
element._maybeShowRevertDialog();
|
||||
assert.isTrue(Gerrit.awaitPluginsLoaded.called);
|
||||
});
|
||||
|
||||
suite('scroll related tests', function() {
|
||||
|
||||
Reference in New Issue
Block a user