Add an 'Ack' button next to the 'Done' button
Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=622838
Change-Id: Ie7db71615e2c657bbf24847cd8e6e2fc7606f5a9
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.html b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.html
index 6d034b0..864294b 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.html
@@ -40,6 +40,7 @@
project-config="[[projectConfig]]"
on-reply="_handleCommentReply"
on-comment-discard="_handleCommentDiscard"
+ on-ack="_handleCommentAck"
on-done="_handleCommentDone"></gr-diff-comment>
</template>
</div>
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.js b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.js
index a24100f..de1c197 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.js
@@ -162,6 +162,18 @@
this.push('comments', reply);
},
+ _handleCommentAck: function(e) {
+ var comment = e.detail.comment;
+ var reply = this._newReply(comment.id, comment.line, 'Ack');
+ this.push('comments', reply);
+
+ // Allow the reply to render in the dom-repeat.
+ this.async(function() {
+ var commentEl = this._commentElWithDraftID(reply.__draftID);
+ commentEl.save();
+ }.bind(this), 1);
+ },
+
_handleCommentDone: function(e) {
var comment = e.detail.comment;
var reply = this._newReply(comment.id, comment.line, 'Done');
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread_test.html b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread_test.html
index 7b85b62..b694a75 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread_test.html
@@ -180,6 +180,23 @@
{bubbles: false});
});
+ test('ack', function(done) {
+ element.changeNum = '42';
+ element.patchNum = '1';
+ var commentEl = element.$$('gr-diff-comment');
+ assert.ok(commentEl);
+ commentEl.addEventListener('ack', function() {
+ var drafts = element._orderedComments.filter(function(c) {
+ return c.__draft == true;
+ });
+ assert.equal(drafts.length, 1);
+ assert.equal(drafts[0].message, 'Ack');
+ assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215');
+ done();
+ });
+ commentEl.fire('ack', {comment: commentEl.comment}, {bubbles: false});
+ });
+
test('done', function(done) {
element.changeNum = '42';
element.patchNum = '1';
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.html b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.html
index a7be3b7..a1c73db 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.html
@@ -93,11 +93,12 @@
.danger .action {
margin-right: 0;
}
- .container:not(.draft) .actions :not(.reply):not(.quote):not(.done) {
+ .container:not(.draft) .actions :not(.reply):not(.quote):not(.ack):not(.done) {
display: none;
}
.draft .reply,
.draft .quote,
+ .draft .ack,
.draft .done {
display: none;
}
@@ -111,6 +112,7 @@
.editing .message,
.editing .reply,
.editing .quote,
+ .editing .ack,
.editing .done,
.editing .edit {
display: none;
@@ -191,6 +193,7 @@
<div class="actions" hidden$="[[!showActions]]">
<gr-button class="action reply" on-tap="_handleReply">Reply</gr-button>
<gr-button class="action quote" on-tap="_handleQuote">Quote</gr-button>
+ <gr-button class="action ack" on-tap="_handleAck">Ack</gr-button>
<gr-button class="action done" on-tap="_handleDone">Done</gr-button>
<gr-button class="action edit" on-tap="_handleEdit">Edit</gr-button>
<gr-button class="action save" on-tap="_handleSave"
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.js b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.js
index 720e6542..8905854 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.js
@@ -26,6 +26,12 @@
*/
/**
+ * Fired when the Ack action is triggered.
+ *
+ * @event ack
+ */
+
+ /**
* Fired when the Done action is triggered.
*
* @event done
@@ -289,6 +295,11 @@
'reply', this._getEventPayload({quote: true}), {bubbles: false});
},
+ _handleAck: function(e) {
+ e.preventDefault();
+ this.fire('ack', this._getEventPayload(), {bubbles: false});
+ },
+
_handleDone: function(e) {
e.preventDefault();
this.fire('done', this._getEventPayload(), {bubbles: false});
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment_test.html b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment_test.html
index 49507a5..96caebf 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment_test.html
@@ -115,6 +115,13 @@
MockInteractions.tap(element.$$('.quote'));
});
+ test('proper event fires on ack', function(done) {
+ element.addEventListener('ack', function(e) {
+ done();
+ });
+ MockInteractions.tap(element.$$('.ack'));
+ });
+
test('proper event fires on done', function(done) {
element.addEventListener('done', function(e) {
done();
@@ -227,6 +234,7 @@
assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is not visible');
assert.isFalse(isVisible(element.$$('.reply')), 'reply is not visible');
assert.isFalse(isVisible(element.$$('.quote')), 'quote is not visible');
+ assert.isFalse(isVisible(element.$$('.ack')), 'ack is not visible');
assert.isFalse(isVisible(element.$$('.done')), 'done is not visible');
element.editing = true;
@@ -236,6 +244,7 @@
assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is visible');
assert.isFalse(isVisible(element.$$('.reply')), 'reply is not visible');
assert.isFalse(isVisible(element.$$('.quote')), 'quote is not visible');
+ assert.isFalse(isVisible(element.$$('.ack')), 'ack is not visible');
assert.isFalse(isVisible(element.$$('.done')), 'done is not visible');
element.draft = false;
@@ -247,6 +256,7 @@
assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is not visible');
assert.isTrue(isVisible(element.$$('.reply')), 'reply is visible');
assert.isTrue(isVisible(element.$$('.quote')), 'quote is visible');
+ assert.isTrue(isVisible(element.$$('.ack')), 'ack is visible');
assert.isTrue(isVisible(element.$$('.done')), 'done is visible');
element.comment.id = 'foo';