Skip to content

Conversation

@vamsikrishnamathala
Copy link
Member

@vamsikrishnamathala vamsikrishnamathala commented Mar 19, 2025

Description

This update fixes open/close for favorties menu in the sidebar when an entity is marked as favorite.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

WEB-3175

Summary by CodeRabbit

  • New Features
    • Enhanced Favorites Interaction: The favorites menu now automatically opens when you add an item to favorites, providing immediate visual feedback.
    • Consistent User Experience: This behavior is applied across various sections of the application, ensuring a more streamlined and responsive interaction when favoriting items.
    • Local Storage Integration: The state of the favorites menu is now managed using local storage, ensuring that the menu's visibility persists across sessions.

@makeplane
Copy link

makeplane bot commented Mar 19, 2025

Pull Request Linked with Plane Issues

References

Comment Automatically Generated by Plane

2 similar comments
@makeplane
Copy link

makeplane bot commented Mar 19, 2025

Pull Request Linked with Plane Issues

References

Comment Automatically Generated by Plane

@makeplane
Copy link

makeplane bot commented Mar 19, 2025

Pull Request Linked with Plane Issues

References

Comment Automatically Generated by Plane

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2025

Walkthrough

This pull request adds a new constant IS_FAVORITE_MENU_OPEN and integrates local storage state management for the favorite menu across multiple components. The implementation uses a custom hook, useLocalStorage, to track and toggle the open/closed status of the favorite menu when items are added to favorites. Several UI components and hooks are updated to reference the new constant, modifying control flows to conditionally open the menu based on its current state.

Changes

File(s) Change Summary
packages/constants/src/workspace.ts Added new exported constant IS_FAVORITE_MENU_OPEN = "is_favorite_menu_open".
web/core/components/.../cycle-list-item-action.tsx
web/core/components/.../module-card-item.tsx
web/core/components/.../module-list-item-action.tsx
web/core/components/.../editor/header/extra-options.tsx
web/core/components/.../project/card.tsx
web/core/components/.../view-list-item-action.tsx
Imported IS_FAVORITE_MENU_OPEN and useLocalStorage; introduced local storage state management for favorite menu; added conditional logic in handleAddToFavorites to toggle the menu open if it is closed.
web/core/components/.../sidebar/favorites/favorites-menu.tsx Updated local storage key by replacing hardcoded string with the constant IS_FAVORITE_MENU_OPEN.
web/core/hooks/use-page-operations.ts Imported IS_FAVORITE_MENU_OPEN and useLocalStorage; integrated local storage state for favorite menu management within the toggleFavorite method.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Component
    participant LocalStorage

    User->>Component: Trigger add-to-favorites
    Component->>LocalStorage: Check state of IS_FAVORITE_MENU_OPEN
    alt Menu is closed
        LocalStorage-->>Component: Return state (false)
        Component->>LocalStorage: toggleFavoriteMenu(true)
        LocalStorage-->>Component: Updated state (true)
    else Menu is open
        LocalStorage-->>Component: Return state (true)
    end
    Component-->>User: Display favorite menu state
Loading

Possibly related PRs

  • [WEB-3422] fix: app sidebar fixes and improvements #6630: The changes in the main PR, which involve adding a new constant IS_FAVORITE_MENU_OPEN, are related to the retrieved PR as both involve the same constant being utilized in different components for managing the state of the favorite menu.
  • [WEB-2774]fix:reordering favorites and favorite folders #6119: The changes in the main PR, which introduce a new constant IS_FAVORITE_MENU_OPEN, are related to the retrieved PR as both involve the management of the favorite menu state, specifically utilizing the same constant in different components.
  • refactor: favorites sidebar implementation #6716: The changes in the main PR, which introduce a new constant IS_FAVORITE_MENU_OPEN, are related to the retrieved PR as both involve the management of the favorite menu state, specifically utilizing the same constant in different components.

Suggested reviewers

  • prateekshourya29
  • sriramveeraghanta

Poem

I'm a hopping rabbit in the code lane,
With constants and hooks making joy reign.
The favorite menu now opens with grace,
Toggled just right at the perfect place.
🐰💻 Hooray for changes that keep pace!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 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 e8df516 and 437b0a5.

📒 Files selected for processing (1)
  • web/core/components/modules/module-list-item-action.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/modules/module-list-item-action.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)

🪧 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 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: 1

🧹 Nitpick comments (2)
web/core/hooks/use-page-operations.ts (2)

153-160: Consider adding toggleFavoriteMenu to the useMemo dependency array.

The implementation correctly opens the favorites menu when an item is added, which addresses the core issue. However, since the toggleFavoriteMenu function is used within the memoized pageOperations object, it should be included in the dependency array.

  }, [
    access,
    addToFavorites,
    archived_at,
    duplicate,
    executeCollaborativeAction,
    getRedirectionLink,
    is_favorite,
    is_locked,
    removePageFromFavorites,
+   toggleFavoriteMenu,
+   isfavoriteMenuOpen,
  ]);

54-56: Consider consistent naming convention for boolean variables.

The variable name isfavoriteMenuOpen uses camelCase but deviates from JavaScript conventions for boolean variables, which typically use "is" as a prefix but capitalize the following word.

- const { setValue: toggleFavoriteMenu, storedValue: isfavoriteMenuOpen } = useLocalStorage<boolean>(
+ const { setValue: toggleFavoriteMenu, storedValue: isFavoriteMenuOpen } = useLocalStorage<boolean>(

This would require updating all instances of the variable in the code.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f22642 and e8df516.

📒 Files selected for processing (9)
  • packages/constants/src/workspace.ts (1 hunks)
  • web/core/components/cycles/list/cycle-list-item-action.tsx (3 hunks)
  • web/core/components/modules/module-card-item.tsx (3 hunks)
  • web/core/components/modules/module-list-item-action.tsx (3 hunks)
  • web/core/components/pages/editor/header/extra-options.tsx (3 hunks)
  • web/core/components/project/card.tsx (3 hunks)
  • web/core/components/views/view-list-item-action.tsx (3 hunks)
  • web/core/components/workspace/sidebar/favorites/favorites-menu.tsx (2 hunks)
  • web/core/hooks/use-page-operations.ts (4 hunks)
🧰 Additional context used
🧬 Code Definitions (6)
web/core/components/workspace/sidebar/favorites/favorites-menu.tsx (1)
packages/constants/src/workspace.ts (1) (1)
  • IS_FAVORITE_MENU_OPEN (328-328)
web/core/components/modules/module-card-item.tsx (1)
packages/constants/src/workspace.ts (1) (1)
  • IS_FAVORITE_MENU_OPEN (328-328)
web/core/components/pages/editor/header/extra-options.tsx (2)
packages/constants/src/workspace.ts (1) (1)
  • IS_FAVORITE_MENU_OPEN (328-328)
web/core/services/page/project-page.service.ts (1) (1)
  • addToFavorites (79-85)
web/core/hooks/use-page-operations.ts (2)
packages/constants/src/workspace.ts (1) (1)
  • IS_FAVORITE_MENU_OPEN (328-328)
web/core/services/page/project-page.service.ts (1) (1)
  • addToFavorites (79-85)
web/core/components/cycles/list/cycle-list-item-action.tsx (1)
packages/constants/src/workspace.ts (1) (1)
  • IS_FAVORITE_MENU_OPEN (328-328)
web/core/components/views/view-list-item-action.tsx (1)
packages/constants/src/workspace.ts (1) (1)
  • IS_FAVORITE_MENU_OPEN (328-328)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (26)
packages/constants/src/workspace.ts (1)

328-328: Good addition of a centralized constant.

The addition of IS_FAVORITE_MENU_OPEN as a centralized constant is a good practice that will help maintain consistency across all components that manage the favorite menu state through local storage.

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

16-16: Good practice using imported constant instead of string literal.

Using the imported constant rather than a hardcoded string improves maintainability.


58-58: Refactored local storage key to use constant.

Replacing the hardcoded string with the imported constant ensures consistency across components.

web/core/components/project/card.tsx (3)

9-10: Good import additions for implementing favorite menu toggling.

Adding imports for the constant and hook that will be used to manage favorite menu state.


72-76: Good implementation of local storage for favorite menu state.

The implementation correctly initializes the local storage hook with the standard constant and default state.


87-90: Improved UX by automatically opening favorites menu.

This change enhances the user experience by automatically opening the favorites menu when a project is added to favorites, making it immediately visible to the user.

web/core/components/views/view-list-item-action.tsx (3)

6-7: Good import additions for implementing favorite menu toggling.

Adding imports for the constant and hook that will be used to manage favorite menu state.


40-44: Good implementation of local storage for favorite menu state.

The implementation correctly initializes the local storage hook with the standard constant and default state.


59-64: Improved handling of favorite addition with async/await and automatic menu toggle.

Making the function async and awaiting the API call is good practice. Additionally, automatically opening the favorites menu when a view is added to favorites improves user experience.

web/core/components/pages/editor/header/extra-options.tsx (4)

4-5: Appropriate addition of the IS_FAVORITE_MENU_OPEN constant import.

The import of the IS_FAVORITE_MENU_OPEN constant from @plane/constants is properly added to support the new functionality.


8-9: Good use of the useLocalStorage hook.

The useLocalStorage hook import is correctly added to enable persistent state management for the favorite menu.


44-48: Well-implemented local storage state management.

The local storage integration for tracking the favorite menu's open/closed state using the useLocalStorage hook is appropriately implemented with a default state of false.


60-67: Successfully enhanced favorite functionality with menu auto-opening.

The implementation correctly opens the favorite menu when a page is added to favorites, providing immediate visual feedback to users. This enhances the user experience by making newly favorited items immediately visible.

web/core/components/modules/module-list-item-action.tsx (2)

16-16: Good addition of the useLocalStorage hook import.

The useLocalStorage hook is correctly imported to support the favorites menu state management.


69-70: Appropriate implementation of automatic favorites menu opening.

The implementation correctly opens the favorites menu when adding a module to favorites, improving user experience by providing immediate visual feedback.

web/core/components/cycles/list/cycle-list-item-action.tsx (4)

9-15: Correctly imported the IS_FAVORITE_MENU_OPEN constant.

The IS_FAVORITE_MENU_OPEN constant is properly imported from @plane/constants package to maintain consistency across the application.


16-16: Good addition of the useLocalStorage hook import.

The useLocalStorage hook is correctly imported to support persistent state management for the favorites menu functionality.


67-71: Well-implemented local storage state management.

The local storage integration using the useLocalStorage hook with the correct constant and default value is properly implemented.


105-105: Successfully implemented favorites menu auto-opening functionality.

The implementation correctly opens the favorites menu when a cycle is added to favorites, providing immediate visual feedback to users and enhancing their experience.

web/core/components/modules/module-card-item.tsx (4)

16-17: Correct import of the IS_FAVORITE_MENU_OPEN constant.

The IS_FAVORITE_MENU_OPEN constant is properly imported from @plane/constants to ensure consistency across the application.


18-18: Good addition of the useLocalStorage hook import.

The useLocalStorage hook is correctly imported to support the favorites menu functionality.


63-65: Well-implemented local storage state management.

The local storage integration for tracking the favorite menu's open/closed state is appropriately implemented with the correct constant and default value of false.


83-83: Appropriate implementation of automatic favorites menu opening.

The implementation correctly opens the favorites menu when adding a module to favorites, improving user experience by providing immediate visual feedback.

web/core/hooks/use-page-operations.ts (3)

2-3: Import properly added for favorites menu constant.

The import for IS_FAVORITE_MENU_OPEN from @plane/constants has been correctly added to enable consistent favorite menu state tracking across components.


16-17: Local storage hook import properly added.

The useLocalStorage hook import is appropriate for persisting the favorites menu state.


53-57: Good implementation of local storage state for favorites menu.

The implementation correctly:

  • Uses a descriptive constant as the storage key
  • Includes a sensible default value (false)
  • Destructures both the value and setter function with clear naming

This approach ensures the favorites menu state persists between sessions.

@sriramveeraghanta sriramveeraghanta merged commit bc539e0 into preview Mar 20, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-favorites-menu branch March 20, 2025 08:33
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* fix: favrotites menu open

* fix: open fav menu on starring projec

* chore: added constant for hardcoded text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛bug Something isn't working 🌐frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants