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

Fix incorrect total user count display on members page #426

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

choidabom
Copy link
Member

@choidabom choidabom commented Dec 11, 2024

What this PR does / why we need it?

This PR fixes the issue where the total user count displayed on the members page is incorrectly set to a maximum of 10, regardless of the actual number of users present in the workspace. The updated code will ensure that the total user count accurately reflects the number of users in the workspace.

Any background context you want to provide?

The inconsistency in the user count display could lead to confusion for users, as they may think that the workspace has fewer participants than it actually does. This fix addresses that by removing the cap on the displayed count.

What are the relevant tickets?

Fixes #300

Checklist

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

  • New Features

    • Enhanced user data processing in the MemberIndex component for accurate user count display.
    • Improved visual representation of the loading indicator.
  • Bug Fixes

    • Corrected the typo in the constant name from COLLAPESED_DRAWER_WIDTH to COLLAPSED_DRAWER_WIDTH.
  • Style

    • Updated icon imports for better consistency and clarity in the WorkspaceDrawer component.

@choidabom choidabom added the bug 🐞 Something isn't working label Dec 11, 2024
@choidabom choidabom requested a review from devleejb December 11, 2024 08:04
@choidabom choidabom self-assigned this Dec 11, 2024
Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

frontend/src/components/drawers/WorkspaceDrawer.tsx

Oops! Something went wrong! :(

ESLint: 9.12.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

Walkthrough

The changes in this pull request involve modifications to three main files: WorkspaceDrawer.tsx, layout.ts, and Index.tsx. The updates include correcting a typographical error in a constant name, enhancing icon imports in the drawer component, and improving user data handling in the member index page. Specifically, the user count now accurately reflects all users in a workspace instead of just those on the first page.

Changes

File Path Change Summary
frontend/src/components/drawers/WorkspaceDrawer.tsx Added imports for several Material-UI icons, removed redundant imports, and corrected a typo in the collapsedSize property.
frontend/src/constants/layout.ts Renamed constant from COLLAPESED_DRAWER_WIDTH to COLLAPSED_DRAWER_WIDTH.
frontend/src/pages/workspace/member/Index.tsx Updated user data processing to reflect total users in the workspace, changed loader size to 20.

Assessment against linked issues

Objective Addressed Explanation
Display the correct total number of users in the workspace (#300)

Possibly related PRs

  • Apply the design of sidebar #306: This PR modifies the WorkspaceDrawer.tsx component, which is directly related to the changes made in the main PR, specifically regarding the collapsedSize property and the use of icons.

Poem

In the drawer where icons play,
A typo fixed, brightens the day.
Users counted, all in sight,
No more hiding, all feels right.
Hooray for changes, let’s rejoice,
In code we trust, let’s raise our voice! 🐇✨


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. (Experiment)
  • @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 (3)
frontend/src/components/drawers/WorkspaceDrawer.tsx (1)

1-4: Consolidate Material-UI icon imports

Consider using the destructured import pattern for better maintainability and consistency:

-import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft";
-import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight";
-import PeopleIcon from "@mui/icons-material/People";
-import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard";
+import {
+  KeyboardDoubleArrowLeft as KeyboardDoubleArrowLeftIcon,
+  KeyboardDoubleArrowRight as KeyboardDoubleArrowRightIcon,
+  People as PeopleIcon,
+  SpaceDashboard as SpaceDashboardIcon
+} from "@mui/icons-material";
frontend/src/pages/workspace/member/Index.tsx (2)

73-73: Consider documenting standard component sizes.

The change from "sm" to an explicit size of 20 is good for consistency, but consider documenting these standard sizes in a shared constants file or design system documentation.


Line range hint 65-78: Consider enhancing error handling for infinite scroll.

While the infinite scroll implementation works correctly, consider adding error handling and user feedback for failed page loads. This would improve the user experience when network issues occur.

 <InfiniteScroll
   pageStart={0}
   loadMore={() => fetchNextPage()}
   hasMore={hasNextPage}
+  threshold={100}
   loader={
     <Box className="loader" key={0}>
       <CircularProgress size={20} />
     </Box>
   }
+  error={
+    <Box className="error" key={1}>
+      <Typography color="error">Failed to load more members. Click to retry.</Typography>
+    </Box>
+  }
   useWindow={false}
   style={{
     width: "100%",
   }}
 >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between deac17a and 04a3fd4.

📒 Files selected for processing (3)
  • frontend/src/components/drawers/WorkspaceDrawer.tsx (4 hunks)
  • frontend/src/constants/layout.ts (1 hunks)
  • frontend/src/pages/workspace/member/Index.tsx (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • frontend/src/constants/layout.ts
🔇 Additional comments (3)
frontend/src/components/drawers/WorkspaceDrawer.tsx (1)

17-17: Verify the constant rename impact across the codebase

The constant has been renamed from COLLAPESED_DRAWER_WIDTH to COLLAPSED_DRAWER_WIDTH. Let's ensure all references are updated.

Also applies to: 67-67, 80-80

✅ Verification successful

All references to the drawer width constant are using the correct spelling

The codebase search shows that all instances are using the new correct spelling COLLAPSED_DRAWER_WIDTH. The constant is defined in frontend/src/constants/layout.ts and consistently used in WorkspaceDrawer.tsx with no occurrences of the old misspelled version COLLAPESED_DRAWER_WIDTH.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of the old constant name
rg "COLLAPESED_DRAWER_WIDTH"

# Search for all uses of the new constant name to verify consistency
rg "COLLAPSED_DRAWER_WIDTH"

Length of output: 482

frontend/src/pages/workspace/member/Index.tsx (2)

54-54: LGTM! The user count now correctly displays the total number of users.

This change, combined with the useMemo implementation above, ensures that all workspace users are counted, fixing the previous limitation where only the first page was considered.


34-41: LGTM! The useMemo implementation correctly aggregates all users.

The implementation properly flattens the paginated user list, addressing the core issue where only the first page of users was being counted. The null coalescing operator provides a safe fallback.

Let's verify that we're correctly processing all pages:

✅ Verification successful

The useMemo implementation correctly handles paginated user data

The implementation properly concatenates all pages of users, and the backend supports cursor-based pagination with a default page size of 10 users per request. The frontend's infinite query implementation correctly fetches and accumulates all pages, effectively removing the previous 10-user limitation. The dependency array is properly set to trigger recalculation when pages change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any hardcoded page size limits in the API hooks
# that might affect the total user count

rg -A 5 "useGetWorkspaceUserListQuery|getWorkspaceUserList" 

Length of output: 1706


Script:

#!/bin/bash
# Let's check the API response type and pagination parameters
ast-grep --pattern 'type GetWorkspaceUserListResponse = {
  $$$
}'

# Also check the API call implementation for any page size parameters
rg -A 10 '/workspaces/\$\{workspaceId\}/users'

Length of output: 752


Script:

#!/bin/bash
# Let's check the type definitions for pagination-related types
ast-grep --pattern 'interface $_ {
  $$$
  cursor?: $_
  $$$
}'

# And check for any page size constants or configurations
rg -i "pagesize|page_size|limit" --type ts

Length of output: 3145

@@ -50,7 +51,7 @@ function MemberIndex() {
<Typography variant="h5" fontWeight="bold">
{workspace?.title}{" "}
<Typography component="span" variant="inherit" color="primary">
{workspaceUserPageList?.pages[0].workspaceUsers.length}
{userList.length}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As userList is paginated, we can't determine that the length is same with total users.
It seems it needs to modify backend API to know total number of users.

For reference, you can look at FindWorkspaceDocumentsResponse (Code Pointer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Incorrect user count display on /[workspace-slug]/members page
2 participants