Set composed: true on all bubbled events
In Polymer 2, and when using native shadow DOM, events that do not have `composed: true` set do not cross shadow DOM boundaries. I cross checked and all these events seem to be handled outside of the component that fires them, so they need this. Change-Id: Iee8d2d545f3b1ea0bfb624648637fd190b952feb
This commit is contained in:
@@ -95,7 +95,8 @@
|
|||||||
// For a new section, this is not fired because new permissions and
|
// For a new section, this is not fired because new permissions and
|
||||||
// rules have to be added in order to save, modifying the ref is not
|
// rules have to be added in order to save, modifying the ref is not
|
||||||
// enough.
|
// enough.
|
||||||
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
|
this.dispatchEvent(new CustomEvent(
|
||||||
|
'access-modified', {bubbles: true, composed: true}));
|
||||||
}
|
}
|
||||||
this.section.value.updatedId = this.section.id;
|
this.section.value.updatedId = this.section.id;
|
||||||
},
|
},
|
||||||
@@ -199,12 +200,13 @@
|
|||||||
|
|
||||||
_handleRemoveReference() {
|
_handleRemoveReference() {
|
||||||
if (this.section.value.added) {
|
if (this.section.value.added) {
|
||||||
this.dispatchEvent(new CustomEvent('added-section-removed',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{bubbles: true}));
|
'added-section-removed', {bubbles: true, composed: true}));
|
||||||
}
|
}
|
||||||
this._deleted = true;
|
this._deleted = true;
|
||||||
this.section.value.deleted = true;
|
this.section.value.deleted = true;
|
||||||
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('access-modified', {bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleUndoRemove() {
|
_handleUndoRemove() {
|
||||||
|
|||||||
@@ -205,6 +205,7 @@
|
|||||||
this.dispatchEvent(new CustomEvent('show-alert', {
|
this.dispatchEvent(new CustomEvent('show-alert', {
|
||||||
detail: {message: SAVING_ERROR_TEXT},
|
detail: {message: SAVING_ERROR_TEXT},
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
}));
|
}));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,17 +137,19 @@
|
|||||||
_handleValueChange() {
|
_handleValueChange() {
|
||||||
this.permission.value.modified = true;
|
this.permission.value.modified = true;
|
||||||
// Allows overall access page to know a change has been made.
|
// Allows overall access page to know a change has been made.
|
||||||
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('access-modified', {bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleRemovePermission() {
|
_handleRemovePermission() {
|
||||||
if (this.permission.value.added) {
|
if (this.permission.value.added) {
|
||||||
this.dispatchEvent(new CustomEvent('added-permission-removed',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{bubbles: true}));
|
'added-permission-removed', {bubbles: true, composed: true}));
|
||||||
}
|
}
|
||||||
this._deleted = true;
|
this._deleted = true;
|
||||||
this.permission.value.deleted = true;
|
this.permission.value.deleted = true;
|
||||||
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('access-modified', {bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleRulesChanged(changeRecord) {
|
_handleRulesChanged(changeRecord) {
|
||||||
@@ -273,7 +275,8 @@
|
|||||||
const value = this._rules[this._rules.length - 1].value;
|
const value = this._rules[this._rules.length - 1].value;
|
||||||
value.added = true;
|
value.added = true;
|
||||||
this.set(['permission', 'value', 'rules', groupId], value);
|
this.set(['permission', 'value', 'rules', groupId], value);
|
||||||
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('access-modified', {bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeHasRange(name) {
|
_computeHasRange(name) {
|
||||||
|
|||||||
@@ -406,8 +406,11 @@
|
|||||||
if (!Object.keys(addRemoveObj.add).length &&
|
if (!Object.keys(addRemoveObj.add).length &&
|
||||||
!Object.keys(addRemoveObj.remove).length &&
|
!Object.keys(addRemoveObj.remove).length &&
|
||||||
!addRemoveObj.parent) {
|
!addRemoveObj.parent) {
|
||||||
this.dispatchEvent(new CustomEvent('show-alert',
|
this.dispatchEvent(new CustomEvent('show-alert', {
|
||||||
{detail: {message: NOTHING_TO_SAVE}, bubbles: true}));
|
detail: {message: NOTHING_TO_SAVE},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const obj = {
|
const obj = {
|
||||||
|
|||||||
@@ -34,7 +34,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
_onCommandTap() {
|
_onCommandTap() {
|
||||||
this.dispatchEvent(new CustomEvent('command-tap', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('command-tap', {bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -75,8 +75,9 @@
|
|||||||
_handleRunningGC() {
|
_handleRunningGC() {
|
||||||
return this.$.restAPI.runRepoGC(this.repo).then(response => {
|
return this.$.restAPI.runRepoGC(this.repo).then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
this.dispatchEvent(new CustomEvent('show-alert',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{detail: {message: GC_MESSAGE}, bubbles: true}));
|
'show-alert',
|
||||||
|
{detail: {message: GC_MESSAGE}, bubbles: true, composed: true}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -100,8 +101,9 @@
|
|||||||
const message = change ?
|
const message = change ?
|
||||||
CREATE_CHANGE_SUCCEEDED_MESSAGE :
|
CREATE_CHANGE_SUCCEEDED_MESSAGE :
|
||||||
CREATE_CHANGE_FAILED_MESSAGE;
|
CREATE_CHANGE_FAILED_MESSAGE;
|
||||||
this.dispatchEvent(new CustomEvent('show-alert',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{detail: {message}, bubbles: true}));
|
'show-alert',
|
||||||
|
{detail: {message}, bubbles: true, composed: true}));
|
||||||
if (!change) { return; }
|
if (!change) { return; }
|
||||||
|
|
||||||
Gerrit.Nav.navigateToRelativeUrl(Gerrit.Nav.getEditUrlForDiff(
|
Gerrit.Nav.navigateToRelativeUrl(Gerrit.Nav.getEditUrlForDiff(
|
||||||
|
|||||||
@@ -123,8 +123,8 @@
|
|||||||
notifyPath: `${name}.${notifyPath}`,
|
notifyPath: `${name}.${notifyPath}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent(this.PLUGIN_CONFIG_CHANGED,
|
this.dispatchEvent(new CustomEvent(
|
||||||
{detail, bubbles: true}));
|
this.PLUGIN_CONFIG_CHANGED, {detail, bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ limitations under the License.
|
|||||||
const select = element.$$('select');
|
const select = element.$$('select');
|
||||||
assert.ok(select);
|
assert.ok(select);
|
||||||
select.value = 'newTest';
|
select.value = 'newTest';
|
||||||
select.dispatchEvent(new Event('change', {bubbles: true}));
|
select.dispatchEvent(new Event(
|
||||||
|
'change', {bubbles: true, composed: true}));
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
assert.isTrue(buildStub.called);
|
assert.isTrue(buildStub.called);
|
||||||
|
|||||||
@@ -210,12 +210,13 @@
|
|||||||
|
|
||||||
_handleRemoveRule() {
|
_handleRemoveRule() {
|
||||||
if (this.rule.value.added) {
|
if (this.rule.value.added) {
|
||||||
this.dispatchEvent(new CustomEvent('added-rule-removed',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{bubbles: true}));
|
'added-rule-removed', {bubbles: true, composed: true}));
|
||||||
}
|
}
|
||||||
this._deleted = true;
|
this._deleted = true;
|
||||||
this.rule.value.deleted = true;
|
this.rule.value.deleted = true;
|
||||||
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('access-modified', {bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleUndoRemove() {
|
_handleUndoRemove() {
|
||||||
@@ -237,7 +238,8 @@
|
|||||||
if (!this._originalRuleValues) { return; }
|
if (!this._originalRuleValues) { return; }
|
||||||
this.rule.value.modified = true;
|
this.rule.value.modified = true;
|
||||||
// Allows overall access page to know a change has been made.
|
// Allows overall access page to know a change has been made.
|
||||||
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('access-modified', {bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_setOriginalRuleValues(value) {
|
_setOriginalRuleValues(value) {
|
||||||
|
|||||||
@@ -214,6 +214,7 @@
|
|||||||
this.set('change.reviewed', newVal);
|
this.set('change.reviewed', newVal);
|
||||||
this.dispatchEvent(new CustomEvent('toggle-reviewed', {
|
this.dispatchEvent(new CustomEvent('toggle-reviewed', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
detail: {change: this.change, reviewed: newVal},
|
detail: {change: this.change, reviewed: newVal},
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
|
|
||||||
_handleCreateTap(e) {
|
_handleCreateTap(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.dispatchEvent(new CustomEvent('create-tap', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('create-tap', {bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -118,8 +118,8 @@
|
|||||||
|
|
||||||
_inputTextChanged(text) {
|
_inputTextChanged(text) {
|
||||||
if (text.length && this.allowAnyInput) {
|
if (text.length && this.allowAnyInput) {
|
||||||
this.dispatchEvent(new CustomEvent('account-text-changed',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{bubbles: true}));
|
'account-text-changed', {bubbles: true, composed: true}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -123,8 +123,11 @@
|
|||||||
// Repopulate the input with what the user tried to enter and have
|
// Repopulate the input with what the user tried to enter and have
|
||||||
// a toast tell them why they can't enter it.
|
// a toast tell them why they can't enter it.
|
||||||
this.$.entry.setText(reviewer);
|
this.$.entry.setText(reviewer);
|
||||||
this.dispatchEvent(new CustomEvent('show-alert',
|
this.dispatchEvent(new CustomEvent('show-alert', {
|
||||||
{detail: {message: VALID_EMAIL_ALERT}, bubbles: true}));
|
detail: {message: VALID_EMAIL_ALERT},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
}));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
const account = {email: reviewer, _pendingAdd: true};
|
const account = {email: reviewer, _pendingAdd: true};
|
||||||
|
|||||||
@@ -221,8 +221,8 @@
|
|||||||
this._settingTopic = false;
|
this._settingTopic = false;
|
||||||
this.set(['change', 'topic'], newTopic);
|
this.set(['change', 'topic'], newTopic);
|
||||||
if (newTopic !== lastTopic) {
|
if (newTopic !== lastTopic) {
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(new CustomEvent(
|
||||||
new CustomEvent('topic-changed', {bubbles: true}));
|
'topic-changed', {bubbles: true, composed: true}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -246,8 +246,8 @@
|
|||||||
this.change._number, {add: [newHashtag]}).then(newHashtag => {
|
this.change._number, {add: [newHashtag]}).then(newHashtag => {
|
||||||
this.set(['change', 'hashtags'], newHashtag);
|
this.set(['change', 'hashtags'], newHashtag);
|
||||||
if (newHashtag !== lastHashtag) {
|
if (newHashtag !== lastHashtag) {
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(new CustomEvent(
|
||||||
new CustomEvent('hashtag-changed', {bubbles: true}));
|
'hashtag-changed', {bubbles: true, composed: true}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -378,7 +378,7 @@
|
|||||||
target.disabled = false;
|
target.disabled = false;
|
||||||
this.set(['change', 'topic'], '');
|
this.set(['change', 'topic'], '');
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CustomEvent('topic-changed', {bubbles: true}));
|
new CustomEvent('topic-changed', {bubbles: true, composed: true}));
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
target.disabled = false;
|
target.disabled = false;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1599,32 +1599,44 @@ limitations under the License.
|
|||||||
sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl');
|
sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl');
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
fileList.dispatchEvent(new CustomEvent('file-action-tap',
|
fileList.dispatchEvent(new CustomEvent('file-action-tap', {
|
||||||
{detail: {action: Actions.DELETE.id, path: 'foo'}, bubbles: true}));
|
detail: {action: Actions.DELETE.id, path: 'foo'},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
}));
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
assert.isTrue(controls.openDeleteDialog.called);
|
assert.isTrue(controls.openDeleteDialog.called);
|
||||||
assert.equal(controls.openDeleteDialog.lastCall.args[0], 'foo');
|
assert.equal(controls.openDeleteDialog.lastCall.args[0], 'foo');
|
||||||
|
|
||||||
// Restore
|
// Restore
|
||||||
fileList.dispatchEvent(new CustomEvent('file-action-tap',
|
fileList.dispatchEvent(new CustomEvent('file-action-tap', {
|
||||||
{detail: {action: Actions.RESTORE.id, path: 'foo'}, bubbles: true}));
|
detail: {action: Actions.RESTORE.id, path: 'foo'},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
}));
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
assert.isTrue(controls.openRestoreDialog.called);
|
assert.isTrue(controls.openRestoreDialog.called);
|
||||||
assert.equal(controls.openRestoreDialog.lastCall.args[0], 'foo');
|
assert.equal(controls.openRestoreDialog.lastCall.args[0], 'foo');
|
||||||
|
|
||||||
// Rename
|
// Rename
|
||||||
fileList.dispatchEvent(new CustomEvent('file-action-tap',
|
fileList.dispatchEvent(new CustomEvent('file-action-tap', {
|
||||||
{detail: {action: Actions.RENAME.id, path: 'foo'}, bubbles: true}));
|
detail: {action: Actions.RENAME.id, path: 'foo'},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
}));
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
assert.isTrue(controls.openRenameDialog.called);
|
assert.isTrue(controls.openRenameDialog.called);
|
||||||
assert.equal(controls.openRenameDialog.lastCall.args[0], 'foo');
|
assert.equal(controls.openRenameDialog.lastCall.args[0], 'foo');
|
||||||
|
|
||||||
// Open
|
// Open
|
||||||
fileList.dispatchEvent(new CustomEvent('file-action-tap',
|
fileList.dispatchEvent(new CustomEvent('file-action-tap', {
|
||||||
{detail: {action: Actions.OPEN.id, path: 'foo'}, bubbles: true}));
|
detail: {action: Actions.OPEN.id, path: 'foo'},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
}));
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
assert.isTrue(Gerrit.Nav.getEditUrlForDiff.called);
|
assert.isTrue(Gerrit.Nav.getEditUrlForDiff.called);
|
||||||
|
|||||||
@@ -133,7 +133,8 @@
|
|||||||
const name = e.target.selectedItem.name;
|
const name = e.target.selectedItem.name;
|
||||||
const value = e.target.selectedItem.getAttribute('value');
|
const value = e.target.selectedItem.getAttribute('value');
|
||||||
this.dispatchEvent(new CustomEvent(
|
this.dispatchEvent(new CustomEvent(
|
||||||
'labels-changed', {detail: {name, value}, bubbles: true}));
|
'labels-changed',
|
||||||
|
{detail: {name, value}, bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeAnyPermittedLabelValues(permittedLabels, label) {
|
_computeAnyPermittedLabelValues(permittedLabels, label) {
|
||||||
|
|||||||
@@ -228,6 +228,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.dispatchEvent(new CustomEvent('message-anchor-tap', {
|
this.dispatchEvent(new CustomEvent('message-anchor-tap', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
detail: {id: this.message.id},
|
detail: {id: this.message.id},
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -150,7 +150,8 @@ limitations under the License.
|
|||||||
flush(() => {
|
flush(() => {
|
||||||
const textarea = element.$.textarea.getNativeTextarea();
|
const textarea = element.$.textarea.getNativeTextarea();
|
||||||
textarea.value = 'LGTM';
|
textarea.value = 'LGTM';
|
||||||
textarea.dispatchEvent(new CustomEvent('input', {bubbles: true}));
|
textarea.dispatchEvent(new CustomEvent(
|
||||||
|
'input', {bubbles: true, composed: true}));
|
||||||
const labelScoreRows = Polymer.dom(element.$.labelScores.root)
|
const labelScoreRows = Polymer.dom(element.$.labelScores.root)
|
||||||
.querySelector('gr-label-score-row[name="Code-Review"]');
|
.querySelector('gr-label-score-row[name="Code-Review"]');
|
||||||
const selectedBtn = Polymer.dom(labelScoreRows.root)
|
const selectedBtn = Polymer.dom(labelScoreRows.root)
|
||||||
|
|||||||
@@ -749,6 +749,7 @@
|
|||||||
if (this._sendDisabled) {
|
if (this._sendDisabled) {
|
||||||
this.dispatchEvent(new CustomEvent('show-alert', {
|
this.dispatchEvent(new CustomEvent('show-alert', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
detail: {message: EMPTY_REPLY_MESSAGE},
|
detail: {message: EMPTY_REPLY_MESSAGE},
|
||||||
}));
|
}));
|
||||||
return;
|
return;
|
||||||
@@ -756,9 +757,11 @@
|
|||||||
return this.send(this._includeComments, this.canBeStarted)
|
return this.send(this._includeComments, this.canBeStarted)
|
||||||
.then(keepReviewers => {
|
.then(keepReviewers => {
|
||||||
this._purgeReviewersPendingRemove(false, keepReviewers);
|
this._purgeReviewersPendingRemove(false, keepReviewers);
|
||||||
}).catch(err => {
|
})
|
||||||
|
.catch(err => {
|
||||||
this.dispatchEvent(new CustomEvent('show-error', {
|
this.dispatchEvent(new CustomEvent('show-error', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
detail: {message: `Error submitting review ${err}`},
|
detail: {message: `Error submitting review ${err}`},
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ limitations under the License.
|
|||||||
assert.isTrue(element.$$('#ccs').allowAnyInput);
|
assert.isTrue(element.$$('#ccs').allowAnyInput);
|
||||||
assert.isFalse(element.$$('#reviewers').allowAnyInput);
|
assert.isFalse(element.$$('#reviewers').allowAnyInput);
|
||||||
element.$$('#ccs').dispatchEvent(new CustomEvent('account-text-changed',
|
element.$$('#ccs').dispatchEvent(new CustomEvent('account-text-changed',
|
||||||
{bubbles: true}));
|
{bubbles: true, composed: true}));
|
||||||
assert.isTrue(element._reviewersMutated);
|
assert.isTrue(element._reviewersMutated);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,8 @@ limitations under the License.
|
|||||||
|
|
||||||
const isBinary = !!(this.isImageDiff || this.diff.binary);
|
const isBinary = !!(this.isImageDiff || this.diff.binary);
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent('render-start', {bubbles: true}));
|
this.dispatchEvent(new CustomEvent(
|
||||||
|
'render-start', {bubbles: true, composed: true}));
|
||||||
this._cancelableRenderPromise = util.makeCancelable(
|
this._cancelableRenderPromise = util.makeCancelable(
|
||||||
this.$.processor.process(this.diff.content, isBinary)
|
this.$.processor.process(this.diff.content, isBinary)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -187,7 +188,7 @@ limitations under the License.
|
|||||||
this._builder.renderDiff();
|
this._builder.renderDiff();
|
||||||
}
|
}
|
||||||
this.dispatchEvent(new CustomEvent('render-content',
|
this.dispatchEvent(new CustomEvent('render-content',
|
||||||
{bubbles: true}));
|
{bubbles: true, composed: true}));
|
||||||
|
|
||||||
if (this._diffTooLargeForSyntax()) {
|
if (this._diffTooLargeForSyntax()) {
|
||||||
this.$.syntaxLayer.enabled = false;
|
this.$.syntaxLayer.enabled = false;
|
||||||
@@ -196,8 +197,8 @@ limitations under the License.
|
|||||||
return this.$.syntaxLayer.process();
|
return this.$.syntaxLayer.process();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(new CustomEvent(
|
||||||
new CustomEvent('render-syntax', {bubbles: true}));
|
'render-syntax', {bubbles: true, composed: true}));
|
||||||
}));
|
}));
|
||||||
return this._cancelableRenderPromise
|
return this._cancelableRenderPromise
|
||||||
.finally(() => { this._cancelableRenderPromise = null; })
|
.finally(() => { this._cancelableRenderPromise = null; })
|
||||||
@@ -313,7 +314,7 @@ limitations under the License.
|
|||||||
this.dispatchEvent(new CustomEvent('show-alert', {
|
this.dispatchEvent(new CustomEvent('show-alert', {
|
||||||
detail: {
|
detail: {
|
||||||
message,
|
message,
|
||||||
}, bubbles: true}));
|
}, bubbles: true, composed: true}));
|
||||||
throw Error(`Invalid preference value: ${pref}`);
|
throw Error(`Invalid preference value: ${pref}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -179,8 +179,8 @@ limitations under the License.
|
|||||||
element.commentRanges = [{side: 'right'}];
|
element.commentRanges = [{side: 'right'}];
|
||||||
|
|
||||||
sandbox.stub(element, 'set');
|
sandbox.stub(element, 'set');
|
||||||
threadEl.dispatchEvent(
|
threadEl.dispatchEvent(new CustomEvent(
|
||||||
new CustomEvent('comment-thread-mouseenter', {bubbles: true}));
|
'comment-thread-mouseenter', {bubbles: true, composed: true}));
|
||||||
assert.isFalse(element.set.called);
|
assert.isFalse(element.set.called);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -204,8 +204,8 @@ limitations under the License.
|
|||||||
}}];
|
}}];
|
||||||
|
|
||||||
sandbox.stub(element, 'set');
|
sandbox.stub(element, 'set');
|
||||||
threadEl.dispatchEvent(
|
threadEl.dispatchEvent(new CustomEvent(
|
||||||
new CustomEvent('comment-thread-mouseenter', {bubbles: true}));
|
'comment-thread-mouseenter', {bubbles: true, composed: true}));
|
||||||
assert.isTrue(element.set.called);
|
assert.isTrue(element.set.called);
|
||||||
const args = element.set.lastCall.args;
|
const args = element.set.lastCall.args;
|
||||||
assert.deepEqual(args[0], ['commentRanges', 0, 'hovering']);
|
assert.deepEqual(args[0], ['commentRanges', 0, 'hovering']);
|
||||||
@@ -221,8 +221,8 @@ limitations under the License.
|
|||||||
element.commentRanges = [{side: 'right'}];
|
element.commentRanges = [{side: 'right'}];
|
||||||
|
|
||||||
sandbox.stub(element, 'set');
|
sandbox.stub(element, 'set');
|
||||||
threadEl.dispatchEvent(
|
threadEl.dispatchEvent(new CustomEvent(
|
||||||
new CustomEvent('comment-thread-mouseleave', {bubbles: true}));
|
'comment-thread-mouseleave', {bubbles: true, composed: true}));
|
||||||
assert.isFalse(element.set.called);
|
assert.isFalse(element.set.called);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,9 @@
|
|||||||
commitRange: Object,
|
commitRange: Object,
|
||||||
filesWeblinks: {
|
filesWeblinks: {
|
||||||
type: Object,
|
type: Object,
|
||||||
value() { return {}; },
|
value() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
notify: true,
|
notify: true,
|
||||||
},
|
},
|
||||||
hidden: {
|
hidden: {
|
||||||
@@ -309,7 +311,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_getFilesWeblinks(diff) {
|
_getFilesWeblinks(diff) {
|
||||||
if (!this.commitRange) { return {}; }
|
if (!this.commitRange) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
meta_a: Gerrit.Nav.getFileWebLinks(
|
meta_a: Gerrit.Nav.getFileWebLinks(
|
||||||
this.projectName, this.commitRange.baseCommit, this.path,
|
this.projectName, this.commitRange.baseCommit, this.path,
|
||||||
@@ -435,7 +439,9 @@
|
|||||||
* Report info about the diff response.
|
* Report info about the diff response.
|
||||||
*/
|
*/
|
||||||
_reportDiff(diff) {
|
_reportDiff(diff) {
|
||||||
if (!diff || !diff.content) { return; }
|
if (!diff || !diff.content) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Count the delta lines stemming from normal deltas, and from
|
// Count the delta lines stemming from normal deltas, and from
|
||||||
// due_to_rebase deltas.
|
// due_to_rebase deltas.
|
||||||
@@ -663,7 +669,7 @@
|
|||||||
* @param {!Gerrit.Range=} range
|
* @param {!Gerrit.Range=} range
|
||||||
* @return {?Node}
|
* @return {?Node}
|
||||||
*/
|
*/
|
||||||
_getThreadEl(lineNum, commentSide, range=undefined) {
|
_getThreadEl(lineNum, commentSide, range = undefined) {
|
||||||
let line;
|
let line;
|
||||||
if (commentSide === GrDiffBuilder.Side.LEFT) {
|
if (commentSide === GrDiffBuilder.Side.LEFT) {
|
||||||
line = {beforeNumber: lineNum};
|
line = {beforeNumber: lineNum};
|
||||||
@@ -778,7 +784,8 @@
|
|||||||
return this.prefs.ignore_whitespace;
|
return this.prefs.ignore_whitespace;
|
||||||
},
|
},
|
||||||
|
|
||||||
_whitespaceChanged(preferredWhitespaceLevel, loadedWhitespaceLevel,
|
_whitespaceChanged(
|
||||||
|
preferredWhitespaceLevel, loadedWhitespaceLevel,
|
||||||
noRenderOnPrefsChange) {
|
noRenderOnPrefsChange) {
|
||||||
if (preferredWhitespaceLevel !== loadedWhitespaceLevel &&
|
if (preferredWhitespaceLevel !== loadedWhitespaceLevel &&
|
||||||
!noRenderOnPrefsChange) {
|
!noRenderOnPrefsChange) {
|
||||||
@@ -831,8 +838,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_handleCommentSaveOrDiscard() {
|
_handleCommentSaveOrDiscard() {
|
||||||
this.dispatchEvent(new CustomEvent('diff-comments-modified',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{bubbles: true}));
|
'diff-comments-modified', {bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeComment(comment) {
|
_removeComment(comment) {
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ limitations under the License.
|
|||||||
suite('render reporting', () => {
|
suite('render reporting', () => {
|
||||||
test('starts total and content timer on render-start', done => {
|
test('starts total and content timer on render-start', done => {
|
||||||
element.dispatchEvent(
|
element.dispatchEvent(
|
||||||
new CustomEvent('render-start', {bubbles: true}));
|
new CustomEvent('render-start', {bubbles: true, composed: true}));
|
||||||
assert.isTrue(element.$.reporting.time.calledWithExactly(
|
assert.isTrue(element.$.reporting.time.calledWithExactly(
|
||||||
'Diff Total Render'));
|
'Diff Total Render'));
|
||||||
assert.isTrue(element.$.reporting.time.calledWithExactly(
|
assert.isTrue(element.$.reporting.time.calledWithExactly(
|
||||||
@@ -279,7 +279,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('ends content and starts syntax timer on render-content', done => {
|
test('ends content and starts syntax timer on render-content', done => {
|
||||||
element.dispatchEvent(
|
element.dispatchEvent(
|
||||||
new CustomEvent('render-content', {bubbles: true}));
|
new CustomEvent('render-content', {bubbles: true, composed: true}));
|
||||||
assert.isTrue(element.$.reporting.time.calledWithExactly(
|
assert.isTrue(element.$.reporting.time.calledWithExactly(
|
||||||
'Diff Syntax Render'));
|
'Diff Syntax Render'));
|
||||||
assert.isTrue(element.$.reporting.timeEnd.calledWithExactly(
|
assert.isTrue(element.$.reporting.timeEnd.calledWithExactly(
|
||||||
@@ -289,7 +289,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('ends total and syntax timer on render-syntax', done => {
|
test('ends total and syntax timer on render-syntax', done => {
|
||||||
element.dispatchEvent(
|
element.dispatchEvent(
|
||||||
new CustomEvent('render-syntax', {bubbles: true}));
|
new CustomEvent('render-syntax', {bubbles: true, composed: true}));
|
||||||
assert.isTrue(element.$.reporting.timeEnd.calledWithExactly(
|
assert.isTrue(element.$.reporting.timeEnd.calledWithExactly(
|
||||||
'Diff Total Render'));
|
'Diff Total Render'));
|
||||||
assert.isTrue(element.$.reporting.timeEnd.calledWithExactly(
|
assert.isTrue(element.$.reporting.timeEnd.calledWithExactly(
|
||||||
|
|||||||
@@ -390,12 +390,12 @@
|
|||||||
_redispatchHoverEvents(addedThreadEls) {
|
_redispatchHoverEvents(addedThreadEls) {
|
||||||
for (const threadEl of addedThreadEls) {
|
for (const threadEl of addedThreadEls) {
|
||||||
threadEl.addEventListener('mouseenter', () => {
|
threadEl.addEventListener('mouseenter', () => {
|
||||||
threadEl.dispatchEvent(
|
threadEl.dispatchEvent(new CustomEvent(
|
||||||
new CustomEvent('comment-thread-mouseenter', {bubbles: true}));
|
'comment-thread-mouseenter', {bubbles: true, composed: true}));
|
||||||
});
|
});
|
||||||
threadEl.addEventListener('mouseleave', () => {
|
threadEl.addEventListener('mouseleave', () => {
|
||||||
threadEl.dispatchEvent(
|
threadEl.dispatchEvent(new CustomEvent(
|
||||||
new CustomEvent('comment-thread-mouseleave', {bubbles: true}));
|
'comment-thread-mouseleave', {bubbles: true, composed: true}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -551,6 +551,7 @@
|
|||||||
this._getIsParentCommentByLineAndContent(lineEl, contentEl);
|
this._getIsParentCommentByLineAndContent(lineEl, contentEl);
|
||||||
this.dispatchEvent(new CustomEvent('create-comment', {
|
this.dispatchEvent(new CustomEvent('create-comment', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
detail: {
|
detail: {
|
||||||
lineNum,
|
lineNum,
|
||||||
side,
|
side,
|
||||||
@@ -727,14 +728,16 @@
|
|||||||
_renderDiffTable() {
|
_renderDiffTable() {
|
||||||
this._unobserveIncrementalNodes();
|
this._unobserveIncrementalNodes();
|
||||||
if (!this.prefs) {
|
if (!this.prefs) {
|
||||||
this.dispatchEvent(new CustomEvent('render', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('render', {bubbles: true, composed: true}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.prefs.context === -1 &&
|
if (this.prefs.context === -1 &&
|
||||||
this._diffLength >= LARGE_DIFF_THRESHOLD_LINES &&
|
this._diffLength >= LARGE_DIFF_THRESHOLD_LINES &&
|
||||||
this._safetyBypass === null) {
|
this._safetyBypass === null) {
|
||||||
this._showWarning = true;
|
this._showWarning = true;
|
||||||
this.dispatchEvent(new CustomEvent('render', {bubbles: true}));
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('render', {bubbles: true, composed: true}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,7 +747,7 @@
|
|||||||
this.$.diffBuilder.render(keyLocations, this._getBypassPrefs())
|
this.$.diffBuilder.render(keyLocations, this._getBypassPrefs())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CustomEvent('render', {bubbles: true}));
|
new CustomEvent('render', {bubbles: true, composed: true}));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -762,7 +762,7 @@ limitations under the License.
|
|||||||
() => {
|
() => {
|
||||||
Promise.resolve();
|
Promise.resolve();
|
||||||
element.$.diffBuilder.dispatchEvent(
|
element.$.diffBuilder.dispatchEvent(
|
||||||
new CustomEvent('render', {bubbles: true}));
|
new CustomEvent('render', {bubbles: true, composed: true}));
|
||||||
});
|
});
|
||||||
const mock = document.createElement('mock-diff-response');
|
const mock = document.createElement('mock-diff-response');
|
||||||
sandbox.stub(element.$.diffBuilder, 'getDiffLength').returns(10000);
|
sandbox.stub(element.$.diffBuilder, 'getDiffLength').returns(10000);
|
||||||
|
|||||||
@@ -188,6 +188,7 @@
|
|||||||
range.end = line.text.length;
|
range.end = line.text.length;
|
||||||
this.dispatchEvent(new CustomEvent('normalize-range', {
|
this.dispatchEvent(new CustomEvent('normalize-range', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
detail: {lineNum, side},
|
detail: {lineNum, side},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_handleTextareaInput(e) {
|
_handleTextareaInput(e) {
|
||||||
this.dispatchEvent(new CustomEvent('content-change',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{detail: {value: e.target.value}, bubbles: true}));
|
'content-change',
|
||||||
|
{detail: {value: e.target.value}, bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ limitations under the License.
|
|||||||
element.addEventListener('content-change', contentChangedHandler);
|
element.addEventListener('content-change', contentChangedHandler);
|
||||||
textarea.value = 'test';
|
textarea.value = 'test';
|
||||||
textarea.dispatchEvent(new CustomEvent('input',
|
textarea.dispatchEvent(new CustomEvent('input',
|
||||||
{target: textarea, bubbles: true}));
|
{target: textarea, bubbles: true, composed: true}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -46,8 +46,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_dispatchFileAction(action, path) {
|
_dispatchFileAction(action, path) {
|
||||||
this.dispatchEvent(new CustomEvent('file-action-tap',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{detail: {action, path}, bubbles: true}));
|
'file-action-tap',
|
||||||
|
{detail: {action, path}, bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeFileActions(actions) {
|
_computeFileActions(actions) {
|
||||||
|
|||||||
@@ -104,7 +104,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_paramsChanged(value) {
|
_paramsChanged(value) {
|
||||||
if (value.view !== Gerrit.Nav.View.EDIT) { return; }
|
if (value.view !== Gerrit.Nav.View.EDIT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._changeNum = value.changeNum;
|
this._changeNum = value.changeNum;
|
||||||
this._path = value.path;
|
this._path = value.path;
|
||||||
@@ -134,7 +136,9 @@
|
|||||||
|
|
||||||
_handlePathChanged(e) {
|
_handlePathChanged(e) {
|
||||||
const path = e.detail;
|
const path = e.detail;
|
||||||
if (path === this._path) { return Promise.resolve(); }
|
if (path === this._path) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
return this.$.restAPI.renameFileInChangeEdit(this._changeNum,
|
return this.$.restAPI.renameFileInChangeEdit(this._changeNum,
|
||||||
this._path, path).then(res => {
|
this._path, path).then(res => {
|
||||||
if (!res.ok) { return; }
|
if (!res.ok) { return; }
|
||||||
@@ -158,8 +162,11 @@
|
|||||||
.then(res => {
|
.then(res => {
|
||||||
if (storedContent && storedContent.message &&
|
if (storedContent && storedContent.message &&
|
||||||
storedContent.message !== res.content) {
|
storedContent.message !== res.content) {
|
||||||
this.dispatchEvent(new CustomEvent('show-alert',
|
this.dispatchEvent(new CustomEvent('show-alert', {
|
||||||
{detail: {message: RESTORED_MESSAGE}, bubbles: true}));
|
detail: {message: RESTORED_MESSAGE},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
}));
|
||||||
|
|
||||||
this._newContent = storedContent.message;
|
this._newContent = storedContent.message;
|
||||||
} else {
|
} else {
|
||||||
@@ -197,11 +204,14 @@
|
|||||||
this.dispatchEvent(new CustomEvent('show-alert', {
|
this.dispatchEvent(new CustomEvent('show-alert', {
|
||||||
detail: {message},
|
detail: {message},
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeSaveDisabled(content, newContent, saving) {
|
_computeSaveDisabled(content, newContent, saving) {
|
||||||
if (saving) { return true; }
|
if (saving) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return content === newContent;
|
return content === newContent;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -224,7 +234,9 @@
|
|||||||
|
|
||||||
_handleSaveShortcut(e) {
|
_handleSaveShortcut(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!this._saveDisabled) { this._saveEdit(); }
|
if (!this._saveDisabled) {
|
||||||
|
this._saveEdit();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ suite('gr-editor-view tests', () => {
|
|||||||
const storeStub = sandbox.spy(element.$.storage, 'setEditableContentItem');
|
const storeStub = sandbox.spy(element.$.storage, 'setEditableContentItem');
|
||||||
element._newContent = 'test';
|
element._newContent = 'test';
|
||||||
element.$.editorEndpoint.dispatchEvent(new CustomEvent('content-change', {
|
element.$.editorEndpoint.dispatchEvent(new CustomEvent('content-change', {
|
||||||
bubbles: true,
|
bubbles: true, composed: true,
|
||||||
detail: {value: 'new content value'},
|
detail: {value: 'new content value'},
|
||||||
}));
|
}));
|
||||||
element.flushDebouncer('store');
|
element.flushDebouncer('store');
|
||||||
|
|||||||
@@ -66,7 +66,9 @@
|
|||||||
|
|
||||||
_getAgreementsUrl(configUrl) {
|
_getAgreementsUrl(configUrl) {
|
||||||
let url;
|
let url;
|
||||||
if (!configUrl) { return ''; }
|
if (!configUrl) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
if (configUrl.startsWith('http:') || configUrl.startsWith('https:')) {
|
if (configUrl.startsWith('http:') || configUrl.startsWith('https:')) {
|
||||||
url = configUrl;
|
url = configUrl;
|
||||||
} else {
|
} else {
|
||||||
@@ -100,8 +102,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_createToast(message) {
|
_createToast(message) {
|
||||||
this.dispatchEvent(new CustomEvent('show-alert',
|
this.dispatchEvent(new CustomEvent(
|
||||||
{detail: {message}, bubbles: true}));
|
'show-alert', {detail: {message}, bubbles: true, composed: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeShowAgreementsClass(agreements) {
|
_computeShowAgreementsClass(agreements) {
|
||||||
@@ -133,9 +135,13 @@
|
|||||||
// then hides the text box and submit button.
|
// then hides the text box and submit button.
|
||||||
_computeHideAgreementClass(name, config) {
|
_computeHideAgreementClass(name, config) {
|
||||||
for (const key in config) {
|
for (const key in config) {
|
||||||
if (!config.hasOwnProperty(key)) { continue; }
|
if (!config.hasOwnProperty(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (const prop in config[key]) {
|
for (const prop in config[key]) {
|
||||||
if (!config[key].hasOwnProperty(prop)) { continue; }
|
if (!config[key].hasOwnProperty(prop)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (name === config[key].name &&
|
if (name === config[key].name &&
|
||||||
!config[key].auto_verify_group) {
|
!config[key].auto_verify_group) {
|
||||||
return 'hideAgreementsTextBox';
|
return 'hideAgreementsTextBox';
|
||||||
|
|||||||
@@ -414,6 +414,7 @@
|
|||||||
this.dispatchEvent(new CustomEvent('show-alert', {
|
this.dispatchEvent(new CustomEvent('show-alert', {
|
||||||
detail: {message: RELOAD_MESSAGE},
|
detail: {message: RELOAD_MESSAGE},
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
}));
|
}));
|
||||||
this.async(() => {
|
this.async(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
this.set('change.starred', newVal);
|
this.set('change.starred', newVal);
|
||||||
this.dispatchEvent(new CustomEvent('toggle-star', {
|
this.dispatchEvent(new CustomEvent('toggle-star', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
detail: {change: this.change, starred: newVal},
|
detail: {change: this.change, starred: newVal},
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -128,7 +128,8 @@
|
|||||||
|
|
||||||
_numPendingDraftRequests: {
|
_numPendingDraftRequests: {
|
||||||
type: Object,
|
type: Object,
|
||||||
value: {number: 0}, // Intentional to share the object across instances.
|
value:
|
||||||
|
{number: 0}, // Intentional to share the object across instances.
|
||||||
},
|
},
|
||||||
|
|
||||||
_enableOverlay: {
|
_enableOverlay: {
|
||||||
@@ -230,7 +231,9 @@
|
|||||||
*/
|
*/
|
||||||
save(opt_comment) {
|
save(opt_comment) {
|
||||||
let comment = opt_comment;
|
let comment = opt_comment;
|
||||||
if (!comment) { comment = this.comment; }
|
if (!comment) {
|
||||||
|
comment = this.comment;
|
||||||
|
}
|
||||||
|
|
||||||
this.set('comment.message', this._messageText);
|
this.set('comment.message', this._messageText);
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
@@ -340,7 +343,9 @@
|
|||||||
|
|
||||||
_computeSaveDisabled(draft, comment, resolved) {
|
_computeSaveDisabled(draft, comment, resolved) {
|
||||||
// If resolved state has changed and a msg exists, save should be enabled.
|
// If resolved state has changed and a msg exists, save should be enabled.
|
||||||
if (comment.unresolved === resolved && draft) { return false; }
|
if (comment.unresolved === resolved && draft) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return !draft || draft.trim() === '';
|
return !draft || draft.trim() === '';
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -376,7 +381,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_messageTextChanged(newValue, oldValue) {
|
_messageTextChanged(newValue, oldValue) {
|
||||||
if (!this.comment || (this.comment && this.comment.id)) { return; }
|
if (!this.comment || (this.comment && this.comment.id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.debounce('store', () => {
|
this.debounce('store', () => {
|
||||||
const message = this._messageText;
|
const message = this._messageText;
|
||||||
@@ -400,9 +407,12 @@
|
|||||||
|
|
||||||
_handleAnchorTap(e) {
|
_handleAnchorTap(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!this.comment.line) { return; }
|
if (!this.comment.line) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.dispatchEvent(new CustomEvent('comment-anchor-tap', {
|
this.dispatchEvent(new CustomEvent('comment-anchor-tap', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
detail: {
|
detail: {
|
||||||
number: this.comment.line || FILE,
|
number: this.comment.line || FILE,
|
||||||
side: this.side,
|
side: this.side,
|
||||||
@@ -421,7 +431,9 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// Ignore saves started while already saving.
|
// Ignore saves started while already saving.
|
||||||
if (this.disabled) { return; }
|
if (this.disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const timingLabel = this.comment.id ?
|
const timingLabel = this.comment.id ?
|
||||||
REPORT_UPDATE_DRAFT : REPORT_CREATE_DRAFT;
|
REPORT_UPDATE_DRAFT : REPORT_CREATE_DRAFT;
|
||||||
const timer = this.$.reporting.getTimer(timingLabel);
|
const timer = this.$.reporting.getTimer(timingLabel);
|
||||||
@@ -450,6 +462,7 @@
|
|||||||
_handleFix() {
|
_handleFix() {
|
||||||
this.dispatchEvent(new CustomEvent('create-fix-comment', {
|
this.dispatchEvent(new CustomEvent('create-fix-comment', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
detail: this._getEventPayload(),
|
detail: this._getEventPayload(),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
@@ -512,7 +525,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_getSavingMessage(numPending) {
|
_getSavingMessage(numPending) {
|
||||||
if (numPending === 0) { return SAVED_MESSAGE; }
|
if (numPending === 0) {
|
||||||
|
return SAVED_MESSAGE;
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
SAVING_MESSAGE,
|
SAVING_MESSAGE,
|
||||||
numPending,
|
numPending,
|
||||||
@@ -544,8 +559,8 @@
|
|||||||
// Note: the event is fired on the body rather than this element because
|
// Note: the event is fired on the body rather than this element because
|
||||||
// this element may not be attached by the time this executes, in which
|
// this element may not be attached by the time this executes, in which
|
||||||
// case the event would not bubble.
|
// case the event would not bubble.
|
||||||
document.body.dispatchEvent(new CustomEvent('show-alert',
|
document.body.dispatchEvent(new CustomEvent(
|
||||||
{detail: {message}, bubbles: true}));
|
'show-alert', {detail: {message}, bubbles: true, composed: true}));
|
||||||
}, TOAST_DEBOUNCE_INTERVAL);
|
}, TOAST_DEBOUNCE_INTERVAL);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -96,8 +96,11 @@
|
|||||||
this.$.storage.getEditableContentItem(this.storageKey);
|
this.$.storage.getEditableContentItem(this.storageKey);
|
||||||
if (storedContent && storedContent.message) {
|
if (storedContent && storedContent.message) {
|
||||||
content = storedContent.message;
|
content = storedContent.message;
|
||||||
this.dispatchEvent(new CustomEvent('show-alert',
|
this.dispatchEvent(new CustomEvent('show-alert', {
|
||||||
{detail: {message: RESTORED_MESSAGE}, bubbles: true}));
|
detail: {message: RESTORED_MESSAGE},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!content) {
|
if (!content) {
|
||||||
|
|||||||
Reference in New Issue
Block a user