Remove alert-based error reporting
Migrates all alert calls to toasts. Also corrects one test that checked for an alert on the window. Bug: Issue 6701 Change-Id: I4d41790f63edc15873014df4f98013ac2bb2af7c
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const ERR_BRANCH_EMPTY = 'The destination branch can’t be empty.';
|
||||
const ERR_COMMIT_EMPTY = 'The commit message can’t be empty.';
|
||||
const ERR_REVISION_ACTIONS = 'Couldn’t load revision actions.';
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
@@ -293,8 +296,7 @@
|
||||
this.revisionActions = revisionActions;
|
||||
this._loading = false;
|
||||
}).catch(err => {
|
||||
alert('Couldn’t load revision actions. Check the console ' +
|
||||
'and contact the PolyGerrit team for assistance.');
|
||||
this.fire('show-alert', {message: ERR_REVISION_ACTIONS});
|
||||
this._loading = false;
|
||||
throw err;
|
||||
});
|
||||
@@ -696,11 +698,11 @@
|
||||
const el = this.$.confirmCherrypick;
|
||||
if (!el.branch) {
|
||||
// TODO(davido): Fix error handling
|
||||
alert('The destination branch can’t be empty.');
|
||||
this.fire('show-alert', {message: ERR_BRANCH_EMPTY});
|
||||
return;
|
||||
}
|
||||
if (!el.message) {
|
||||
alert('The commit message can’t be empty.');
|
||||
this.fire('show-alert', {message: ERR_COMMIT_EMPTY});
|
||||
return;
|
||||
}
|
||||
this.$.overlay.close();
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const ERR_COMMIT_NOT_FOUND =
|
||||
'Unable to find the commit hash of this change.';
|
||||
|
||||
Polymer({
|
||||
is: 'gr-confirm-revert-dialog',
|
||||
|
||||
@@ -38,7 +41,7 @@
|
||||
const originalTitle = message.split('\n')[0];
|
||||
const revertTitle = `Revert "${originalTitle}"`;
|
||||
if (!commitHash) {
|
||||
alert('Unable to find the commit hash of this change.');
|
||||
this.fire('show-alert', {message: ERR_COMMIT_NOT_FOUND});
|
||||
return;
|
||||
}
|
||||
const revertCommitText = `This reverts commit ${commitHash}.`;
|
||||
|
||||
@@ -34,17 +34,21 @@ limitations under the License.
|
||||
<script>
|
||||
suite('gr-confirm-revert-dialog tests', () => {
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
setup(() => {
|
||||
element = fixture('basic');
|
||||
sandbox =sinon.sandbox.create();
|
||||
});
|
||||
|
||||
teardown(() => sandbox.restore());
|
||||
|
||||
test('no match', () => {
|
||||
assert.isNotOk(element.message);
|
||||
const alertStub = sinon.stub(window, 'alert');
|
||||
const alertStub = sandbox.stub();
|
||||
element.addEventListener('show-alert', alertStub);
|
||||
element.populateRevertMessage('not a commitHash in sight', undefined);
|
||||
assert.isTrue(alertStub.calledOnce);
|
||||
alertStub.restore();
|
||||
});
|
||||
|
||||
test('single line', () => {
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
const COMMIT_MESSAGE_PATH = '/COMMIT_MSG';
|
||||
const MERGE_LIST_PATH = '/MERGE_LIST';
|
||||
|
||||
const ERR_REVIEW_STATUS = 'Couldn’t change file review status.';
|
||||
|
||||
const COMMENT_SAVE = 'Try again when all comments have saved.';
|
||||
|
||||
const DiffSides = {
|
||||
@@ -191,8 +193,7 @@
|
||||
_setReviewed(reviewed) {
|
||||
this.$.reviewed.checked = reviewed;
|
||||
this._saveReviewedState(reviewed).catch(err => {
|
||||
alert('Couldn’t change file review status. Check the console ' +
|
||||
'and contact the PolyGerrit team for assistance.');
|
||||
this.fire('show-alert', {message: ERR_REVIEW_STATUS});
|
||||
throw err;
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user