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

Ability to select SpaceLevel2 on create VC #7386

Merged
merged 3 commits into from
Jan 3, 2025

Conversation

ccanos
Copy link
Contributor

@ccanos ccanos commented Jan 3, 2025

Describe the background of your pull request

What does your pull request do? Does it solve a bug (which one?), add a feature?

Additional context

Add any other context

Governance

  • Documentation is added
  • Test cases are added or updated

By submitting this pull request I confirm that:

Summary by CodeRabbit

Release Notes

  • Localization

    • Added new error message for space selection in Virtual Contributor creation
    • Refined language strings for improved user clarity
  • Form Improvements

    • Enhanced form error handling to prevent premature error displays
    • Updated space selection component with more robust interaction logic
  • Virtual Contributor Creation

    • Improved space selection process with hierarchical space listing
    • Streamlined space selection and community role assignment mechanisms
  • Technical Enhancements

    • Optimized GraphQL queries using fragments
    • Simplified type definitions for better code maintainability

@ccanos ccanos requested a review from bobbykolev January 3, 2025 12:03
Copy link

coderabbitai bot commented Jan 3, 2025

Walkthrough

This pull request introduces changes across multiple files related to the Virtual Contributor creation process and form handling. The modifications focus on improving localization, error handling, and space selection functionality. Key updates include adding a new error message for space selection, refining the Formik autocomplete component's error handling, and updating the space selection logic to support a more complex hierarchical structure of selectable spaces.

Changes

File Change Summary
src/core/i18n/en/translation.en.json Added new error message "spaceNotSelected" for Virtual Contributor wizard
src/core/ui/forms/FormikAutocomplete.tsx Enhanced error handling by adding meta.touched check and modified onBlur event handler
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/ExistingSpace.tsx Renamed interfaces, updated space selection logic, replaced FormikSelect with FormikAutocomplete
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/newVirtualContributorQueries.graphql Added new VCSelectableSpace fragment to consolidate space-related query fields
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useNewVirtualContributorWizard.tsx Simplified space selection logic, added SelectableSpace type, updated community role assignment

Sequence Diagram

sequenceDiagram
    participant User
    participant VCWizard as Virtual Contributor Wizard
    participant SpaceSelection as Space Selection Component
    participant Backend

    User->>VCWizard: Initiate Virtual Contributor Creation
    VCWizard->>SpaceSelection: Request Available Spaces
    Backend->>SpaceSelection: Return Selectable Spaces
    SpaceSelection-->>User: Display Hierarchical Space List
    User->>SpaceSelection: Select Space
    SpaceSelection->>VCWizard: Validate and Submit Space Selection
    alt Space Not Selected
        VCWizard-->>User: Display Error: "Unable to find selected spaceId"
    else Space Selected
        VCWizard->>Backend: Create Virtual Contributor
    end
Loading

Possibly Related PRs


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
Contributor

@bobbykolev bobbykolev left a comment

Choose a reason for hiding this comment

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

Changes are looking good, thanks for optimizing the queries further.
Lazy is far better to track and understand rather than the 'skip' logic.

@ccanos ccanos force-pushed the client-7347-from7379 branch from 01b326a to dbd454d Compare January 3, 2025 14:34
@ccanos
Copy link
Contributor Author

ccanos commented Jan 3, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Jan 3, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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 (3)
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/ExistingSpace.tsx (1)

36-59: Recursive subspace handling
This logic meticulously pushes each subspace and sub-subspace into the result. Consider a fully recursive approach if deeper nesting is possible.

src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useNewVirtualContributorWizard.tsx (2)

103-104: Auto-selecting the first space
Defaulting to account?.spaces?.[0] might be confusing if multiple spaces exist. Consider prompting the user explicitly.


259-276: Looping over parentRoleSetIds
Adding the VC to each parent role can be time-consuming. Consider whether parallel updates or partial failure handling is needed.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e3df846 and dbd454d.

⛔ Files ignored due to path filters (2)
  • src/core/apollo/generated/apollo-hooks.ts is excluded by !**/generated/**
  • src/core/apollo/generated/graphql-schema.ts is excluded by !**/generated/**
📒 Files selected for processing (5)
  • src/core/i18n/en/translation.en.json (1 hunks)
  • src/core/ui/forms/FormikAutocomplete.tsx (2 hunks)
  • src/main/topLevelPages/myDashboard/newVirtualContributorWizard/ExistingSpace.tsx (4 hunks)
  • src/main/topLevelPages/myDashboard/newVirtualContributorWizard/newVirtualContributorQueries.graphql (1 hunks)
  • src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useNewVirtualContributorWizard.tsx (5 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
src/core/ui/forms/FormikAutocomplete.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/newVirtualContributorQueries.graphql (1)

Pattern src/**/*.{graphql,gql}: Review the GraphQL schema and queries for best practices, potential bugs, and adherence to the project's GraphQL standards.
Ensure that the schema is well-defined and queries are optimized.
Check for security vulnerabilities.

src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useNewVirtualContributorWizard.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/ExistingSpace.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/core/i18n/en/translation.en.json (1)

Pattern src/**/*.json: Review the JSON files for correct syntax and structure.
Ensure that the configuration and data are accurate and follow the project's standards.
Check for sensitive data exposure and ensure that the data is properly validated.

🔇 Additional comments (16)
src/core/ui/forms/FormikAutocomplete.tsx (2)

36-36: Show errors only after the field is touched
This check prevents displaying errors prematurely and enhances user experience.


59-62: Marking the field as touched onBlur
Calling helpers.setTouched(true) before field.onBlur(e) ensures correct error highlighting and form state handling.

src/main/topLevelPages/myDashboard/newVirtualContributorWizard/ExistingSpace.tsx (6)

1-1: useMemo import
Using useMemo for memoized computations can help optimize performance in complex data transformations.


10-11: Replacing FormikSelect with FormikAutocomplete
Importing the new component aligns with the enhanced error handling approach.


13-18: New interface for knowledge spaces
Introducing SelectableKnowledgeSpace broadens the structure to incorporate hierarchical parents. Make sure external references are updated consistently.


24-25: onSubmit type signature updates
Accepting the revised SelectableKnowledgeSpace type ensures strong typing and consistent usage.


66-66: Immediate lookup from listItems
Filtering listItems by subspaceId for onSubmit is straightforward. Ensure usage of a suitable fallback if bok is not found.


88-93: FormikAutocomplete integration
Swapping to FormikAutocomplete with disablePortal={false} helps present suggestions in the normal DOM flow.

src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useNewVirtualContributorWizard.tsx (5)

29-29: Import ExistingSpace and SelectableKnowledgeSpace
The import is consistent with the refactored type definitions in ExistingSpace.tsx.


52-65: New SelectableSpace type
Defining a clear structure matches the GraphQL fragment’s fields. Good for consistency.


277-299: Fallback if no space selected
Properly shows an error message when neither createdSpaceId nor selectedExistingSpaceId is present.


304-320: Navigate to new space or fallback
Fetching the space URL on demand is a sound approach. Consider verifying the possibility of an empty or invalid response.


424-438: Adding VC to community with knowledge
Passing selectedKnowledge.parentRoleSetIds ensures the contributor is added to each parent space’s community as well. Make sure to handle potential mismatches in parent role sets.

src/main/topLevelPages/myDashboard/newVirtualContributorWizard/newVirtualContributorQueries.graphql (2)

21-25: Adopting the new VCSelectableSpace fragment
Referencing the fragment for each subspace simplifies and centralizes the field definitions.


34-52: VCSelectableSpace fragment definition
Using a fragment increases maintainability and avoids repetition. Verify that all included fields (like authorization) are necessary to keep payload size minimal.

src/core/i18n/en/translation.en.json (1)

3232-3234: LGTM! Clear and well-structured error message.

The error message is concise, informative, and properly placed within the Virtual Contributor wizard section.

@bobbykolev bobbykolev merged commit 0c6875b into client-7379-vc-bok-v2 Jan 3, 2025
3 checks passed
@bobbykolev bobbykolev deleted the client-7347-from7379 branch January 3, 2025 15:40
This was referenced Jan 8, 2025
ccanos added a commit that referenced this pull request Jan 13, 2025
…#7381)

* added new tabs to user + org admin pages; refactored how admin pages for users + orgs + vcs are managed; moved some global admin functionality out of domain down to platform admin; ...

* updated generation to match api tidy ups related to set of preference types + ID passing for org mutations

* fix compile errors related to dropping of separate UserPreferenceType enum

* Synchronize icons, remove comments, make sure there are no redundant settings calls.

* Links & Docs to BoK on VC creation (#7365)

* VC documents and links BoK - refactor the AddContent

* VC documents and links implementation without validation;

* resolve rabbit comments

---------

Co-authored-by: Petar Kolev <[email protected]>
Co-authored-by: reactoholic <[email protected]>

* Links and Docs - forgotten commit with Validation  (#7377)

* CalloutsSet entity (#7376)

* codegen passing with updated api

* fixed api + codegen passes

* code compiling

* pick up create callout privilege from the CalloutsSet

* callouts showing up after creation

* retrieving of callouts using only calloutsSet ID

* moved code around to have notion of calloutsSet in tree

* fix array dep breaking tool creation; small code optimizations;

---------

Co-authored-by: bobbykolev <[email protected]>

* VC knowledge base instead of subspace init

* Space creation after VC creation, loading, code opt & reorganization

* Fix docs uploading, code organization and documentation;

* fix uploading of docs in case there's no space under the acc; remove misleading createdSpaceId usage;

* useLoadingState instead of a new React State

* Fix - set properly the persona type depending on the 3 steps;

* Ability to select SpaceLevel2 on create VC (#7386)

* VC Knowledge Base callouts dialog (#7388)

* VC Knowledge Base callouts dialog - init.
* Filter available callout types.
* disable rich media on VC callout creation.
* Description component with update functionality.
* Update the Create Written Knowledge UI and initial state; Fix dialog titles in VC flow.
* Reingest logic in the Knowledge dialog.
* Remove the icon logic for CalloutVisibilityChangeDialog.
* Use the account hostname for space created in the VC flow.

* fix VC dialog not opening; remove outdated copy;

* storage config for KnowledgeBase description

---------

Co-authored-by: Neil Smyth <[email protected]>
Co-authored-by: Petar Kolev <[email protected]>
Co-authored-by: reactoholic <[email protected]>
Co-authored-by: Neil Smyth <[email protected]>
Co-authored-by: Carlos Cano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants