Use GrComment to create patchset level comment
Basic prototype for creating patchset level comments using
GrComment.
The feature is flag protected.
This change is nowhere close to completing the overall feature but
just an incremental change in the right direction. :)
At the bare minimum, it is currently possible to write something
in the comment textarea, save the comment and reply to the change.
Release-Notes: skip
Google-bug-id: b/242982372
Change-Id: Iac1f8542b6a6b4df4107dac414a48414c67a0083
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 5d380ef..704f770 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -142,6 +142,12 @@
initiallyCollapsed?: boolean;
/**
+ * Hide the header for patchset level comments used in GrReplyDialog.
+ */
+ @property({type: Boolean, attribute: 'hide-header'})
+ hideHeader = false;
+
+ /**
* This is the *current* (internal) collapsed state of the comment. Do not set
* from the outside. Use `initiallyCollapsed` instead. This is just a
* reflected property such that css rules can be based on it.
@@ -478,19 +484,7 @@
const classes = {container: true, draft: isDraftOrUnsaved(this.comment)};
return html`
<div id="container" class=${classMap(classes)}>
- <div
- class="header"
- id="header"
- @click=${() => (this.collapsed = !this.collapsed)}
- >
- <div class="headerLeft">
- ${this.renderAuthor()} ${this.renderPortedCommentMessage()}
- ${this.renderDraftLabel()}
- </div>
- <div class="headerMiddle">${this.renderCollapsedContent()}</div>
- ${this.renderRunDetails()} ${this.renderDeleteButton()}
- ${this.renderPatchset()} ${this.renderDate()} ${this.renderToggle()}
- </div>
+ ${this.renderHeader()}
<div class="body">
${this.renderRobotAuthor()} ${this.renderEditingTextarea()}
${this.renderCommentMessage()} ${this.renderHumanActions()}
@@ -501,6 +495,25 @@
`;
}
+ private renderHeader() {
+ if (this.hideHeader) return nothing;
+ return html`
+ <div
+ class="header"
+ id="header"
+ @click=${() => (this.collapsed = !this.collapsed)}
+ >
+ <div class="headerLeft">
+ ${this.renderAuthor()} ${this.renderPortedCommentMessage()}
+ ${this.renderDraftLabel()}
+ </div>
+ <div class="headerMiddle">${this.renderCollapsedContent()}</div>
+ ${this.renderRunDetails()} ${this.renderDeleteButton()}
+ ${this.renderPatchset()} ${this.renderDate()} ${this.renderToggle()}
+ </div>
+ `;
+ }
+
private renderAuthor() {
if (isRobot(this.comment)) {
const id = this.comment.robot_id;