Fix template types in gr-comment-thread
Change-Id: If813a5071483958251983046b02cf7e43dd526cb
diff --git a/polygerrit-ui/app/BUILD b/polygerrit-ui/app/BUILD
index b5da5d5..3a647d4 100644
--- a/polygerrit-ui/app/BUILD
+++ b/polygerrit-ui/app/BUILD
@@ -129,7 +129,6 @@
"elements/gr-app-element_html.ts",
"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",
]
sources_for_template_checking = glob(
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
index fe4a66a..68df9c1 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
@@ -349,7 +349,8 @@
return GerritNav.getUrlForComment(changeNum, projectName, id);
}
- getHighlightRange() {
+ /** The parameter is for triggering re-computation only. */
+ getHighlightRange(_: unknown) {
const comment = this.comments?.[0];
if (!comment) return undefined;
if (comment.range) return comment.range;
@@ -378,9 +379,9 @@
comments: UIComment[],
changeNum?: NumericChangeId,
projectName?: RepoName
- ) {
- if (!changeNum) return;
- if (!projectName) return;
+ ): string {
+ if (!changeNum) return '';
+ if (!projectName) return '';
check(comments.length > 0, 'comment not found');
return GerritNav.getUrlForComment(changeNum, projectName, comments[0].id!);
}
@@ -426,7 +427,7 @@
});
}
- _isPatchsetLevelComment(path: string) {
+ _isPatchsetLevelComment(path?: string) {
return path === SpecialFilePath.PATCHSET_LEVEL_COMMENTS;
}
@@ -435,7 +436,7 @@
return this.showPortedComment && comment.id === this._orderedComments[0].id;
}
- _computeDisplayPath(path: string) {
+ _computeDisplayPath(path?: string) {
const displayPath = computeDisplayPath(path);
if (displayPath === SpecialFilePath.PATCHSET_LEVEL_COMMENTS) {
return 'Patchset';
@@ -741,7 +742,8 @@
return -1;
}
- _computeHostClass(unresolved?: boolean) {
+ /** 2nd parameter is for triggering re-computation only. */
+ _computeHostClass(unresolved?: boolean, _?: unknown) {
if (this.isRobotComment) {
return 'robotComment';
}
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
index 245f71c..4bd359c 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
@@ -241,9 +241,7 @@
</gr-diff>
<div class="view-diff-container">
<a href="[[_getUrlForViewDiff(comments, changeNum, projectName)]]">
- <gr-button link class="view-diff-button" on-click="_handleViewDiff">
- View Diff
- </gr-button>
+ <gr-button link class="view-diff-button">View Diff</gr-button>
</a>
</div>
</div>
diff --git a/polygerrit-ui/app/utils/path-list-util.ts b/polygerrit-ui/app/utils/path-list-util.ts
index fd922fc..411421e 100644
--- a/polygerrit-ui/app/utils/path-list-util.ts
+++ b/polygerrit-ui/app/utils/path-list-util.ts
@@ -95,13 +95,13 @@
});
}
-export function computeDisplayPath(path: string) {
+export function computeDisplayPath(path?: string) {
if (path === SpecialFilePath.COMMIT_MESSAGE) {
return 'Commit message';
} else if (path === SpecialFilePath.MERGE_LIST) {
return 'Merge list';
}
- return path;
+ return path ?? '';
}
export function isMagicPath(path?: string) {