plane icon indicating copy to clipboard operation
plane copied to clipboard

fix: comments refactor

Open gakshita opened this issue 10 months ago • 1 comments

Description

This PR implements a common comments component and has some refactoring changes

gakshita avatar Mar 17 '25 08:03 gakshita

Walkthrough

The changes modify how issue comments are updated and managed across both the backend API and frontend components. The API now conditionally updates the comment’s edit timestamp, while the TypeScript definitions have been extended to support reactions and various comment operations. The frontend has seen the introduction of new and renamed components for displaying, creating, and reacting to comments, along with updates to editor components and services. Additionally, helper hooks and store updates streamline comment operations and metadata tracking throughout the system.

Changes

File(s) Change Summary
apiserver/plane/app/views/issue/comment.py Modified partial_update in IssueCommentViewSet to conditionally add edited_at timestamp based on comment content.
packages/types/src/issues/activity/issue_comment.d.ts Added new types (TCommentReaction, TCommentsOperations) and updated TIssueComment with an optional edited_at field.
web/ce/components/comments/comment-block.tsx
web/ce/components/comments/index.ts
Introduced new CommentBlock component and updated export to help display comments with user details and quick actions.
web/core/components/comments/comment-card.tsx
web/core/components/comments/comment-create.tsx
web/core/components/comments/comment-reaction.tsx
web/core/components/comments/comments.tsx
web/core/components/comments/index.ts (deleted files: comment-block.tsx, index.ts, root.tsx)
Renamed and refactored comment components (e.g., IssueCommentCardCommentCard, IssueCommentCreateCommentCreate), introduced CommentReactions and CommentsWrapper, and removed deprecated modules.
web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx
web/core/components/issues/issue-detail/issue-activity/root.tsx
Updated comment handling in issue activity components to use the new comment components and operations; swapped out old functions and hooks for a new consolidated hook.
web/core/components/editor/lite-text-editor/lite-text-editor.tsx
web/core/components/editor/lite-text-editor/lite-text-read-only-editor.tsx
Made projectId optional and added new optional props (showToolbar, parentClassName) to enhance editor flexibility.
web/core/services/file.service.ts
web/core/services/issue/issue_comment.service.ts
Added updateBulkWorkspaceAssetsUploadStatus to handle asset uploads at the workspace level and updated patchIssueComment to return the updated comment object.
web/core/store/issue/issue-details/comment.store.ts
web/core/store/issue/issue-details/comment_reaction.store.ts
Updated the comment store to maintain and update updated_at/edited_at timestamps and ensured proper initialization and access of comment reaction data.
web/core/components/issues/issue-detail/issue-activity/helper.tsx Added new hook useCommentOperations to consolidate comment-related CRUD and reaction functions.
web/ee/components/comments/index.ts Added export to re-export all entities from ce/components/comments for consolidated access.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ViewSet
    participant Serializer
    participant ActivityHandler

    Client->>ViewSet: PATCH /issue/{id} with comment_html
    ViewSet->>ViewSet: Check if comment_html exists and has changed
    alt Edited Content Changed
       ViewSet->>Serializer: save(edited_at = now)
    else No Change Detected
       ViewSet->>Serializer: save()
    end
    Serializer-->>ViewSet: return updated comment
    ViewSet->>ActivityHandler: trigger activity delay
    ActivityHandler-->>ViewSet: activity processed
    ViewSet-->>Client: return response

Possibly related PRs

  • makeplane/plane#6352: Updates the asynchronous handling of comment updates in the comment card component, aligning with the new conditional logic for comment edits.

Suggested labels

🌟enhancement, 🧹chore, 🌐frontend

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham
  • rahulramesha

Poem

I’m a little rabbit, hopping with cheer,
Code changes abound, making updates clear.
Comments updated with a timely twist,
New features and hooks that none can resist.
In fields of refactor, I dance away –
💻🐰 Hip-hip-hooray for a brighter day!
Hop on, code—let’s live to debug and play!


📜 Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d769080594ba62d8ff78ddfabed784c1c9974f3 and fd0dbf70a30291e1050da1205ac0e87faa18052b.

📒 Files selected for processing (1)
  • packages/i18n/src/locales/en/translations.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/i18n/src/locales/en/translations.json
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Mar 17 '25 08:03 coderabbitai[bot]

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

makeplane[bot] avatar Mar 27 '25 11:03 makeplane[bot]