Reflect changes to lineNum and range property to the DOM
Change-Id: Ic43bde61545f48bf160066c3fbabdb71f7174b6c
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 cf8a0ed..3d0548b 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
@@ -404,16 +404,16 @@
return displayPath;
}
- _computeDisplayLine() {
- if (this.lineNum === FILE) {
+ _computeDisplayLine(lineNum?: LineNumber, range?: CommentRange) {
+ if (lineNum === FILE) {
if (this.path === SpecialFilePath.PATCHSET_LEVEL_COMMENTS) {
return '';
}
return FILE;
}
- if (this.lineNum) return `#${this.lineNum}`;
+ if (lineNum) return `#${lineNum}`;
// If range is set, then lineNum equals the end line of the range.
- if (this.range) return `#${this.range.end_line}`;
+ if (range) return `#${range.end_line}`;
return '';
}
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 1f0ce3d..9b8659c 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
@@ -123,7 +123,7 @@
<template is="dom-if" if="[[!_isPatchsetLevelComment(path)]]">
<a
href$="[[_getDiffUrlForComment(projectName, changeNum, path, patchNum)]]"
- >[[_computeDisplayLine()]]</a
+ >[[_computeDisplayLine(lineNum, range)]]</a
>
</template>
</div>
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
index 64f5ad8..2eeb12d 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
@@ -285,15 +285,24 @@
test('_computeDisplayLine', () => {
element.lineNum = 5;
- assert.equal(element._computeDisplayLine(), '#5');
+ assert.equal(
+ element._computeDisplayLine(element.lineNum, element.range),
+ '#5'
+ );
element.path = SpecialFilePath.COMMIT_MESSAGE;
element.lineNum = 5;
- assert.equal(element._computeDisplayLine(), '#5');
+ assert.equal(
+ element._computeDisplayLine(element.lineNum, element.range),
+ '#5'
+ );
element.lineNum = undefined;
element.path = SpecialFilePath.PATCHSET_LEVEL_COMMENTS;
- assert.equal(element._computeDisplayLine(), '');
+ assert.equal(
+ element._computeDisplayLine(element.lineNum, element.range),
+ ''
+ );
});
});
});