From 5fe08d47433b36a5e003eda40eb1af8d1c00ccc7 Mon Sep 17 00:00:00 2001 From: Tan Nhu Date: Tue, 21 May 2024 19:41:14 +0000 Subject: [PATCH] Refactor collapse/expand PR comments per new design (#2046) --- .../CodeCommentStatusSelect.tsx | 13 +- .../CommentBox/CommentBox.module.scss | 21 + .../CommentBox/CommentBox.module.scss.d.ts | 1 + web/src/components/CommentBox/CommentBox.tsx | 469 +++++++++--------- .../CommentBox/comment-resolved.svg | 1 + web/src/components/CommentBox/comment.svg | 1 + .../DiffViewer/DiffViewer.module.scss | 3 +- .../DiffViewer/usePullReqComments.tsx | 19 +- web/src/framework/strings/stringTypes.ts | 1 + web/src/i18n/strings.en.yaml | 1 + 10 files changed, 305 insertions(+), 225 deletions(-) create mode 100644 web/src/components/CommentBox/comment-resolved.svg create mode 100644 web/src/components/CommentBox/comment.svg diff --git a/web/src/components/CodeCommentStatusSelect/CodeCommentStatusSelect.tsx b/web/src/components/CodeCommentStatusSelect/CodeCommentStatusSelect.tsx index 847ce297a..55e7b829e 100644 --- a/web/src/components/CodeCommentStatusSelect/CodeCommentStatusSelect.tsx +++ b/web/src/components/CodeCommentStatusSelect/CodeCommentStatusSelect.tsx @@ -29,12 +29,14 @@ import css from './CodeCommentStatusSelect.module.scss' interface CodeCommentStatusSelectProps extends Pick { comment: { commentItems: CommentItem[] } + rowElement?: HTMLTableRowElement } export const CodeCommentStatusSelect: React.FC = ({ repoMetadata, pullReqMetadata, - comment: { commentItems } + comment: { commentItems }, + rowElement }) => { const { getString } = useStrings() const { showError } = useToaster() @@ -87,6 +89,15 @@ export const CodeCommentStatusSelect: React.FC = ( } }, [parentComment?.id, randomClass]) + useEffect( + function updateRowElement() { + if (rowElement) { + rowElement.dataset.commentThreadStatus = codeCommentStatus.value + } + }, + [rowElement, codeCommentStatus] + ) + return parentComment?.deleted ? null : (