Skip to content

[WEB-2229] fix: issue attachments toast error#5424

Merged
SatishGandham merged 2 commits intopreviewfrom
fix/issue-attachments-toast-error
Aug 26, 2024
Merged

[WEB-2229] fix: issue attachments toast error#5424
SatishGandham merged 2 commits intopreviewfrom
fix/issue-attachments-toast-error

Conversation

@sharma01ketan
Copy link
Contributor

@sharma01ketan sharma01ketan commented Aug 26, 2024

Changes:

This PR fixes the toast behaviour when an attachment to an issue is rejected.
Action Button and DragNDrop are implemented separately in the code, so they are addressed separately.

  1. Action Button allows only one file to be selected, if the file is larger than 5MB, toast should should display a related error.
Screenshot 2024-08-26 at 3 37 19 PM
  1. While dragging and dropping, if a file is larger than 5MB is dropped, toast should should display a related error.
Screenshot 2024-08-26 at 3 37 19 PM
  1. Only one file is allowed to be uploaded, if multiple files are dropped toast should display a related error.
Screenshot 2024-08-26 at 3 28 24 PM

Reference

[WEB-2229]

Summary by CodeRabbit

  • New Features
    • Enhanced file upload functionality with improved error handling for rejected files.
    • Introduced user feedback mechanisms via toast notifications for upload status and restrictions.
    • Implemented loading states during file upload processes.
  • Bug Fixes
    • Resolved issues related to multiple file uploads and size limitations, ensuring adherence to specified constraints.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 26, 2024

Walkthrough

The changes enhance the file upload functionality in the IssueAttachmentItemList and IssueAttachmentActionButton components by adding error handling for rejected files. The onDrop function now accepts both accepted and rejected files, improving user feedback and ensuring compliance with upload restrictions, such as file size limits and single-file uploads.

Changes

Files Change Summary
web/core/components/issues/attachment/attachment-item-list.tsx
web/core/components/issues/issue-detail-widgets/attachments/quick-action-button.tsx
Updated onDrop functions to accept rejectedFiles in addition to acceptedFiles, allowing better handling of file uploads. Introduced error notifications for rejected files and enforced upload constraints like size and quantity.

Poem

🐇 In the land of files, where uploads play,
A rabbit hops in, to brighten the day.
With toasts of feedback, both quick and clear,
No more rejected, we’ll have no fear!
So let’s upload joyfully, one at a time,
With limits in place, all will be fine! ✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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, codebase verification and nitpick comments (2)
web/core/components/issues/issue-detail-widgets/attachments/quick-action-button.tsx (1)

38-79: LGTM! Consider simplifying the toast message condition.

The logic correctly handles rejected files and displays appropriate toast notifications. However, you can simplify the toast message condition as follows:

- message: (totalAttachedFiles>1)?
- "Only one file can be uploaded at a time." :
- "File must be 5MB or less.",
+ message: totalAttachedFiles > 1
+   ? "Only one file can be uploaded at a time."
+   : "File must be 5MB or less.",
web/core/components/issues/attachment/attachment-item-list.tsx (1)

41-79: LGTM! Consider simplifying the toast message condition.

The logic correctly handles rejected files and displays appropriate toast notifications. However, you can simplify the toast message condition as follows:

- message: (totalAttachedFiles>1)?
- "Only one file can be uploaded at a time." :
- "File must be 5MB or less.",
+ message: totalAttachedFiles > 1
+   ? "Only one file can be uploaded at a time."
+   : "File must be 5MB or less.",
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 890379b and 9c72318.

Files selected for processing (2)
  • web/core/components/issues/attachment/attachment-item-list.tsx (2 hunks)
  • web/core/components/issues/issue-detail-widgets/attachments/quick-action-button.tsx (3 hunks)
Additional comments not posted (8)
web/core/components/issues/issue-detail-widgets/attachments/quick-action-button.tsx (4)

4-4: LGTM!

The import statement for FileRejection is correct and necessary for handling rejected files.


6-6: LGTM!

The import statement for TOAST_TYPE and setToast is correct and necessary for displaying toast notifications.


37-37: LGTM!

The onDrop function signature is correctly updated to accept the rejectedFiles parameter.


84-84: LGTM!

The useDropzone configuration is correctly updated to use the onDrop function.

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

3-3: LGTM!

The import statement for FileRejection is correct and necessary for handling rejected files.


6-6: LGTM!

The import statement for TOAST_TYPE and setToast is correct and necessary for displaying toast notifications.


40-40: LGTM!

The onDrop function signature is correctly updated to accept the rejectedFiles parameter.


Line range hint 84-84: LGTM!

The useDropzone configuration is correctly updated to use the onDrop function.

@sharma01ketan sharma01ketan changed the title Fix/issue attachments toast error [WEB-2229] Fix/issue attachments toast error Aug 26, 2024
@sharma01ketan sharma01ketan changed the title [WEB-2229] Fix/issue attachments toast error [WEB-2229] fix issue attachments toast error Aug 26, 2024
@SatishGandham SatishGandham changed the title [WEB-2229] fix issue attachments toast error [WEB-2229] fix: issue attachments toast error Aug 26, 2024
@SatishGandham SatishGandham merged commit 4689ebe into preview Aug 26, 2024
@SatishGandham SatishGandham deleted the fix/issue-attachments-toast-error branch August 26, 2024 11:28
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.

2 participants