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-2108] refactor: enhance workspace and project wrapper modularity #6207

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Dec 16, 2024

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • New Features
    • Introduced new enumeration value VIIXL for modal width.
    • Added new ProjectAuthWrapper and WorkspaceAuthWrapper components to enhance layout functionality.
  • Enhancements
    • Improved loading state management in ProjectAuthWrapper and WorkspaceAuthWrapper.
    • Enhanced error handling in WorkspaceInvitationsListItem for better user feedback.
  • Refactor
    • Updated import paths for authentication wrappers to reflect codebase reorganization.
    • Cleaned up redundant code in loading state checks.
  • Chores
    • Re-exported entities from project and workspace wrapper modules for better accessibility.

Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request introduces several changes across the Plane web application's layout and authentication components. The modifications primarily involve reorganizing layout wrappers, updating import paths, and enhancing loading state management for workspace and project authentication components. A new modal width enum value is also added to the UI constants. The changes appear to be part of a broader refactoring effort to improve code structure and component flexibility.

Changes

File Change Summary
packages/ui/src/modals/constants.ts Added new enum value VIIXL = "sm:max-w-7xl" to EModalWidth
web/app/[workspaceSlug]/(projects)/layout.tsx Updated import path for WorkspaceAuthWrapper
web/app/[workspaceSlug]/(projects)/projects/(detail)/layout.tsx Updated import path for ProjectAuthWrapper
web/ce/layouts/project-wrapper.tsx Added new ProjectAuthWrapper component
web/ce/layouts/workspace-wrapper.tsx Added new WorkspaceAuthWrapper component
web/core/layouts/auth-layout/project-wrapper.tsx Added isLoading prop to ProjectAuthWrapper
web/core/layouts/auth-layout/workspace-wrapper.tsx Added isLoading prop to WorkspaceAuthWrapper
web/ee/layouts/project-wrapper.tsx Re-exported all entities from CE project wrapper
web/ee/layouts/workspace-wrapper.tsx Re-exported all entities from CE workspace wrapper

Sequence Diagram

sequenceDiagram
    participant Parent as Parent Component
    participant Wrapper as Auth Wrapper
    participant Core as Core Auth Logic

    Parent->>Wrapper: Render with children
    Wrapper->>Wrapper: Check loading state
    alt Is Loading
        Wrapper-->>Parent: Render Loading Spinner
    else Not Loading
        Wrapper->>Core: Validate Authentication
        Core-->>Wrapper: Return Authentication Status
        Wrapper-->>Parent: Render Children
    end
Loading

Possibly related PRs

Suggested labels

🧹chore, 🛠️refactor, 🌐frontend

Suggested reviewers

  • SatishGandham

Poem

🐰 Wrappers dancing, imports anew,
Authentication's path we'll pursue
Modal widths stretch, components align
Refactoring code with a rabbit's design
Flexibility blooms, complexity fades 🌈

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request.


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.

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: 5

🧹 Nitpick comments (5)
packages/ui/src/modals/constants.ts (1)

16-16: Consider adding documentation for modal width use cases.

The new VIIXL enum value follows the existing pattern correctly. However, it would be helpful to document when each modal width should be used.

Consider adding a comment block above the enum explaining the intended use case for each size:

 export enum EModalWidth {
+  // SM (max-w-sm): Use for simple confirmation dialogs
+  // MD (max-w-md): Use for forms with few fields
+  // ...
+  // VIIXL (max-w-7xl): Use for full-width workspace views
   VIIXL = "sm:max-w-7xl",
web/ce/layouts/project-wrapper.tsx (1)

6-8: Consider simplifying the wrapper if no additional functionality is needed.

The interface currently only includes children. If no additional props or functionality will be added, consider whether this extra wrapper layer is necessary.

web/ce/layouts/workspace-wrapper.tsx (1)

10-15: Consider adding workspace-specific logic

The current implementation is a simple pass-through wrapper. Consider adding workspace-specific logic such as:

  • Workspace-level permission checks
  • Workspace data pre-fetching
  • Workspace-specific error boundaries
web/core/layouts/auth-layout/project-wrapper.tsx (1)

41-41: Consider extracting complex loading condition to a derived value

The loading condition combines multiple checks. Consider improving readability by extracting it to a derived value:

- if (isParentLoading || (!projectMemberInfo && projectId && hasPermissionToCurrentProject === null))
+ const isLoadingState = isParentLoading || (!projectMemberInfo && projectId && hasPermissionToCurrentProject === null);
+ if (isLoadingState)

Also applies to: 155-155

web/core/layouts/auth-layout/workspace-wrapper.tsx (1)

122-122: Consider consistent loading state management across wrappers

For consistency with the suggested improvement in project-wrapper.tsx, consider extracting the loading condition:

- if (isParentLoading || allWorkspaces === undefined || loader || isDBInitializing) {
+ const isLoadingState = isParentLoading || allWorkspaces === undefined || loader || isDBInitializing;
+ if (isLoadingState) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 442b0fd and 9e0dd8b.

📒 Files selected for processing (10)
  • packages/ui/src/modals/constants.ts (1 hunks)
  • web/app/[workspaceSlug]/(projects)/layout.tsx (1 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/layout.tsx (1 hunks)
  • web/ce/layouts/project-wrapper.tsx (1 hunks)
  • web/ce/layouts/workspace-wrapper.tsx (1 hunks)
  • web/core/components/workspace/settings/invitations-list-item.tsx (1 hunks)
  • web/core/layouts/auth-layout/project-wrapper.tsx (3 hunks)
  • web/core/layouts/auth-layout/workspace-wrapper.tsx (4 hunks)
  • web/ee/layouts/project-wrapper.tsx (1 hunks)
  • web/ee/layouts/workspace-wrapper.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • web/ee/layouts/workspace-wrapper.tsx
  • web/ee/layouts/project-wrapper.tsx
🔇 Additional comments (3)
web/core/components/workspace/settings/invitations-list-item.tsx (1)

123-129: LGTM! Error handling improvement

The error message is now more specific and maintains proper error object handling.

web/core/layouts/auth-layout/project-wrapper.tsx (1)

37-37: LGTM: Interface enhancement improves component flexibility

The addition of the optional isLoading prop enhances the component's modularity by allowing parent components to control the loading state.

web/core/layouts/auth-layout/workspace-wrapper.tsx (1)

29-31: ⚠️ Potential issue

Verify the impact of removing interface export

The export keyword has been removed from the interface declaration. If this interface is used in other files, they might be affected by this change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

why not just move the whole thing to CE?

@pushya22 pushya22 merged commit 4507802 into preview Dec 16, 2024
13 of 14 checks passed
@pushya22 pushya22 deleted the refactor-workspace-project-wrapper branch December 16, 2024 13:31
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.

3 participants