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

bug fix: community vc list not rendering dynamically #7583

Conversation

reactoholic
Copy link
Contributor

@reactoholic reactoholic commented Jan 31, 2025

bug fix: community vc list not rendering dynamically

Summary by CodeRabbit

  • New Features

    • Enhanced management of virtual contributors with new role assignment capabilities.
    • Introduced loading state management for delete actions, improving user feedback during operations.
    • Added dynamic generation of community options based on provided data.
  • Bug Fixes

    • Updated deletion process to ensure role set data refreshes after a virtual contributor is removed.
  • Chores

    • Added console log statements for improved debugging of account and role set data.

@reactoholic reactoholic added bug Something isn't working client labels Jan 31, 2025
Copy link

coderabbitai bot commented Jan 31, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces several modifications across multiple components related to the management of virtual contributors. Key changes include the addition of new constants and hooks for fetching role set data, the implementation of loading state management for delete operations, and the introduction of console log statements for debugging purposes. Overall, these updates enhance the functionality and data handling capabilities of the components involved without altering their core structures.

Changes

File Change Summary
src/domain/access/RoleSetAdmin/useRoleSetAdmin.ts Added a comment line indicating work-in-progress related to virtual contributors.
src/domain/community/contributor/Account/ContributorAccountView.tsx Added constants RoleName, RoleSetContributorType, and contributorTypes; introduced useRoleSetRoleAssignmentQuery hook; updated deleteVC function to refetch role set data after deletion; added comments for clarity.
src/domain/community/userAdmin/tabs/UserAdminAccountPage.tsx Added console log statement for accountData.
src/domain/journey/space/SpaceContext/SpaceContext.tsx Added console log statement for roleSetId.
src/domain/journey/space/pages/SpaceSettings/EntityConfirmDeleteDialog.tsx Introduced loading state management for delete action; minor formatting adjustments.
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/ChooseCommunity.tsx Added constant listItems using useMemo to dynamically generate selectable community options.
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useVirtualContributorWizard.tsx Added useRoleSetRoleAssignmentQuery hook, selectedRoleSetId state variable, and contributorTypes constant; modified onChooseCommunity function for role set ID management.

Possibly related PRs

  • Optimize the Contributor Account Tab and VC flow  #7444: The changes in the main PR are related to the modifications in the useRoleSetRoleAssignmentQuery hook, which is also introduced in the retrieved PR, indicating a direct connection in functionality related to role assignment for virtual contributors.
  • [VC Flow] Choose community step #7457: The changes in the main PR are related to the addition of the useRoleSetRoleAssignmentQuery hook, which is also introduced in the retrieved PR, indicating a shared focus on managing role assignments for virtual contributors.
  • fix empty bokID for non-external VCs #7068: The changes in the main PR are related to the addition of the useRoleSetRoleAssignmentQuery hook, which is also present in the retrieved PR's modifications to the useNewVirtualContributorWizard hook, indicating a shared focus on role assignment functionality.

Suggested reviewers

  • ccanos

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.

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

@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)
src/domain/access/RoleSetAdmin/useRoleSetAdmin.ts (1)

133-133: LGTM! Consider cache optimization.

The addition of fetchPolicy: 'network-only' effectively fixes the dynamic rendering issue by ensuring fresh data. However, for performance optimization, consider implementing cache invalidation instead of bypassing cache completely.

An alternative approach could be:

-    fetchPolicy: 'network-only',
+    fetchPolicy: 'cache-first',

And implement cache invalidation when role assignments change, using Apollo Client's cache manipulation methods:

// After successful role assignment/removal
client.cache.evict({ fieldName: 'roleSet' });
client.cache.gc();
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94307ac and e32ac7a.

📒 Files selected for processing (1)
  • src/domain/access/RoleSetAdmin/useRoleSetAdmin.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/domain/access/RoleSetAdmin/useRoleSetAdmin.ts (1)

Pattern src/**/*.{ts,tsx,js}: Review the React.js/TypeScript/JavaScript code for best practices and potential bugs.
Ensure that the code adheres to TypeScript's typing system and modern standards.
Use the following code guide documentation in the codebase: 'docs/code-guidelines.md'.
Ensure sufficient error handling and logging is present, but note:

  • We have a global error handler in place. So local try/catch blocks are not required unless they provide value beyond what the global error handler already covers.
  • Avoid flagging the absence of local error handling in cases where the global error handler suffices.
  • Avoid flagging the absence of logging in cases where the global logger is already in place (graphql usage).

Inform about the recommendation of not using non-null assertion,
except on GraphQL queries where the variable is asserted non-null and followed by a
skip: with the same variable.
Examples:

  • Not Required: there's a skip
    {
    variables: { templateId: templateId! },
    skip: !templateId,
    }

Check for common security vulnerabilities such as:

  • SQL Injection
  • XSS (Cross-Site Scripting)
  • CSRF (Cross-Site Request Forgery)
  • Insecure dependencies
  • Sensitive data exposure

@reactoholic reactoholic deleted the client-web/7539_bugfix_community-vc-list-is-not-updating-dynamically branch January 31, 2025 09:19
@reactoholic reactoholic restored the client-web/7539_bugfix_community-vc-list-is-not-updating-dynamically branch January 31, 2025 09:59
@reactoholic reactoholic reopened this Jan 31, 2025
Copy link

@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 (4)
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/ChooseCommunity.tsx (1)

35-35: Remove development comment.

The TODO comment @@@ WIP ~ #7539 should be removed as it's not providing any actionable information.

src/domain/community/contributor/Account/ContributorAccountView.tsx (3)

275-276: Translate comments to English.

Comments should be in English to maintain code readability for all team members.


196-196: Remove debug console.log.

Remove the debug console.log statement before merging to production.

-console.log('@@@ ACCOUNT.VCs >>>', virtualContributors);

288-288: Remove development comments.

Remove the @@@ WIP ~ #7539 comments as they don't provide actionable information.

Also applies to: 377-377, 614-614

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e32ac7a and 53514a3.

📒 Files selected for processing (7)
  • src/domain/access/RoleSetAdmin/useRoleSetAdmin.ts (1 hunks)
  • src/domain/community/contributor/Account/ContributorAccountView.tsx (8 hunks)
  • src/domain/community/userAdmin/tabs/UserAdminAccountPage.tsx (1 hunks)
  • src/domain/journey/space/SpaceContext/SpaceContext.tsx (1 hunks)
  • src/domain/journey/space/pages/SpaceSettings/EntityConfirmDeleteDialog.tsx (1 hunks)
  • src/main/topLevelPages/myDashboard/newVirtualContributorWizard/ChooseCommunity.tsx (1 hunks)
  • src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useVirtualContributorWizard.tsx (7 hunks)
✅ Files skipped from review due to trivial changes (3)
  • src/domain/access/RoleSetAdmin/useRoleSetAdmin.ts
  • src/domain/community/userAdmin/tabs/UserAdminAccountPage.tsx
  • src/domain/journey/space/SpaceContext/SpaceContext.tsx
🧰 Additional context used
📓 Path-based instructions (4)
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/ChooseCommunity.tsx (1)

Pattern src/**/*.{ts,tsx,js}: Review the React.js/TypeScript/JavaScript code for best practices and potential bugs.
Ensure that the code adheres to TypeScript's typing system and modern standards.
Use the following code guide documentation in the codebase: 'docs/code-guidelines.md'.
Ensure sufficient error handling and logging is present, but note:

  • We have a global error handler in place. So local try/catch blocks are not required unless they provide value beyond what the global error handler already covers.
  • Avoid flagging the absence of local error handling in cases where the global error handler suffices.
  • Avoid flagging the absence of logging in cases where the global logger is already in place (graphql usage).

Inform about the recommendation of not using non-null assertion,
except on GraphQL queries where the variable is asserted non-null and followed by a
skip: with the same variable.
Examples:

  • Not Required: there's a skip
    {
    variables: { templateId: templateId! },
    skip: !templateId,
    }

Check for common security vulnerabilities such as:

  • SQL Injection
  • XSS (Cross-Site Scripting)
  • CSRF (Cross-Site Request Forgery)
  • Insecure dependencies
  • Sensitive data exposure
src/domain/journey/space/pages/SpaceSettings/EntityConfirmDeleteDialog.tsx (1)

Pattern src/**/*.{ts,tsx,js}: Review the React.js/TypeScript/JavaScript code for best practices and potential bugs.
Ensure that the code adheres to TypeScript's typing system and modern standards.
Use the following code guide documentation in the codebase: 'docs/code-guidelines.md'.
Ensure sufficient error handling and logging is present, but note:

  • We have a global error handler in place. So local try/catch blocks are not required unless they provide value beyond what the global error handler already covers.
  • Avoid flagging the absence of local error handling in cases where the global error handler suffices.
  • Avoid flagging the absence of logging in cases where the global logger is already in place (graphql usage).

Inform about the recommendation of not using non-null assertion,
except on GraphQL queries where the variable is asserted non-null and followed by a
skip: with the same variable.
Examples:

  • Not Required: there's a skip
    {
    variables: { templateId: templateId! },
    skip: !templateId,
    }

Check for common security vulnerabilities such as:

  • SQL Injection
  • XSS (Cross-Site Scripting)
  • CSRF (Cross-Site Request Forgery)
  • Insecure dependencies
  • Sensitive data exposure
src/domain/community/contributor/Account/ContributorAccountView.tsx (1)

Pattern src/**/*.{ts,tsx,js}: Review the React.js/TypeScript/JavaScript code for best practices and potential bugs.
Ensure that the code adheres to TypeScript's typing system and modern standards.
Use the following code guide documentation in the codebase: 'docs/code-guidelines.md'.
Ensure sufficient error handling and logging is present, but note:

  • We have a global error handler in place. So local try/catch blocks are not required unless they provide value beyond what the global error handler already covers.
  • Avoid flagging the absence of local error handling in cases where the global error handler suffices.
  • Avoid flagging the absence of logging in cases where the global logger is already in place (graphql usage).

Inform about the recommendation of not using non-null assertion,
except on GraphQL queries where the variable is asserted non-null and followed by a
skip: with the same variable.
Examples:

  • Not Required: there's a skip
    {
    variables: { templateId: templateId! },
    skip: !templateId,
    }

Check for common security vulnerabilities such as:

  • SQL Injection
  • XSS (Cross-Site Scripting)
  • CSRF (Cross-Site Request Forgery)
  • Insecure dependencies
  • Sensitive data exposure
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useVirtualContributorWizard.tsx (1)

Pattern src/**/*.{ts,tsx,js}: Review the React.js/TypeScript/JavaScript code for best practices and potential bugs.
Ensure that the code adheres to TypeScript's typing system and modern standards.
Use the following code guide documentation in the codebase: 'docs/code-guidelines.md'.
Ensure sufficient error handling and logging is present, but note:

  • We have a global error handler in place. So local try/catch blocks are not required unless they provide value beyond what the global error handler already covers.
  • Avoid flagging the absence of local error handling in cases where the global error handler suffices.
  • Avoid flagging the absence of logging in cases where the global logger is already in place (graphql usage).

Inform about the recommendation of not using non-null assertion,
except on GraphQL queries where the variable is asserted non-null and followed by a
skip: with the same variable.
Examples:

  • Not Required: there's a skip
    {
    variables: { templateId: templateId! },
    skip: !templateId,
    }

Check for common security vulnerabilities such as:

  • SQL Injection
  • XSS (Cross-Site Scripting)
  • CSRF (Cross-Site Request Forgery)
  • Insecure dependencies
  • Sensitive data exposure
🔇 Additional comments (5)
src/domain/journey/space/pages/SpaceSettings/EntityConfirmDeleteDialog.tsx (1)

34-38: Good addition of loading state management!

The implementation of loading state using useLoadingState hook improves user feedback during deletion operations.

src/main/topLevelPages/myDashboard/newVirtualContributorWizard/ChooseCommunity.tsx (1)

36-52: Good use of useMemo for performance optimization!

The implementation efficiently maps spaces to SelectableKnowledgeSpace objects and memoizes the result to prevent unnecessary recalculations.

src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useVirtualContributorWizard.tsx (3)

79-83: Good use of enum values for contributor types!

The constant clearly defines the supported contributor types using the RoleSetContributorType enum.


504-505: Good addition of dynamic refetch!

The call to refetchRoleSetData after successful VC addition ensures the community VC list updates dynamically.


104-113: Verify the non-null assertion usage.

The non-null assertion on roleSetId is acceptable here since it's guarded by the skip condition.

✅ Verification successful

Non-null assertion usage is sound.
The output confirms that the query is guarded by the skip: !selectedRoleSetId condition, ensuring that selectedRoleSetId is defined when the query is executed. No changes are needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that roleSetId is always defined when the query is executed
ast-grep --pattern 'useRoleSetRoleAssignmentQuery({
  variables: {
    roleSetId: $_!,
    $$$
  },
  skip: !$_,
})'

Length of output: 1655

@reactoholic reactoholic marked this pull request as draft February 3, 2025 08:50
@reactoholic reactoholic force-pushed the client-web/7539_bugfix_community-vc-list-is-not-updating-dynamically branch from fb6131b to ac2497e Compare February 3, 2025 12:05
@reactoholic reactoholic force-pushed the client-web/7539_bugfix_community-vc-list-is-not-updating-dynamically branch from ac2497e to b662dc1 Compare February 3, 2025 12:06
@reactoholic
Copy link
Contributor Author

reactoholic commented Feb 3, 2025

This PR has been converted to a draft as we are still exploring a more efficient and optimized approach for fetching and revalidating role sets.

Currently, community VCs in the left panel update dynamically. The only scenario requiring a role set re-fetch to ensure dynamic updates of community VCs is within the VC deletion dialog.

@bobbykolev
Copy link
Collaborator

Fix in #7584

@bobbykolev bobbykolev closed this Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants