Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-1907] Fix/favorite move out of folder #5305

Merged
merged 3 commits into from
Aug 5, 2024

Conversation

gakshita
Copy link
Collaborator

@gakshita gakshita commented Aug 5, 2024

Summary
Users can now hover on a item to move it out of favorite

[WEB-1907]

Summary by CodeRabbit

  • New Features

    • Enhanced drag-and-drop functionality for favorite items and folders, allowing users to easily manage their favorites.
    • Introduced a method for removing favorites directly from folders via drag-and-drop actions.
  • User Interface Updates

    • Updated the label from "MY FAVORITES" to "YOUR FAVORITES" for improved user engagement.
    • Improved rendering logic to prevent duplicate favorite items based on IDs.
  • Bug Fixes

    • Enhanced error handling during updates and deletions of favorites, ensuring data integrity and rollback on failure.
  • Chores

    • Refined internal logic for managing favorites and modules to ensure consistency across the application during deletions.

Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Walkthrough

The updates enhance the favorites management system across multiple components, incorporating improved drag-and-drop interactions for managing favorite items and folders. The integration of deletion actions for cycles, modules, views, and projects with the favorites store ensures consistent data handling and a smoother user experience, reinforcing data integrity throughout the application.

Changes

File Path Change Summary
.../favorites/favorite-folder.tsx
.../favorites/favorite-item.tsx
Introduced new props for handling folder removals and enhanced drag-and-drop logic for managing favorites.
.../favorites/favorites-menu.tsx Updated rendering logic to prevent duplicate favorites and modified labeling for improved user experience.
.../cycle.store.ts
.../module.store.ts
.../project-view.store.ts
.../project/project.store.ts
Added methods to remove favorites upon deletion of cycles, modules, views, and projects to maintain consistency.
.../favorite.store.ts Implemented robust error handling and state management improvements for favorites management operations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant FavoriteStore
    participant CycleStore

    User->>UI: Delete Cycle
    UI->>CycleStore: deleteCycle(cycleId)
    CycleStore->>FavoriteStore: removeFavoriteFromStore(cycleId)
    FavoriteStore-->>CycleStore: Favorite removed
    CycleStore-->>UI: Cycle deleted
    UI-->>User: Confirm deletion
Loading
sequenceDiagram
    participant User
    participant UI
    participant FavoriteStore
    participant ModuleStore

    User->>UI: Delete Module
    UI->>ModuleStore: deleteModule(moduleId)
    ModuleStore->>FavoriteStore: removeFavoriteFromStore(moduleId)
    FavoriteStore-->>ModuleStore: Favorite removed
    ModuleStore-->>UI: Module deleted
    UI-->>User: Confirm deletion
Loading

Poem

🐇 In the garden of favorites, we play and we hop,
With folders and items, we’ll never stop!
Dragging and dropping, our joys intertwine,
Removing the clutter, oh how we shine!
A world of sweet favorites, so easy, so bright,
Let’s dance through the app, in pure delight! 🌼✨


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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fafa2c0 and c809538.

Files selected for processing (8)
  • web/core/components/workspace/sidebar/favorites/favorite-folder.tsx (6 hunks)
  • web/core/components/workspace/sidebar/favorites/favorite-item.tsx (4 hunks)
  • web/core/components/workspace/sidebar/favorites/favorites-menu.tsx (4 hunks)
  • web/core/store/cycle.store.ts (1 hunks)
  • web/core/store/favorite.store.ts (9 hunks)
  • web/core/store/module.store.ts (1 hunks)
  • web/core/store/project-view.store.ts (1 hunks)
  • web/core/store/project/project.store.ts (1 hunks)
Additional comments not posted (24)
web/core/components/workspace/sidebar/favorites/favorite-item.tsx (5)

5-5: LGTM! The import statement change is appropriate.

The addition of dropTargetForElements is necessary for the new drag-and-drop functionality.


25-33: LGTM! The new props are well-integrated.

The addition of favoriteMap and handleRemoveFromFavoritesFolder props enhances the component's functionality.


108-127: LGTM! The useEffect hook changes enhance drag-and-drop functionality.

The new handlers for onDragStart, onDragEnter, onDragLeave, and onDrop are correctly implemented.


166-166: LGTM! The Link component change is appropriate.

The new prop enhances the component's functionality.


Line range hint 187-195: LGTM! The CustomMenu component changes are well-implemented.

The new functionality enhances the component's usability.

web/core/components/workspace/sidebar/favorites/favorites-menu.tsx (4)

6-6: LGTM! The import statement change is appropriate.

The addition of uniqBy is necessary for ensuring unique favorites.


134-134: LGTM! The text label change improves user experience.

Changing "MY FAVORITES" to "YOUR FAVORITES" makes the interface more user-friendly.


171-171: LGTM! The usage of uniqBy is correct.

Processing favorites through uniqBy ensures that duplicates are removed, enhancing data integrity.


187-195: LGTM! The FavoriteItem component changes are appropriate.

The new prop enhances the component's functionality.

web/core/components/workspace/sidebar/favorites/favorite-folder.tsx (5)

31-31: LGTM! The new prop is well-integrated.

The addition of handleRemoveFromFavoritesFolder enhances the component's functionality.


35-35: LGTM! The prop destructuring change is appropriate.

The new handler is correctly destructured and used within the component.


97-97: LGTM! The initialData object change is appropriate.

The addition of the is_folder property enhances the drag-and-drop functionality.


131-131: LGTM! The onDragEnter handler change is appropriate.

The new check for whether the source data is a folder enhances the drag-and-drop functionality.


146-146: LGTM! The onDrop handler change is appropriate.

The new payload adjustment ensures robust state management during drag-and-drop events.

web/core/store/project-view.store.ts (1)

274-274: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that all calls to deleteView handle the removal of favorites correctly.

web/core/store/favorite.store.ts (6)

128-140: LGTM!

The changes improve error handling by capturing the initial state and restoring it if the update fails.


Line range hint 153-198:
LGTM!

The changes improve clarity, maintainability, and error handling by capturing the old parent and favorite details and providing a rollback mechanism if the operation fails.


212-212: LGTM!

The changes improve error handling by capturing the initial sequence and restoring it if the move fails.


Line range hint 221-249:
LGTM!

The changes improve error handling by capturing the parent and restoring the original state if the removal fails.


278-314: LGTM!

The changes improve error handling by capturing the initial state and restoring it if the deletion fails.


342-359: LGTM!

The new method enhances the management of favorite entities by providing a way to remove them from the store.

web/core/store/project/project.store.ts (1)

404-404: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that all calls to deleteProject handle the removal of favorites correctly.

web/core/store/module.store.ts (1)

408-408: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to deleteModule handle the removal from favorites appropriately.

Verification successful

Verified: The function usage in the codebase is appropriate.

The deleteModule method includes the necessary call to removeFavoriteFromStore(moduleId), ensuring consistency between module management and favorites tracking. The method is used in the delete-module-modal.tsx file, handling the deletion process correctly.

  • web/core/store/module.store.ts: The deleteModule method includes the call to removeFavoriteFromStore(moduleId).
  • web/core/components/modules/delete-module-modal.tsx: The deleteModule method is called appropriately.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `deleteModule` handle the removal from favorites appropriately.

# Test: Search for the function usage. Expect: Proper handling of the removal from favorites.
rg --type typescript -A 5 $'deleteModule'

Length of output: 75


Script:

#!/bin/bash
# Description: Verify all function calls to `deleteModule` handle the removal from favorites appropriately.

# Test: Search for the function usage. Expect: Proper handling of the removal from favorites.
rg --type ts -A 5 $'deleteModule'

Length of output: 6365

web/core/store/cycle.store.ts (1)

554-554: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to deleteCycle handle the removal from favorites appropriately.

Verification successful

LGTM! The function usage is appropriate and the removal from favorites is handled correctly within the deleteCycle method.

  • web/core/store/cycle.store.ts: The deleteCycle method includes the call to removeFavoriteFromStore(cycleId).
  • web/core/components/cycles/delete-modal.tsx: The deleteCycle function is used, and it internally handles the removal from favorites.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `deleteCycle` handle the removal from favorites appropriately.

# Test: Search for the function usage. Expect: Proper handling of the removal from favorites.
rg --type typescript -A 5 $'deleteCycle'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify all function calls to `deleteCycle` handle the removal from favorites appropriately.

# Test: Search for the function usage. Expect: Proper handling of the removal from favorites.
rg 'deleteCycle' --glob '*.ts' --glob '*.tsx' -A 5

Length of output: 3066

@pushya22 pushya22 requested a review from rahulramesha August 5, 2024 11:31
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c809538 and 102b16d.

Files selected for processing (1)
  • web/core/components/workspace/sidebar/favorites/favorite-item.tsx (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/core/components/workspace/sidebar/favorites/favorite-item.tsx

@pushya22 pushya22 merged commit 91e4da5 into preview Aug 5, 2024
13 of 14 checks passed
@pushya22 pushya22 deleted the fix/favorite-move-out-of-folder branch August 5, 2024 11:36
@coderabbitai coderabbitai bot mentioned this pull request Dec 10, 2024
6 tasks
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