Skip to content

chore: Minor refactor for sign up workspace create flow.#40046

Merged
trishaanand merged 2 commits intoreleasefrom
chore/ce-refactor-first-workspace-app-signup
Apr 3, 2025
Merged

chore: Minor refactor for sign up workspace create flow.#40046
trishaanand merged 2 commits intoreleasefrom
chore/ce-refactor-first-workspace-app-signup

Conversation

@trishaanand
Copy link
Contributor

@trishaanand trishaanand commented Apr 3, 2025

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/test sanity

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/14237818849
Commit: c173b04
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Thu, 03 Apr 2025 08:32:21 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced the sign-up process with a new UserSignupHelper for automated default workspace and application provisioning.
    • Improved the email verification redirection for a smoother onboarding experience.
  • Refactor

    • Streamlined backend workflows by consolidating workspace and application creation logic, enhancing modularity and maintainability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 3, 2025

Walkthrough

This PR refactors authentication-related handlers by updating their dependency injection. In both AuthenticationSuccessHandler and AuthenticationSuccessHandlerCE, workspace-related dependencies have been removed and replaced with a new UserSignupHelper. The access modifier for the email verification redirection method in the CE handler has been changed to public. Additionally, new helper classes (UserSignupHelper and UserSignupHelperCE) have been added to encapsulate the logic for creating default workspaces and applications for users.

Changes

File(s) Change Summary
app/.../handlers/AuthenticationSuccessHandler.java
app/.../handlers/ce/AuthenticationSuccessHandlerCE.java
Updated constructor dependencies to remove WorkspaceRepository, WorkspaceService, and (in CE) WorkspacePermission; added UserSignupHelper. Changed formEmailVerificationRedirectionHandler from private to public and refactored application creation logic to delegate to UserSignupHelper.
app/.../helpers/UserSignupHelper.java
app/.../helpers/ce/UserSignupHelperCE.java
Introduced new helper classes for user signup processes. UserSignupHelper extends UserSignupHelperCE while the latter contains methods for creating default workspaces and applications using reactive patterns.
app/.../services/ce/UserServiceCEImpl.java Added shouldCreateWorkspaceForUser method to determine if a workspace should be created during user signup, modifying the createUser method to incorporate this logic.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant Auth as AuthHandler/CE
    participant Signup as UserSignupHelper
    participant SignupCE as UserSignupHelperCE
    participant WS as WorkspaceService
    participant AP as ApplicationPageService

    User ->> Auth: Successful Authentication
    Auth ->> Signup: Invoke signup logic
    Signup ->> SignupCE: Delegate workspace/app creation
    SignupCE ->> WS: Create default workspace
    WS -->> SignupCE: Workspace Created
    SignupCE ->> AP: Create default application
    AP -->> SignupCE: Application Created
    SignupCE -->> Signup: Return success
    Signup -->> Auth: Complete processing
Loading

Possibly related PRs

  • chore: refactor the creation of workspace and application on signup #39935: The changes in the main PR and this one both involve modifications to the AuthenticationSuccessHandlerCE class, specifically in how workspace and application creation logic is handled, including the removal of direct dependencies on WorkspaceRepository and WorkspaceService.
  • chore: Remove unused JSON signup API handler #37387: The changes in the main PR regarding the AuthenticationSuccessHandler class and the modifications in the AuthenticationSuccessHandlerCE class in this PR both involve the removal of the WorkspaceRepository and WorkspaceService dependencies, as well as the introduction of the UserSignupHelper, indicating a direct relationship at the code level.

Suggested reviewers

  • nsarupr
  • albinAppsmith

Poem

In the code forest, a helper is born,
Old dependencies are quietly torn,
With constructors now lean and bright,
The signup flow shines in a new light,
Handlers and helpers in joyful tune,
Celebrating changes beneath a digital moon.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 7118093 and c173b04.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UserServiceCEImpl.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: server-unit-tests / server-unit-tests
  • GitHub Check: server-spotless / spotless-check
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UserServiceCEImpl.java (2)

448-458: Well-structured addition of the shouldCreateWorkspaceForUser method

The new method provides a clean extension point for enterprise edition to override workspace creation behavior during signup, while maintaining the current functionality in community edition by defaulting to TRUE.


506-538: Good implementation of conditional workspace creation logic

The changes effectively introduce a toggle for workspace creation based on the shouldCreateWorkspaceForUser method. The code maintains existing functionality for CE while enabling EE to implement custom logic. The debug logging is helpful for troubleshooting.


🪧 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@trishaanand trishaanand added the ok-to-test Required label for CI label Apr 3, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Apr 3, 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 (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/authentication/handlers/ce/AuthenticationSuccessHandlerCE.java (1)

192-192: Consider documenting why this method is now public

Changed method visibility from private to public. While this allows reuse from other classes, the reason for this change isn't self-evident. Consider adding a comment explaining the rationale.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1c17f35 and 7118093.

📒 Files selected for processing (4)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/authentication/handlers/AuthenticationSuccessHandler.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/authentication/handlers/ce/AuthenticationSuccessHandlerCE.java (4 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/UserSignupHelper.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/UserSignupHelperCE.java (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/UserSignupHelperCE.java (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/authentication/handlers/AuthenticationSuccessHandler.java (1)
  • Slf4j (19-50)
app/server/appsmith-server/src/main/java/com/appsmith/server/authentication/handlers/ce/AuthenticationSuccessHandlerCE.java (1)
  • Slf4j (50-394)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: server-unit-tests / server-unit-tests
  • GitHub Check: server-spotless / spotless-check
🔇 Additional comments (11)
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/UserSignupHelper.java (1)

1-30: Well-structured component for handling signup-related workspace logic

This new class follows a clean inheritance pattern by extending UserSignupHelperCE and properly propagating dependencies to the parent class. The @Component annotation ensures Spring manages this bean in the application context.

app/server/appsmith-server/src/main/java/com/appsmith/server/authentication/handlers/ce/AuthenticationSuccessHandlerCE.java (3)

13-13: Good dependency addition for signup flow refactoring

Adding the UserSignupHelper import supports the new flow where workspace creation is handled by a dedicated helper.


66-66: Proper dependency injection for the new helper

Adding the UserSignupHelper as a dependency enables better separation of concerns by moving workspace creation logic outside of the authentication handler.


347-350: Good refactoring to delegate workspace/application creation

The implementation now properly delegates to the specialized helper class rather than handling this logic directly. This improves separation of concerns and makes the code more maintainable.

app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/UserSignupHelperCE.java (5)

1-39: Well-structured helper class with appropriate dependencies

The class definition, imports, and constructor are well-organized. The class properly initializes all necessary dependencies for workspace and application creation.


40-60: Good implementation with appropriate error handling

The createDefaultWorkspaceAndApplication method includes proper logging and error handling with doOnError. The method follows reactive programming patterns correctly.


62-74: Clean implementation for default application creation

The method is concise, well-documented, and follows reactive patterns. The name of the default application "My first application" is clear and user-friendly.


76-107: Well-implemented workspace retrieval/creation logic

The method handles different cases appropriately: using an existing workspace ID if provided, finding the first accessible workspace, or creating a new one if needed. The embedded comments explain the logic clearly.


109-121: Good extensibility pattern for EE customization

The method is designed to be overridden in the Enterprise Edition version, following a good pattern for code extensibility across different product tiers.

app/server/appsmith-server/src/main/java/com/appsmith/server/authentication/handlers/AuthenticationSuccessHandler.java (2)

5-5: Appropriate import for the new helper

Adding the import for UserSignupHelper is necessary for the constructor parameter change.


34-48: Good dependency injection update

The constructor now properly includes the UserSignupHelper and passes it to the parent class. This aligns with the refactoring to move workspace creation logic to a dedicated helper.

@trishaanand trishaanand merged commit c17e28e into release Apr 3, 2025
45 checks passed
@trishaanand trishaanand deleted the chore/ce-refactor-first-workspace-app-signup branch April 3, 2025 08:55
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
…#40046)

## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/test sanity

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/14237818849>
> Commit: c173b04
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14237818849&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Thu, 03 Apr 2025 08:32:21 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced the sign-up process with a new `UserSignupHelper` for
automated default workspace and application provisioning.
- Improved the email verification redirection for a smoother onboarding
experience.

- **Refactor**
- Streamlined backend workflows by consolidating workspace and
application creation logic, enhancing modularity and maintainability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants