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-3292] feat: workspace switcher redesign #6543

Merged
merged 22 commits into from
Feb 7, 2025

Conversation

gakshita
Copy link
Collaborator

@gakshita gakshita commented Feb 4, 2025

Description

This PR implements the new workspace switcher

image

References

[WEB-3292]

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Workspace details now display enhanced user role information and current subscription plan for better clarity.
    • The workspace sidebar now offers interactive dropdown items highlighting workspace names, logos, roles, and member counts with quick access to settings and member pages.
    • Introduced a new SubscriptionPill component for future subscription-related features.
  • Refactor

    • Streamlined workspace data handling and navigation components to deliver a more consistent and user-friendly experience.
    • Simplified the rendering logic of workspace links in the sidebar for improved readability and functionality.
    • Updated the SidebarDropdown component to utilize the new SidebarDropdownItem for better structure and navigation.

@gakshita gakshita marked this pull request as draft February 4, 2025 12:16
Copy link
Contributor

coderabbitai bot commented Feb 4, 2025

Walkthrough

The changes update the workspace-related API and frontend components. In the backend, the WorkSpaceSerializer now removes the owner field and adds a read-only role field, while the UserWorkSpacesEndpoint includes a new role annotation. The TypeScript interface for workspaces is updated with additional properties. On the frontend, a new component (SidebarDropdownItem) is introduced to encapsulate workspace link rendering, and the existing dropdown has been refactored accordingly.

Changes

File(s) Change Summary
apiserver/.../serializers/workspace.py
apiserver/.../views/workspace/base.py
Modified workspace API: Removed the owner field and added a read-only role field in WorkSpaceSerializer; enhanced UserWorkSpacesEndpoint with a role annotation in the workspace queryset.
packages/types/.../workspace.d.ts Updated the IWorkspace interface by adding optional current_plan and required role fields; streamlined import statement formatting.
web/core/components/workspace/sidebar/dropdown-item.tsx
web/core/components/workspace/sidebar/dropdown.tsx
Introduced the SidebarDropdownItem React component; refactored SidebarDropdown to leverage the new component, removed redundant hooks/functions, and updated icon usage and layout.
web/ce/components/common/subscription-pill.tsx New functional component SubscriptionPill added, returning an empty fragment.
web/ee/components/common/subscription-pill.tsx Re-exported all entities from ce/components/common/subscription-pill.

Possibly related PRs

  • chore: user workspace api modification #6547: The changes in the main PR are directly related to those in the retrieved PR, as both involve the removal of the owner field and the addition of the role field in the WorkSpaceSerializer class within the same file.
  • [WEB-2388] fix: workspace draft issues #5800: The changes in the main PR regarding the WorkSpaceSerializer class and the addition of the role field are related to the modifications in the UserWorkSpacesEndpoint class in the retrieved PR, which also introduces a role annotation for workspaces.
  • [WEB-2376] dev: workspace settings improvement & refactor. #5519: The changes in the main PR, which involve modifying the WorkSpaceSerializer to remove the owner field and add a role field, are related to the retrieved PR's enhancements in the UserWorkSpacesEndpoint that also incorporate the role of users within workspaces, indicating a direct connection in how user roles are handled across the application.

Suggested labels

🎨UI / UX, 🧹chore

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham
  • NarayanBavisetti

Poem

I hopped through lines of code with glee,
Removing old owners to set data free.
A shiny new role now leads the way,
In workspaces where our functions play.
With dropdowns refined and queries anew,
I celebrate these changes—hip, hop, woo!
– A happy coding rabbit 🐇


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@gakshita gakshita marked this pull request as ready for review February 6, 2025 06:39
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

🔭 Outside diff range comments (2)
apiserver/plane/app/serializers/workspace.py (1)

49-57: Remove 'owner' from read_only_fields.

The owner field has been removed from the serializer but is still listed in read_only_fields. This should be removed for consistency.

     read_only_fields = [
         "id",
         "created_by",
         "updated_by",
         "created_at",
         "updated_at",
-        "owner",
         "logo_url",
     ]
web/core/components/workspace/sidebar/dropdown.tsx (1)

45-45: Remove hardcoded value for isUserInstanceAdmin.

The isUserInstanceAdmin is hardcoded to false, which could prevent instance admins from accessing their features. Consider using the actual value from the user store.

-  const isUserInstanceAdmin = false;
+  const { isUserInstanceAdmin } = useUser();
🧹 Nitpick comments (3)
web/core/components/workspace/sidebar/dropdown-item.tsx (1)

16-103: Consider memoizing the component for performance optimization.

The component is well-structured and follows React best practices. However, since it's used in a list rendering context, consider memoizing it with React.memo to prevent unnecessary re-renders when parent state changes.

-const SidebarDropdownItem = (props: TProps) => {
+const SidebarDropdownItem = React.memo((props: TProps) => {
   // ... component implementation
-};
+});
web/core/components/workspace/sidebar/dropdown.tsx (1)

84-84: Address the TODO comment about workspace list scroll.

The comment indicates a pending fix for workspace list scrolling. Consider implementing a virtualized list for better performance with large workspace lists.

Would you like me to provide an implementation using react-window or react-virtualized for efficient list rendering?

apiserver/plane/app/views/workspace/base.py (1)

178-182: Fix line length and LGTM for the role annotation.

The role annotation is well-implemented using an efficient subquery. However, line 179 exceeds the recommended line length of 88 characters.

Consider breaking down the long line:

-            WorkspaceMember.objects.filter(workspace=OuterRef("id"), member=request.user, is_active=True)
+            WorkspaceMember.objects.filter(
+                workspace=OuterRef("id"),
+                member=request.user,
+                is_active=True
+            )
🧰 Tools
🪛 Ruff (0.8.2)

179-179: Line too long (105 > 88)

(E501)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 89d1926 and a4b49e9.

📒 Files selected for processing (5)
  • apiserver/plane/app/serializers/workspace.py (1 hunks)
  • apiserver/plane/app/views/workspace/base.py (3 hunks)
  • packages/types/src/workspace.d.ts (2 hunks)
  • web/core/components/workspace/sidebar/dropdown-item.tsx (1 hunks)
  • web/core/components/workspace/sidebar/dropdown.tsx (4 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/workspace/base.py

179-179: Line too long (105 > 88)

(E501)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: lint-space
🔇 Additional comments (4)
web/core/components/workspace/sidebar/dropdown-item.tsx (1)

10-15: LGTM! Props interface is well-defined.

The props interface clearly defines the required properties with appropriate types.

apiserver/plane/app/views/workspace/base.py (3)

10-10: LGTM! Improved code readability.

The added blank lines help separate import groups, following PEP 8 style guidelines.

Also applies to: 14-14


194-194: LGTM! Efficient annotation combination.

Good optimization by combining both total_issues and role annotations in a single query.


200-200: LGTM! Enhanced code structure.

The added blank lines improve readability by clearly separating the query building from the serialization logic.

Also applies to: 206-206

packages/types/src/workspace.d.ts Show resolved Hide resolved
@gakshita gakshita changed the title feat: ui changes for workspace switcher [WEB-3292] feat: ui changes for workspace switcher Feb 6, 2025
@gakshita gakshita changed the title [WEB-3292] feat: ui changes for workspace switcher [WEB-3292] feat: upgraded workspace switcher Feb 6, 2025
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

🧹 Nitpick comments (2)
web/core/components/workspace/sidebar/dropdown.tsx (2)

131-155: Consider adding ARIA attributes for better accessibility.

The workspace list implementation looks good, but could benefit from additional accessibility attributes.

Consider adding these ARIA attributes to improve accessibility:

-                  <div className="vertical-scrollbar scrollbar-sm flex max-h-96 flex-col items-start justify-start overflow-y-scroll">
+                  <div 
+                    className="vertical-scrollbar scrollbar-sm flex max-h-96 flex-col items-start justify-start overflow-y-scroll"
+                    role="listbox"
+                    aria-label="Workspaces"
+                  >

163-168: Simplify the Plus icon implementation.

The current implementation of the Plus icon container seems overly complex with multiple nested divs and transform styles.

Consider simplifying the implementation:

-          <div className="flex w-4 h-4 backdrop-invert rounded-full ">
-            <Plus
-              strokeWidth={3}
-              className="flex-shrink-0 invert h-[10px] w-[10px] text-custom-text-100 m-auto"
-            />
-          </div>
+          <Plus
+            className="size-4 flex-shrink-0 text-custom-sidebar-text-200"
+            strokeWidth={2}
+          />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a4b49e9 and 8d26d7e.

📒 Files selected for processing (1)
  • web/core/components/workspace/sidebar/dropdown.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: lint-space
  • GitHub Check: lint-admin
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (3)
web/core/components/workspace/sidebar/dropdown.tsx (3)

3-25: LGTM! Well-organized imports with clear categorization.

The import statements are properly organized and the introduction of SidebarDropdownItem promotes better component composition.


27-81: LGTM! Well-structured hooks and handlers.

The component demonstrates good practices with:

  • Clean organization of hooks
  • Proper error handling in sign-out functionality
  • Efficient workspace navigation handling

202-265: LGTM! Well-implemented user profile menu.

The implementation demonstrates good practices:

  • Proper use of Headless UI components
  • Smooth transitions
  • Secure access control for admin features

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

🧹 Nitpick comments (1)
web/core/components/workspace/sidebar/dropdown.tsx (1)

240-240: Remove redundant boolean conversion.

The expression isUserInstanceAdmin || false is unnecessary as isUserInstanceAdmin is already a boolean.

-              <div className={`pt-2 ${isUserInstanceAdmin || false ? "pb-2" : ""}`}>
+              <div className={`pt-2 ${isUserInstanceAdmin ? "pb-2" : ""}`}>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 59ac4f2 and 0faa184.

📒 Files selected for processing (2)
  • web/core/components/workspace/sidebar/dropdown-item.tsx (1 hunks)
  • web/core/components/workspace/sidebar/dropdown.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/workspace/sidebar/dropdown-item.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (4)
web/core/components/workspace/sidebar/dropdown.tsx (4)

3-25: LGTM! Import changes align with the refactoring.

The updated imports reflect the component's needs after refactoring, particularly the addition of the new SidebarDropdownItem component.


39-39: Remove unused allowPermissions import.

The allowPermissions hook is imported but not used in the component.

This aligns with the previous review comment questioning the need for permission checks.


131-155: LGTM! Improved workspace list implementation.

The changes enhance the user experience with:

  • Better scrolling behavior using vertical-scrollbar
  • Semantic HTML structure with sticky header
  • Clean implementation using the new SidebarDropdownItem component

163-194: LGTM! Enhanced action items with better accessibility.

The changes improve the UI with:

  • Better contrast for the Plus icon using backdrop inversion
  • Well-structured workspace invites section
  • Consistent styling across action items

@anmolsinghbhatia
Copy link
Collaborator

I tested it locally and noted the following observations:

  • Workspace name is not truncated for longer text.
  • Email with extended characters is not truncated.
  • Role and member sections are inconsistent.
  • Dropdown elements appear oversized.
  • Hover state is missing for Settings and Invite options.
  • Scrollbar appears in non-scrollable sections.
  • Text and icon colors are inconsistent.

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/components/workspace/sidebar/dropdown.tsx (2)

176-184: Enhance hover state visibility for the Invitations button.

The PR feedback mentions that hover states are not sufficiently visible. Consider enhancing the hover state to provide better visual feedback.

Apply this diff to enhance the hover state:

-                        className="flex items-center gap-2 rounded px-2 py-1 text-sm font-medium text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80"
+                        className="flex items-center gap-2 rounded px-2 py-1 text-sm font-medium text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 hover:text-custom-text-100 transition-colors duration-200"

231-241: Maintain consistent text colors across menu items.

The PR feedback highlights color inconsistencies. The text colors vary between different menu items, which affects visual coherence.

Apply this diff to maintain consistent colors:

-                <span className="px-2 text-custom-sidebar-text-200">{currentUser?.email}</span>
+                <span className="px-2 text-custom-sidebar-text-400">{currentUser?.email}</span>
                 <Link href="/profile">
                   <Menu.Item as="div">
-                    <span className="flex w-full items-center gap-2 rounded px-2 py-1 hover:bg-custom-sidebar-background-80">
+                    <span className="flex w-full items-center gap-2 rounded px-2 py-1 text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 hover:text-custom-text-100">
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e74c57d and bde4d43.

📒 Files selected for processing (2)
  • web/core/components/workspace/sidebar/dropdown-item.tsx (1 hunks)
  • web/core/components/workspace/sidebar/dropdown.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/workspace/sidebar/dropdown-item.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
web/core/components/workspace/sidebar/dropdown.tsx (2)

3-25: LGTM! Clean import organization.

The imports are well-organized and the new SidebarDropdownItem component is properly imported.


80-80: Address the TODO comment regarding workspace list scroll.

This TODO aligns with the reported scrollbar issues in the PR feedback. Consider implementing a proper scrolling solution to prevent the appearance of scrollbars in non-scrollable sections.

Would you like me to propose a solution for the workspace list scrolling implementation?

web/core/components/workspace/sidebar/dropdown.tsx Outdated Show resolved Hide resolved
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

🔭 Outside diff range comments (1)
web/core/components/workspace/sidebar/dropdown.tsx (1)

41-41: Verify the hardcoded admin flag.

The isUserInstanceAdmin is hardcoded to false, which could lead to permission-related issues. This should be derived from the user's actual permissions.

-  const isUserInstanceAdmin = false;
+  const { isUserInstanceAdmin } = useUser();
🧹 Nitpick comments (2)
web/core/components/workspace/sidebar/dropdown.tsx (2)

173-181: Add hover state styles for the invites link.

The PR feedback mentions missing hover states for the invites option. While there is a hover background color, the text color should also change on hover for better visual feedback.

-  className="flex items-center gap-2 rounded px-2 py-1 text-sm font-medium text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80"
+  className="flex items-center gap-2 rounded px-2 py-1 text-sm font-medium text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 hover:text-custom-sidebar-text-100"

229-229: Add email truncation in the avatar menu.

Similar to the main dropdown, the email in the avatar menu should also be truncated to prevent layout issues with long email addresses.

-  <span className="px-2 text-custom-sidebar-text-200">{currentUser?.email}</span>
+  <span className="px-2 text-custom-sidebar-text-200 truncate block w-full">{currentUser?.email}</span>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 93c0453 and b03673b.

📒 Files selected for processing (1)
  • web/core/components/workspace/sidebar/dropdown.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (1)
web/core/components/workspace/sidebar/dropdown.tsx (1)

142-148: Verify dropdown item styling in SidebarDropdownItem component.

The PR feedback mentions issues with dropdown size and color inconsistencies. While this file handles the container layout, please ensure that the SidebarDropdownItem component properly handles:

  1. Consistent sizing of dropdown elements
  2. Consistent text and icon colors
  3. Proper truncation of workspace names
✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check the implementation of SidebarDropdownItem for styling issues

# Find and display the SidebarDropdownItem implementation
ast-grep --pattern 'export const SidebarDropdownItem = $$$'

Length of output: 61


I'm not getting enough information from the previous script. I'll run additional searches using rg to locate the definition of SidebarDropdownItem with different patterns. This should help us verify its implementation details regarding styling issues.


🏁 Script executed:

#!/bin/bash
# Search for SidebarDropdownItem definitions using multiple patterns in TSX files

echo "Searching for function component definition:"
rg "function SidebarDropdownItem" -ttsx -A 10

echo "Searching for class component definition:"
rg "class SidebarDropdownItem" -ttsx -A 10

echo "Searching for export statement containing SidebarDropdownItem:"
rg "export.*SidebarDropdownItem" -ttsx -A 10

Length of output: 550


I'm not getting enough information from the previous search. Let's run additional shell scripts to locate the SidebarDropdownItem component by file name and search within TSX files for its definition. This should help us inspect its styling implementation.


🏁 Script executed:

#!/bin/bash
# Step 1: Locate any files that contain "SidebarDropdownItem" in the filename
echo "Searching for files with 'SidebarDropdownItem' in their name:"
fd -HI "SidebarDropdownItem.*\.tsx$" --type file

# Step 2: Search inside TSX files for the SidebarDropdownItem definition
# We add tsx file type for rg with a glob pattern.
echo "Searching within TSX files for 'export' statements related to SidebarDropdownItem:"
rg --type-add "tsx:*.tsx" -g "*.tsx" "export .*SidebarDropdownItem" -A 10

Length of output: 538


Let's inspect the SidebarDropdownItem component's implementation in detail to verify its styling. We need to review the file’s content – particularly for any styling rules (CSS classes, inline styles, or truncation logic) that address dropdown size, text/icon colors, and name truncation.


🏁 Script executed:

#!/bin/bash
echo "Displaying first 150 lines of web/core/components/workspace/sidebar/dropdown-item.tsx"
head -n 150 web/core/components/workspace/sidebar/dropdown-item.tsx

echo "Displaying last 150 lines of web/core/components/workspace/sidebar/dropdown-item.tsx"
tail -n 150 web/core/components/workspace/sidebar/dropdown-item.tsx

echo "Searching for occurrences of className attribute for styling clues:"
rg "className=" web/core/components/workspace/sidebar/dropdown-item.tsx

Length of output: 10876


Dropdown item styling verified.
The SidebarDropdownItem component correctly applies Tailwind classes that ensure:

• A full-width clickable item with a defined sub-container width (w-full on Link and w-[80%] for workspace info) for consistent sizing.
• Conditional text and icon color styling—using classes like text-custom-sidebar-text-100, text-custom-text-200, and text-custom-text-300—to manage active and inactive states.
• Proper truncation of workspace names via "truncate text-ellipsis".

Overall, the styling implementation appears to address the review feedback regarding dropdown size, color consistency, and text truncation.

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 comments (1)
web/core/components/workspace/sidebar/dropdown.tsx (1)

41-41: Fix hardcoded admin flag.

The isUserInstanceAdmin flag is hardcoded to false, which could prevent legitimate instance admins from accessing admin features.

Use the commented-out isUserInstanceAdmin from the useUser hook:

-  const isUserInstanceAdmin = false;
+  const { isUserInstanceAdmin } = useUser();
🧹 Nitpick comments (1)
web/core/components/workspace/sidebar/dropdown.tsx (1)

229-229: Add email truncation to profile menu.

The email display in the profile menu lacks truncation, which could cause layout issues with long email addresses.

Apply this diff to add email truncation:

-                <span className="px-2 text-custom-sidebar-text-200">{currentUser?.email}</span>
+                <span className="px-2 text-custom-sidebar-text-200 truncate">{currentUser?.email}</span>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b03673b and 4211709.

📒 Files selected for processing (1)
  • web/core/components/workspace/sidebar/dropdown.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (3)
web/core/components/workspace/sidebar/dropdown.tsx (3)

129-129: Fix the workspace list scroll issue.

The TODO comment indicates a known issue with the workspace list scroll. The current implementation uses overflow-y-scroll which shows the scrollbar even when not needed, as reported in the PR feedback.


130-132: LGTM! Email truncation implemented.

The email display now includes proper truncation with the truncate class, addressing the reported issue in the PR feedback.


173-181: LGTM! Hover states implemented correctly.

The menu items now have proper hover states using the hover:bg-custom-sidebar-background-80 class, addressing the reported issue in the PR feedback.

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

🧹 Nitpick comments (3)
web/core/components/workspace/sidebar/dropdown.tsx (3)

130-132: Improve email truncation implementation.

While truncation is added, the layout could be improved to prevent potential overflow issues.

-    <span className="rounded-md px-4 sticky top-0 z-[21] h-full w-full bg-custom-sidebar-background-100 pb-1 pt-3 text-sm font-medium text-custom-text-400 truncate flex-shrink-0">
+    <span className="rounded-md px-4 sticky top-0 z-[21] w-full bg-custom-sidebar-background-100 pb-1 pt-3 text-sm font-medium text-custom-text-400">
+      <span className="block truncate">{currentUser?.email}</span>
+    </span>

135-141: Optimize workspace list sorting.

The current implementation creates a new array on each render. Consider memoizing the sorted list.

+  const sortedWorkspacesList = useMemo(() => 
+    activeWorkspace
+      ? [activeWorkspace, ...workspacesList.filter((workspace) => workspace.id !== activeWorkspace?.id)]
+      : workspacesList,
+    [activeWorkspace, workspacesList]
+  );
+
   {(activeWorkspace
-    ? [
-        activeWorkspace,
-        ...workspacesList.filter((workspace) => workspace.id !== activeWorkspace?.id),
-      ]
-    : workspacesList
+    sortedWorkspacesList
   ).map((workspace) => (

173-181: Enhance hover state consistency.

As reported in PR feedback, the hover states for menu items should be more consistent.

-    <Link href="/invitations" className="w-full" onClick={handleItemClick}>
+    <Link 
+      href="/invitations" 
+      className="w-full transition-colors duration-300" 
+      onClick={handleItemClick}
+    >
       <Menu.Item
         as="div"
-        className="flex items-center gap-2 rounded px-2 py-1 text-sm font-medium text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80"
+        className="flex items-center gap-2 rounded px-2 py-1 text-sm font-medium text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 transition-colors duration-300"
       >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4211709 and 795095b.

📒 Files selected for processing (2)
  • web/core/components/workspace/sidebar/dropdown-item.tsx (1 hunks)
  • web/core/components/workspace/sidebar/dropdown.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/workspace/sidebar/dropdown-item.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
web/core/components/workspace/sidebar/dropdown.tsx (2)

129-129: Fix workspace list scroll behavior.

The workspace list still uses overflow-y-scroll which shows scrollbar even when not needed, as reported in PR feedback.


41-41: Verify the hardcoded isUserInstanceAdmin flag.

The isUserInstanceAdmin flag is hardcoded to false, which might prevent instance admins from accessing admin features.

@sriramveeraghanta sriramveeraghanta changed the title [WEB-3292] feat: upgraded workspace switcher [WEB-3292] feat: workspace switcher redesign Feb 7, 2025
@sriramveeraghanta sriramveeraghanta merged commit 20ba91b into preview Feb 7, 2025
9 of 14 checks passed
@sriramveeraghanta sriramveeraghanta deleted the feat-enchanced-workspace-switcher branch February 7, 2025 14:36
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.

5 participants