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-2738] chore: app sidebar behaviour #5964

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Nov 6, 2024

Summary:

This PR enhances the app sidebar by improving redirection and collapsible functionality.

Media:

Before After
before after
before after

Reference:

[WEB-2738]

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Simplified FavoriteItemTitle component by removing the projectId prop, focusing on essential properties.
    • Enhanced SidebarProjectsListItem with improved drag-and-drop functionality and refined project list visibility management.
  • Bug Fixes

    • Corrected logic for managing project list visibility to ensure it opens correctly based on navigation.
  • Refactor

    • Streamlined component interfaces and props for better usability and maintainability.

@anmolsinghbhatia anmolsinghbhatia self-assigned this Nov 6, 2024
Copy link
Contributor

coderabbitai bot commented Nov 6, 2024

Walkthrough

The changes in this pull request involve modifications to several components, primarily focusing on the FavoriteItemTitle and SidebarProjectsListItem. The projectId property has been removed from the FavoriteItemTitle component, simplifying its props and click handling logic. Additionally, the SidebarProjectsListItem component has seen enhancements in its drag-and-drop functionality and project list visibility management, improving user interaction and responsiveness.

Changes

File Path Change Summary
web/core/components/workspace/sidebar/favorites/favorite-items/common/favorite-item-title.tsx Removed projectId from Props, updated handleOnClick to eliminate projectId logic.
web/core/components/workspace/sidebar/favorites/favorite-items/root.tsx Updated FavoriteItemTitle props to exclude projectId, maintaining existing functionality.
web/core/components/workspace/sidebar/projects-list-item.tsx Refined project list visibility logic and enhanced drag-and-drop functionality with improved checks.

Possibly related PRs

Suggested labels

🐛bug, 🌟improvement

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

Poem

🐇 In the sidebar where favorites dwell,
A change was made, and all is well.
The projectId has hopped away,
Simplifying clicks for a brighter day.
With drag-and-drop now smooth and bright,
Our favorite items take to flight! ✨


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 (2)
web/core/components/workspace/sidebar/favorites/favorite-items/common/favorite-item-title.tsx (2)

16-16: Consider adding ARIA attributes for better accessibility.

While the click handler simplification is good, consider enhancing accessibility by adding appropriate ARIA attributes.

 <Link 
   href={href} 
   className={isSidebarCollapsed ? collapsedClass : linkClass} 
   draggable 
   onClick={handleOnClick}
+  aria-label={`Navigate to ${title}`}
+  role="menuitem"
 >

Also applies to: 27-29


Line range hint 22-23: Consider extracting CSS classes to a constants file.

The CSS classes are quite long and could be reused across similar components. Consider extracting them to a shared constants file for better maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e19cb01 and e182a7d.

📒 Files selected for processing (3)
  • web/core/components/workspace/sidebar/favorites/favorite-items/common/favorite-item-title.tsx (1 hunks)
  • web/core/components/workspace/sidebar/favorites/favorite-items/root.tsx (1 hunks)
  • web/core/components/workspace/sidebar/projects-list-item.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • web/core/components/workspace/sidebar/projects-list-item.tsx
🔇 Additional comments (3)
web/core/components/workspace/sidebar/favorites/favorite-items/common/favorite-item-title.tsx (2)

8-13: LGTM! Props interface is now more focused.

The removal of the projectId prop has simplified the component's interface, making it more focused on its core responsibility of rendering a favorite item title.


8-13: Verify removal of projectId prop usage.

Let's ensure there are no remaining instances where projectId is being passed to this component.

✅ Verification successful

No remaining projectId prop usage found

Based on the search results, the FavoriteItemTitle component is only used in one place (web/core/components/workspace/sidebar/favorites/favorite-items/root.tsx) and it's being called with the correct props (href, icon, title, isSidebarCollapsed) as defined in its type definition. There are no instances where projectId is being passed to this component.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances where projectId is passed to FavoriteItemTitle
ast-grep --pattern 'FavoriteItemTitle $$$projectId=$$$'

Length of output: 57


Script:

#!/bin/bash
# Let's first find all files that might be using FavoriteItemTitle
rg "FavoriteItemTitle" -l

# Then let's see the actual usage contexts
rg "FavoriteItemTitle" -A 3 -B 3

Length of output: 2775

web/core/components/workspace/sidebar/favorites/favorite-items/root.tsx (1)

94-94: LGTM! Props interface simplification.

The removal of the projectId prop simplifies the component interface while maintaining necessary functionality through the useFavoriteItemDetails hook.

Let's verify if the scroll functionality previously dependent on projectId is handled elsewhere:

@anmolsinghbhatia anmolsinghbhatia added this to the v0.24.0 milestone Nov 6, 2024
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 (1)
web/core/components/workspace/sidebar/favorites/favorite-items/common/favorite-item-title.tsx (1)

Line range hint 31-37: Consider enhancing accessibility attributes.

While the component structure is solid, we could improve accessibility by adding ARIA attributes for better screen reader support.

 <Link 
   href={href} 
   className={isSidebarCollapsed ? collapsedClass : linkClass} 
   draggable 
-  onClick={handleOnClick}>
+  onClick={handleOnClick}
+  aria-label={`Navigate to ${title}`}
+  role="menuitem">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e19cb01 and e182a7d.

📒 Files selected for processing (3)
  • web/core/components/workspace/sidebar/favorites/favorite-items/common/favorite-item-title.tsx (1 hunks)
  • web/core/components/workspace/sidebar/favorites/favorite-items/root.tsx (1 hunks)
  • web/core/components/workspace/sidebar/projects-list-item.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • web/core/components/workspace/sidebar/projects-list-item.tsx
🔇 Additional comments (3)
web/core/components/workspace/sidebar/favorites/favorite-items/common/favorite-item-title.tsx (2)

7-13: LGTM! Props interface has been simplified.

The removal of projectId from Props makes the component more focused and easier to maintain.


Line range hint 26-28: Verify the impact of removing scroll behavior.

The click handler has been simplified to only handle mobile sidebar toggling. Let's verify that the removal of scroll behavior doesn't affect user experience in other parts of the application.

✅ Verification successful

Let me generate additional scripts to search for any scroll-related functionality specifically in the favorites section and the component's usage:

This will help us understand:

  1. If there are any scroll behaviors in the favorites section that might be affected
  2. How the FavoriteItemTitle component is being used across the codebase

Removal of scroll behavior is safe to proceed

The removal of scroll behavior from the FavoriteItemTitle component is safe as:

  1. The component is only used as a simple link renderer in the favorites section
  2. No other components in the favorites section rely on scroll behavior from this component
  3. Scroll functionality in the sidebar is properly handled at the container level (as seen in projects-list.tsx and other sidebar components)

The click handler's simplification to only handle mobile sidebar toggling aligns with the component's current usage pattern and doesn't impact the user experience.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining scroll-to-element behaviors that might need to be updated
# or alternative implementations that should handle the scroll behavior

# Look for scroll-related code in sidebar components
rg -g '**/*sidebar*/**/*.{ts,tsx}' -A 3 'scroll|getElementById'

# Look for references to the removed projectId prop
rg -g '**/*.{ts,tsx}' 'FavoriteItemTitle.*projectId'

Length of output: 4778


Script:

#!/bin/bash
# Search for scroll behavior in favorites-related components
rg -g '**/favorites/**/*.{ts,tsx}' -A 5 'scroll|onClick'

# Search for FavoriteItemTitle component usage
ast-grep --pattern 'FavoriteItemTitle'

Length of output: 7644

web/core/components/workspace/sidebar/favorites/favorite-items/root.tsx (1)

94-94: LGTM! Verify navigation behavior after prop simplification.

The removal of projectId prop from FavoriteItemTitle creates a cleaner interface. The component now focuses solely on presentation and basic interaction concerns.

Let's verify that navigation still works correctly after removing the projectId prop:

✅ Verification successful

Removal of projectId and scroll behavior is intentional

The changes are part of a deliberate simplification where:

  • The projectId prop and associated scroll-into-view behavior have been removed
  • Navigation now relies solely on the href prop through Next.js Link component
  • Mobile sidebar toggle behavior is preserved
  • Component maintains its core presentation and navigation responsibilities
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if FavoriteItemTitle's click handling is properly implemented
# Expected: The click handler should now be simplified and handle navigation through href

# Search for click handler implementation in FavoriteItemTitle
ast-grep --pattern 'const FavoriteItemTitle = $_($_) {
  $$$
  onClick($_) {
    $$$
  }
  $$$
}'

# Check for any direct projectId references that might have been missed
rg 'projectId.*FavoriteItemTitle'

Length of output: 135


Script:

#!/bin/bash
# Let's try a different approach to find FavoriteItemTitle implementation
# First, find the file containing FavoriteItemTitle
fd "favorite-item-title" --type f

# Then let's examine its implementation and usage
ast-grep --pattern 'const FavoriteItemTitle = $_'

# Also check for any files importing FavoriteItemTitle
rg "import.*FavoriteItemTitle"

# Look for any test files related to FavoriteItemTitle
fd "favorite-item-title.test" --type f

Length of output: 251


Script:

#!/bin/bash
# Let's examine the FavoriteItemTitle component implementation
cat web/core/components/workspace/sidebar/favorites/favorite-items/common/favorite-item-title.tsx

# Also check for any changes in git history related to projectId
git log -p web/core/components/workspace/sidebar/favorites/favorite-items/common/favorite-item-title.tsx | grep -A 10 -B 10 "projectId"

Length of output: 6620

@pushya22 pushya22 merged commit eebc327 into preview Nov 6, 2024
22 of 23 checks passed
@pushya22 pushya22 deleted the chore-app-sidebar-behaviour branch November 6, 2024 13:06
@coderabbitai coderabbitai bot mentioned this pull request Dec 17, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants