Fix template types in gr-comment
Change-Id: Idb2695c72306193ce84735bf48daa0170e930062
diff --git a/polygerrit-ui/app/BUILD b/polygerrit-ui/app/BUILD
index 1c0ab00..b5da5d5 100644
--- a/polygerrit-ui/app/BUILD
+++ b/polygerrit-ui/app/BUILD
@@ -130,7 +130,6 @@
"elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_html.ts",
"elements/shared/gr-account-list/gr-account-list_html.ts",
"elements/shared/gr-comment-thread/gr-comment-thread_html.ts",
- "elements/shared/gr-comment/gr-comment_html.ts",
]
sources_for_template_checking = glob(
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index fa04860..0d4ad8c 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -49,6 +49,7 @@
import {GrConfirmDeleteCommentDialog} from '../gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog';
import {
isDraft,
+ isRobot,
UIComment,
UIDraft,
UIRobot,
@@ -214,7 +215,7 @@
projectConfig?: ConfigInfo;
@property({type: Boolean})
- robotButtonDisabled?: boolean;
+ robotButtonDisabled = false;
@property({type: Boolean})
_hasHumanReply?: boolean;
@@ -233,7 +234,7 @@
side?: string;
@property({type: Boolean})
- resolved?: boolean;
+ resolved = false;
// Intentional to share the object across instances.
@property({type: Object})
@@ -318,12 +319,13 @@
super.disconnectedCallback();
}
- _getAuthor(comment: UIComment) {
- return comment.author || this._selfAccount;
+ /** 2nd argument is for *triggering* the computation only. */
+ _getAuthor(comment?: UIComment, _?: unknown) {
+ return comment?.author || this._selfAccount;
}
- _getUrlForComment(comment: UIComment) {
- if (!this.changeNum || !this.projectName) return '';
+ _getUrlForComment(comment?: UIComment) {
+ if (!comment || !this.changeNum || !this.projectName) return '';
if (!comment.id) throw new Error('comment must have an id');
return GerritNav.getUrlForComment(
this.changeNum as NumericChangeId,
@@ -435,8 +437,8 @@
this._showRobotActions = showActions && isRobotComment;
}
- hasPublishedComment(comments: UIComment[]) {
- if (!comments.length) return false;
+ hasPublishedComment(comments?: UIComment[]) {
+ if (!comments?.length) return false;
return comments.length > 1 || !isDraft(comments[0]);
}
@@ -808,7 +810,7 @@
);
}
- _hasNoFix(comment: UIComment) {
+ _hasNoFix(comment?: UIComment) {
return !comment || !(comment as UIRobot).fix_suggestions;
}
@@ -1037,9 +1039,10 @@
return overlay.open();
}
- _computeHideRunDetails(comment: UIRobot, collapsed: boolean) {
+ _computeHideRunDetails(comment: UIComment | undefined, collapsed: boolean) {
if (!comment) return true;
- return !(comment.robot_id && comment.url && !collapsed);
+ if (!isRobot(comment)) return true;
+ return !comment.url || collapsed;
}
_closeOverlay(overlay?: GrOverlay | null) {
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_html.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_html.ts
index ee4c02f..b77c4b2 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_html.ts
@@ -316,7 +316,7 @@
<div class="show-hide" tabindex="0">
<label
class="show-hide"
- aria-label="[[_computeShowHideAriaLabel(collapsed)]]"
+ aria-label$="[[_computeShowHideAriaLabel(collapsed)]]"
>
<input
type="checkbox"