diff --git a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.html b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.html index 8324ab2d48..819b6d94c0 100644 --- a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.html +++ b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.html @@ -116,7 +116,9 @@ limitations under the License. as="value"> [[value]] diff --git a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js index cf743a45b3..59f9f4617f 100644 --- a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js +++ b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js @@ -125,7 +125,10 @@ this._selectedValueText = e.target.selectedItem.getAttribute('title'); // Needed to update the style of the selected button. this.updateStyles(); - this.fire('labels-changed'); + const name = e.target.selectedItem.name; + const value = e.target.selectedItem.getAttribute('value'); + this.dispatchEvent(new CustomEvent( + 'labels-changed', {detail: {name, value}, bubbles: true})); }, _computeAnyPermittedLabelValues(permittedLabels, label) { diff --git a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_test.html b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_test.html index 1acf6ad773..49d0b67846 100644 --- a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_test.html +++ b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_test.html @@ -114,7 +114,9 @@ limitations under the License. .textContent.trim(), '-1'); assert.strictEqual( element.$.selectedValueLabel.textContent.trim(), 'bad'); - assert.isTrue(labelsChangedHandler.called); + const detail = labelsChangedHandler.args[0][0].detail; + assert.equal(detail.name, 'Verified'); + assert.equal(detail.value, '-1'); }); test('_computeButtonClass', () => { diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html index 6deb9a0fca..bcaf973893 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html @@ -113,6 +113,9 @@ limitations under the License. display: flex; width: 100%; } + gr-endpoint-decorator[name="reply-label-scores"] { + display: block; + } .previewContainer gr-formatted-text { background: #f6f6f6; padding: 1em; @@ -138,6 +141,14 @@ limitations under the License. #savingLabel.saving { display: inline; } + #pluginMessage { + color: #444; + margin-left: 1em; + margin-bottom: .5em; + } + #pluginMessage:empty { + display: none; + }
@@ -219,12 +230,15 @@ limitations under the License. config="[[projectConfig.commentlinks]]">
- + + + +
[[_pluginMessage]]
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js index 35bdfb0f04..4bd6db7d40 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js @@ -199,6 +199,10 @@ value: ButtonTooltips.SAVE, readOnly: true, }, + _pluginMessage: { + type: String, + value: '', + }, }, FocusTarget, @@ -845,5 +849,9 @@ } return str; }, + + setPluginMessage(message) { + this._pluginMessage = message; + }, }); })(); diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.html b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.html index 6a7966b42f..7e0d5e7017 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.html +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.html @@ -1098,5 +1098,10 @@ limitations under the License. // Mock labels changed. assert.isFalse(fn('Send', {}, '', false, true, false)); }); + + test('setPluginMessage', () => { + element.setPluginMessage('foo'); + assert.equal(element.$.pluginMessage.textContent, 'foo'); + }); }); diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api.js index adaf62230a..376baff54c 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api.js +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api.js @@ -73,5 +73,20 @@ }); }; + GrChangeReplyInterface.prototype.addLabelValuesChangedCallback = + function(handler) { + this.plugin.hook('reply-label-scores').onAttached(el => { + if (!el.content) { return; } + + el.content.addEventListener('labels-changed', e => { + handler(e.detail); + }); + }); + }; + + GrChangeReplyInterface.prototype.showMessage = function(message) { + return this._el.setPluginMessage(message); + }; + window.GrChangeReplyInterface = GrChangeReplyInterface; })(window); diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.html index e453fd2ee1..c21424b43a 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.html +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.html @@ -78,6 +78,10 @@ breaking changes to gr-reply-dialog won’t be noticed. sandbox.stub(element, 'send'); changeReply.send(false); assert.isTrue(element.send.calledWithExactly(false)); + + sandbox.stub(element, 'setPluginMessage'); + changeReply.showMessage('foobar'); + assert.isTrue(element.setPluginMessage.calledWithExactly('foobar')); }); }); @@ -105,6 +109,10 @@ breaking changes to gr-reply-dialog won’t be noticed. sandbox.stub(element, 'send'); changeReply.send(false); assert.isTrue(element.send.calledWithExactly(false)); + + sandbox.stub(element, 'setPluginMessage'); + changeReply.showMessage('foobar'); + assert.isTrue(element.setPluginMessage.calledWithExactly('foobar')); }); }); }); diff --git a/polygerrit-ui/app/samples/suggest-vote.html b/polygerrit-ui/app/samples/suggest-vote.html new file mode 100644 index 0000000000..657fa73352 --- /dev/null +++ b/polygerrit-ui/app/samples/suggest-vote.html @@ -0,0 +1,23 @@ + + +