Improve layout of robot comments
* Switch service account and robot name
* Remove Run ID and replace with Run Details
* Remove robot icon
* https://imgur.com/a/pijB2KP
Change-Id: If42ca1f72ea3c3656f55d5002c82c2439898a5f3
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 46fa3cf..cb87bd9 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
@@ -247,7 +247,7 @@
<div id="container" class="container">
<div class="header" id="header" on-click="_handleToggleCollapsed">
<div class="headerLeft">
- <span class="authorName">[[comment.author.name]]</span>
+ <span class="authorName">[[_computeAuthorName(comment)]]</span>
<span class="draftLabel">DRAFT</span>
<gr-tooltip-content class="draftTooltip"
has-tooltip
@@ -258,6 +258,13 @@
<div class="headerMiddle">
<span class="collapsedContent">[[comment.message]]</span>
</div>
+ <div hidden$="[[_computeHideRunDetails(comment, collapsed)]]" class="runIdMessage message">
+ <div class="runIdInformation">
+ <a class="robotRunLink" href$="[[comment.url]]">
+ <span class="robotRun link">Run Details</span>
+ </a>
+ </div>
+ </div>
<gr-button
id="deleteBtn"
link
@@ -284,10 +291,9 @@
</div>
</div>
<div class="body">
- <template is="dom-if" if="[[comment.robot_id]]">
+ <template is="dom-if" if="[[isRobotComment]]">
<div class="robotId" hidden$="[[collapsed]]">
- <iron-icon class="robotIcon" icon="gr-icons:robot"></iron-icon>
- [[comment.robot_id]]
+ [[comment.author.name]]
</div>
</template>
<template is="dom-if" if="[[editing]]">
@@ -306,19 +312,6 @@
content="[[comment.message]]"
no-trailing-margin="[[!comment.__draft]]"
config="[[projectConfig.commentlinks]]"></gr-formatted-text>
- <div hidden$="[[!comment.robot_run_id]]" class="message">
- <div class="runIdInformation" hidden$="[[collapsed]]">
- Run ID:
- <template is="dom-if" if="[[comment.url]]">
- <a class="robotRunLink" href$="[[comment.url]]">
- <span class="robotRun link">[[comment.robot_run_id]]</span>
- </a>
- </template>
- <template is="dom-if" if="[[!comment.url]]">
- <span class="robotRun text">[[comment.robot_run_id]]</span>
- </template>
- </div>
- </div>
<div class="actions humanActions" hidden$="[[!_showHumanActions]]">
<div class="action resolve hideOnPublished">
<label>
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 dd2855c..053eeee 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
@@ -75,7 +75,7 @@
static get properties() {
return {
changeNum: String,
- /** @type {?} */
+ /** @type {!Gerrit.Comment} */
comment: {
type: Object,
notify: true,
@@ -672,6 +672,19 @@
return overlay.open();
}
+ _computeAuthorName(comment) {
+ if (!comment) return '';
+ if (comment.robot_id) {
+ return comment.robot_id;
+ }
+ return comment.author && comment.author.name;
+ }
+
+ _computeHideRunDetails(comment, collapsed) {
+ if (!comment) return true;
+ return !(comment.robot_id && comment.url && !collapsed);
+ }
+
_closeOverlay(overlay) {
Polymer.dom(Gerrit.getRootElement()).removeChild(overlay);
overlay.close();
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 de75b40..ad8b5e4 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
@@ -456,17 +456,13 @@
element.editing = false;
element.collapsed = false;
flushAsynchronousOperations();
- assert.isNotOk(element.$$('.robotRun.link'));
- assert.notEqual(getComputedStyle(element.$$('.robotRun.text')).display,
- 'none');
+ assert.isTrue(element.$$('.robotRun.link').textContent === 'Run Details');
// A robot comment with run ID and url should display a link.
element.set(['comment', 'url'], '/path/to/run');
flushAsynchronousOperations();
assert.notEqual(getComputedStyle(element.$$('.robotRun.link')).display,
'none');
- assert.equal(getComputedStyle(element.$$('.robotRun.text')).display,
- 'none');
});
test('collapsible drafts', () => {
@@ -527,6 +523,37 @@
'header middle content is not visible');
});
+ test('robot comment layout', () => {
+ const comment = Object.assign({
+ robot_id: 'happy_robot_id',
+ url: '/robot/comment',
+ author: {
+ name: 'Happy Robot',
+ },
+ }, element.comment);
+ element.comment = comment;
+ element.collapsed = false;
+ flushAsynchronousOperations();
+
+ let runIdMessage;
+ runIdMessage = element.$$('.runIdMessage');
+ assert.isFalse(runIdMessage.hidden);
+
+ const runDetailsLink = element.$$('.robotRunLink');
+ assert.isTrue(runDetailsLink.href.indexOf(element.comment.url) !== -1);
+
+ const robotServiceName = element.$$('.authorName');
+ assert.isTrue(robotServiceName.textContent === 'happy_robot_id');
+
+ const authorName = element.$$('.robotId');
+ assert.isTrue(authorName.innerText === 'Happy Robot');
+
+ element.collapsed = true;
+ flushAsynchronousOperations();
+ runIdMessage = element.$$('.runIdMessage');
+ assert.isTrue(runIdMessage.hidden);
+ });
+
test('draft creation/cancellation', done => {
assert.isFalse(element.editing);
MockInteractions.tap(element.$$('.edit'));
diff --git a/polygerrit-ui/app/types/types.js b/polygerrit-ui/app/types/types.js
index 8dd65cb..3b91407 100644
--- a/polygerrit-ui/app/types/types.js
+++ b/polygerrit-ui/app/types/types.js
@@ -273,4 +273,27 @@
* makeSuggestionItem: function(Object): Gerrit.GrSuggestionItem,
* }}
*/
-Gerrit.GrSuggestionsProvider;
\ No newline at end of file
+Gerrit.GrSuggestionsProvider;
+
+/**
+ * @typedef {{
+ * patch_set: ?number,
+ * id: ?string,
+ * path: ?Object,
+ * side: ?string,
+ * parent: ?number,
+ * line: ?Object,
+ * in_reply_to: ?string,
+ * message: ?Object,
+ * updated: ?string,
+ * author: ?Object,
+ * tag: ?Object,
+ * unresolved: ?boolean,
+ * robot_id: ?string,
+ * robot_run_id: ?string,
+ * url: ?string,
+ * properties: ?Object,
+ * fix_suggestions: ?Object,
+ * }}
+ */
+Gerrit.Comment;