Merge "Add an 'Ack' button next to the 'Done' button"

This commit is contained in:
Wyatt Allen
2016-11-30 21:51:20 +00:00
committed by Gerrit Code Review
6 changed files with 55 additions and 1 deletions

View File

@@ -40,6 +40,7 @@ limitations under the License.
project-config="[[projectConfig]]" project-config="[[projectConfig]]"
on-reply="_handleCommentReply" on-reply="_handleCommentReply"
on-comment-discard="_handleCommentDiscard" on-comment-discard="_handleCommentDiscard"
on-ack="_handleCommentAck"
on-done="_handleCommentDone"></gr-diff-comment> on-done="_handleCommentDone"></gr-diff-comment>
</template> </template>
</div> </div>

View File

@@ -162,6 +162,18 @@
this.push('comments', reply); 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) { _handleCommentDone: function(e) {
var comment = e.detail.comment; var comment = e.detail.comment;
var reply = this._newReply(comment.id, comment.line, 'Done'); var reply = this._newReply(comment.id, comment.line, 'Done');

View File

@@ -180,6 +180,23 @@ limitations under the License.
{bubbles: false}); {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) { test('done', function(done) {
element.changeNum = '42'; element.changeNum = '42';
element.patchNum = '1'; element.patchNum = '1';

View File

@@ -93,11 +93,12 @@ limitations under the License.
.danger .action { .danger .action {
margin-right: 0; 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; display: none;
} }
.draft .reply, .draft .reply,
.draft .quote, .draft .quote,
.draft .ack,
.draft .done { .draft .done {
display: none; display: none;
} }
@@ -111,6 +112,7 @@ limitations under the License.
.editing .message, .editing .message,
.editing .reply, .editing .reply,
.editing .quote, .editing .quote,
.editing .ack,
.editing .done, .editing .done,
.editing .edit { .editing .edit {
display: none; display: none;
@@ -191,6 +193,7 @@ limitations under the License.
<div class="actions" hidden$="[[!showActions]]"> <div class="actions" hidden$="[[!showActions]]">
<gr-button class="action reply" on-tap="_handleReply">Reply</gr-button> <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 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 done" on-tap="_handleDone">Done</gr-button>
<gr-button class="action edit" on-tap="_handleEdit">Edit</gr-button> <gr-button class="action edit" on-tap="_handleEdit">Edit</gr-button>
<gr-button class="action save" on-tap="_handleSave" <gr-button class="action save" on-tap="_handleSave"

View File

@@ -25,6 +25,12 @@
* @event reply * @event reply
*/ */
/**
* Fired when the Ack action is triggered.
*
* @event ack
*/
/** /**
* Fired when the Done action is triggered. * Fired when the Done action is triggered.
* *
@@ -289,6 +295,11 @@
'reply', this._getEventPayload({quote: true}), {bubbles: false}); 'reply', this._getEventPayload({quote: true}), {bubbles: false});
}, },
_handleAck: function(e) {
e.preventDefault();
this.fire('ack', this._getEventPayload(), {bubbles: false});
},
_handleDone: function(e) { _handleDone: function(e) {
e.preventDefault(); e.preventDefault();
this.fire('done', this._getEventPayload(), {bubbles: false}); this.fire('done', this._getEventPayload(), {bubbles: false});

View File

@@ -115,6 +115,13 @@ limitations under the License.
MockInteractions.tap(element.$$('.quote')); 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) { test('proper event fires on done', function(done) {
element.addEventListener('done', function(e) { element.addEventListener('done', function(e) {
done(); done();
@@ -227,6 +234,7 @@ limitations under the License.
assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is not visible'); assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is not visible');
assert.isFalse(isVisible(element.$$('.reply')), 'reply 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.$$('.quote')), 'quote is not visible');
assert.isFalse(isVisible(element.$$('.ack')), 'ack is not visible');
assert.isFalse(isVisible(element.$$('.done')), 'done is not visible'); assert.isFalse(isVisible(element.$$('.done')), 'done is not visible');
element.editing = true; element.editing = true;
@@ -236,6 +244,7 @@ limitations under the License.
assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is visible'); assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is visible');
assert.isFalse(isVisible(element.$$('.reply')), 'reply 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.$$('.quote')), 'quote is not visible');
assert.isFalse(isVisible(element.$$('.ack')), 'ack is not visible');
assert.isFalse(isVisible(element.$$('.done')), 'done is not visible'); assert.isFalse(isVisible(element.$$('.done')), 'done is not visible');
element.draft = false; element.draft = false;
@@ -247,6 +256,7 @@ limitations under the License.
assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is not visible'); assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is not visible');
assert.isTrue(isVisible(element.$$('.reply')), 'reply is visible'); assert.isTrue(isVisible(element.$$('.reply')), 'reply is visible');
assert.isTrue(isVisible(element.$$('.quote')), 'quote 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'); assert.isTrue(isVisible(element.$$('.done')), 'done is visible');
element.comment.id = 'foo'; element.comment.id = 'foo';