Merge "Remove Please Fix button if robot comment has human reply"
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html
index 89b28d5..0567777 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html
@@ -90,6 +90,7 @@
as="comment">
<gr-comment
comment="{{comment}}"
+ comments="{{comments}}"
robot-button-disabled="[[_shouldDisableAction(_showActions, _lastComment)]]"
change-num="[[changeNum]]"
patch-num="[[patchNum]]"
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
index cb87bd9..2d3b003 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
@@ -348,14 +348,16 @@
</div>
<div class="robotActions" hidden$="[[!_showRobotActions]]">
<template is="dom-if" if="[[isRobotComment]]">
- <gr-button
- link
- secondary
- class="action fix"
- on-click="_handleFix"
- disabled="[[robotButtonDisabled]]">
- Please Fix
- </gr-button>
+ <template is="dom-if" if="[[!_hasHumanReply]]">
+ <gr-button
+ link
+ secondary
+ class="action fix"
+ on-click="_handleFix"
+ disabled="[[robotButtonDisabled]]">
+ Please Fix
+ </gr-button>
+ </template>
<gr-endpoint-decorator name="robot-comment-controls">
<gr-endpoint-param name="comment" value="[[comment]]">
</gr-endpoint-param>
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
index 7951d20..eb4081e 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
@@ -81,6 +81,9 @@
notify: true,
observer: '_commentChanged',
},
+ comments: {
+ type: Array,
+ },
isRobotComment: {
type: Boolean,
value: false,
@@ -119,6 +122,7 @@
/** @type {?} */
projectConfig: Object,
robotButtonDisabled: Boolean,
+ _hasHumanReply: Boolean,
_isAdmin: {
type: Boolean,
value: false,
@@ -165,6 +169,7 @@
'_loadLocalDraft(changeNum, patchNum, comment)',
'_isRobotComment(comment)',
'_calculateActionstoShow(showActions, isRobotComment)',
+ '_computeHasHumanReply(comment, comments.*)',
];
}
@@ -310,6 +315,15 @@
}
}
+ _computeHasHumanReply() {
+ if (!this.comment || !this.comments) return;
+ // hide please fix button for robot comment that has human reply
+ this._hasHumanReply = this.comments.some(c => {
+ return c.in_reply_to && c.in_reply_to === this.comment.id
+ && !c.robot_id;
+ });
+ }
+
/**
* @param {!Object=} opt_mixin
*
@@ -356,7 +370,7 @@
if (editing) {
this.async(() => {
Polymer.dom.flush();
- this.textarea.putCursorAtEnd();
+ this.textarea && this.textarea.putCursorAtEnd();
}, 1);
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.html b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.html
index ad8b5e4..3111475 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.html
@@ -867,9 +867,145 @@
done();
});
element.isRobotComment = true;
+ element.comments = [element.comment];
flushAsynchronousOperations();
MockInteractions.tap(element.$$('.fix'));
});
+
+ test('do not show Please Fix button if human reply exists', () => {
+ element.comments = [
+ {
+ robot_id: 'happy_robot_id',
+ robot_run_id: '5838406743490560',
+ fix_suggestions: [
+ {
+ fix_id: '478ff847_3bf47aaf',
+ description: 'Make the smiley happier by giving it a nose.',
+ replacements: [
+ {
+ path: 'Documentation/config-gerrit.txt',
+ range: {
+ start_line: 10,
+ start_character: 7,
+ end_line: 10,
+ end_character: 9,
+ },
+ replacement: ':-)',
+ },
+ ],
+ },
+ ],
+ author: {
+ _account_id: 1030912,
+ name: 'Alice Kober-Sotzek',
+ email: 'aliceks@google.com',
+ avatars: [
+ {
+ url: '/s32-p/photo.jpg',
+ height: 32,
+ },
+ {
+ url: '/AaAdOFzPlFI/s56-p/photo.jpg',
+ height: 56,
+ },
+ {
+ url: '/AaAdOFzPlFI/s100-p/photo.jpg',
+ height: 100,
+ },
+ {
+ url: '/AaAdOFzPlFI/s120-p/photo.jpg',
+ height: 120,
+ },
+ ],
+ },
+ patch_set: 1,
+ id: 'eb0d03fd_5e95904f',
+ line: 10,
+ updated: '2017-04-04 15:36:17.000000000',
+ message: 'This is a robot comment with a fix.',
+ unresolved: false,
+ __commentSide: 'right',
+ collapsed: false,
+ },
+ {
+ __draft: true,
+ __draftID: '0.wbrfbwj89sa',
+ __date: '2019-12-04T13:41:03.689Z',
+ path: 'Documentation/config-gerrit.txt',
+ patchNum: 1,
+ side: 'REVISION',
+ __commentSide: 'right',
+ line: 10,
+ in_reply_to: 'eb0d03fd_5e95904f',
+ message: '> This is a robot comment with a fix.\n\nPlease Fix',
+ unresolved: true,
+ },
+ ];
+ element.comment = element.comments[0];
+ flushAsynchronousOperations();
+ assert.isNull(element.$$('robotActions gr-button'));
+ });
+
+ test('show Please Fix if no human reply', () => {
+ element.comments = [
+ {
+ robot_id: 'happy_robot_id',
+ robot_run_id: '5838406743490560',
+ fix_suggestions: [
+ {
+ fix_id: '478ff847_3bf47aaf',
+ description: 'Make the smiley happier by giving it a nose.',
+ replacements: [
+ {
+ path: 'Documentation/config-gerrit.txt',
+ range: {
+ start_line: 10,
+ start_character: 7,
+ end_line: 10,
+ end_character: 9,
+ },
+ replacement: ':-)',
+ },
+ ],
+ },
+ ],
+ author: {
+ _account_id: 1030912,
+ name: 'Alice Kober-Sotzek',
+ email: 'aliceks@google.com',
+ avatars: [
+ {
+ url: '/s32-p/photo.jpg',
+ height: 32,
+ },
+ {
+ url: '/AaAdOFzPlFI/s56-p/photo.jpg',
+ height: 56,
+ },
+ {
+ url: '/AaAdOFzPlFI/s100-p/photo.jpg',
+ height: 100,
+ },
+ {
+ url: '/AaAdOFzPlFI/s120-p/photo.jpg',
+ height: 120,
+ },
+ ],
+ },
+ patch_set: 1,
+ id: 'eb0d03fd_5e95904f',
+ line: 10,
+ updated: '2017-04-04 15:36:17.000000000',
+ message: 'This is a robot comment with a fix.',
+ unresolved: false,
+ __commentSide: 'right',
+ collapsed: false,
+ },
+ ];
+ element.comment = element.comments[0];
+ flushAsynchronousOperations();
+ assert.isNotNull(element.$$('.robotActions gr-button'));
+ });
});
</script>