Skip to content

Comments

[WEB-2326] fix: issue activity mutation on attachments upload.#5886

Merged
pushya22 merged 1 commit intopreviewfrom
fix/attachment-activity-mutation
Oct 24, 2024
Merged

[WEB-2326] fix: issue activity mutation on attachments upload.#5886
pushya22 merged 1 commit intopreviewfrom
fix/attachment-activity-mutation

Conversation

@prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Oct 21, 2024

Issue link: WEB-2326

Summary by CodeRabbit

  • New Features

    • Introduced a projectId property to enhance the functionality of file attachments by enabling project-specific activity fetching.
    • Updated components to ensure projectId is passed through the data flow, improving integration and functionality.
  • Bug Fixes

    • Enhanced the attachment process to ensure activities are fetched after file operations, regardless of the outcome.
  • Documentation

    • Updated type signatures and method signatures to reflect the inclusion of projectId in relevant components.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes introduce a new required property, projectId, to the TIssueAttachmentItemList type in the attachment-item-list.tsx file. This property is integrated into the IssueAttachmentItemList component's props and is utilized in a new handler function, handleFetchPropertyActivities, which fetches activity data related to the project. Modifications are also made to the onDrop function to ensure activities are fetched after an attachment operation. The IssueAttachmentsCollapsibleContent component is updated to pass the projectId prop to the child component, enhancing data flow.

Changes

File Path Change Summary
web/core/components/issues/attachment/attachment-item-list.tsx Added projectId to TIssueAttachmentItemList type; updated destructuring in IssueAttachmentItemList; created handleFetchPropertyActivities to fetch activities; modified onDrop to call this handler.
web/core/components/issues/issue-detail-widgets/attachments/content.tsx Updated IssueAttachmentsCollapsibleContent to pass projectId to IssueAttachmentItemList.
web/core/components/issues/issue-detail-widgets/attachments/quick-action-button.tsx Added fetchActivities to destructured return of useIssueDetail; created handleFetchPropertyActivities for activity fetching; updated onDrop dependency array.

Suggested labels

🐛bug, 🌟enhancement, 🌐frontend

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

Poem

🐰 In the garden where attachments bloom,
A projectId now finds its room.
Fetching activities, swift and bright,
Enhancing our workflow, day and night.
With every drop, a new tale to weave,
Together we code, together we achieve! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 resolve resolve all the CodeRabbit review comments.
  • @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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
web/core/components/issues/issue-detail-widgets/attachments/content.tsx (1)

Line range hint 21-26: Consider using prop spreading for cleaner code.

While the current implementation is correct, you could consider using the spread operator to pass all props to the IssueAttachmentItemList component. This would make the code more concise and less prone to errors when adding or removing props in the future.

Here's a suggested refactor:

 <IssueAttachmentItemList
-  workspaceSlug={workspaceSlug}
-  projectId={projectId}
-  issueId={issueId}
-  disabled={disabled}
+  {...props}
   handleAttachmentOperations={handleAttachmentOperations}
 />

This change would automatically pass all props received by IssueAttachmentsCollapsibleContent to IssueAttachmentItemList, including any future additions.

web/core/components/issues/issue-detail-widgets/attachments/quick-action-button.tsx (1)

35-37: LGTM: Introduction of handleFetchPropertyActivities

The new function handleFetchPropertyActivities is well-implemented and correctly memoized. It enhances the component's ability to fetch updated activities after attachment operations.

Consider adding a comment explaining the purpose of this function for better code readability:

+// Fetch updated activities after attachment operations
const handleFetchPropertyActivities = useCallback(() => {
  fetchActivities(workspaceSlug, projectId, issueId);
}, [fetchActivities, workspaceSlug, projectId, issueId]);
web/core/components/issues/attachment/attachment-item-list.tsx (1)

43-45: LGTM: Addition of handleFetchPropertyActivities function

The new handleFetchPropertyActivities function is well-implemented and correctly memoized. It enhances the component's ability to fetch project-specific activities.

Consider renaming the function to handleFetchIssueActivities for improved clarity, as it specifically fetches activities related to an issue within a project.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fb49644 and f1e804a.

📒 Files selected for processing (3)
  • web/core/components/issues/attachment/attachment-item-list.tsx (3 hunks)
  • web/core/components/issues/issue-detail-widgets/attachments/content.tsx (1 hunks)
  • web/core/components/issues/issue-detail-widgets/attachments/quick-action-button.tsx (3 hunks)
🧰 Additional context used
🔇 Additional comments (9)
web/core/components/issues/issue-detail-widgets/attachments/content.tsx (2)

22-22: LGTM: Correct implementation of projectId prop.

The addition of projectId={projectId} to the IssueAttachmentItemList component is correct and aligns with the changes described in the AI-generated summary. This change ensures that the projectId is properly passed down to the child component, which is necessary for the new functionality related to fetching project-specific activities.


22-22: Verify alignment with PR objective.

The addition of projectId to IssueAttachmentItemList seems to be part of the fix for issue activity mutation on attachments upload, as mentioned in the PR title. However, it would be helpful to clarify how this change specifically contributes to resolving the issue.

Could you please explain how passing projectId to IssueAttachmentItemList helps in fixing the issue activity mutation on attachments upload? This will help ensure that the change aligns with the PR objectives.

web/core/components/issues/issue-detail-widgets/attachments/quick-action-button.tsx (3)

29-29: LGTM: Addition of fetchActivities from useIssueDetail hook

The inclusion of fetchActivities aligns with the PR objective and enhances the component's ability to update issue activities after attachment operations.


58-58: LGTM: Integration of handleFetchPropertyActivities

The integration of handleFetchPropertyActivities is well-implemented:

  1. It's correctly placed in the finally block, ensuring execution regardless of the attachment operation's outcome.
  2. It's properly added to the onDrop callback's dependency array for correct memoization.

These changes effectively address the PR objective of fixing issue activity mutation on attachments upload.

Also applies to: 75-75


Line range hint 1-100: Overall: Excellent implementation addressing the PR objective

The changes in this file effectively address the PR objective of fixing issue activity mutation on attachments upload. The implementation is clean, well-structured, and follows React best practices. The new handleFetchPropertyActivities function is properly integrated into the existing code, ensuring that activities are fetched after attachment operations.

Great job on this implementation!

web/core/components/issues/attachment/attachment-item-list.tsx (4)

20-20: LGTM: Addition of projectId to TIssueAttachmentItemList type

The addition of projectId to the TIssueAttachmentItemList type is appropriate and consistent with the changes described in the summary. This enhancement allows for better project-specific functionality within the component.


27-27: LGTM: Updated props destructuring

The addition of projectId to the destructured props is consistent with the type changes and ensures that the new prop is available for use within the component.


65-68: LGTM: Updated onDrop function with activity fetching

The modifications to the onDrop function are well-implemented:

  1. The addition of handleFetchPropertyActivities in the finally block ensures that activities are fetched after each successful file upload.
  2. The dependency array for useCallback has been correctly updated to include handleFetchPropertyActivities.

These changes effectively integrate activity fetching into the file attachment process.

Also applies to: 82-82


20-20: Summary: Successful integration of project-specific activity fetching

The changes in this file effectively implement project-specific activity fetching for issue attachments. Key improvements include:

  1. Addition of projectId to the component's props and type definition.
  2. Implementation of handleFetchPropertyActivities for fetching issue activities.
  3. Integration of activity fetching into the file upload process.

These modifications enhance the component's functionality and align well with the PR objectives. The code quality is maintained, and the changes are consistent across the file.

Also applies to: 27-27, 43-45, 65-68, 82-82

@pushya22 pushya22 merged commit bf22066 into preview Oct 24, 2024
@pushya22 pushya22 deleted the fix/attachment-activity-mutation branch October 24, 2024 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants