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

chore: Remove unused JSON signup API handler #37387

Merged
merged 2 commits into from
Nov 15, 2024
Merged

Conversation

sharat87
Copy link
Member

@sharat87 sharat87 commented Nov 14, 2024

This PR removes the JSON-version of signup API handler, and its unused references. We use the other Form-body-version of this API, but not this. So this isn't needed.

Fewer things there are, fewer there are to protect.

Automation

/test sanity authentication

🔍 Cypress test results

Tip

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


Thu, 14 Nov 2024 14:49:54 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced new Cypress commands for enhanced API interactions and UI validations.
    • Added a method for handling user creation through form-encoded data.
  • Bug Fixes

    • Improved error handling and validation checks in various commands.
  • Documentation

    • Updated type definitions and submit handler functions for better clarity and maintainability.
  • Chores

    • Removed unused user management functionalities, streamlining the codebase.

Copy link
Contributor

coderabbitai bot commented Nov 14, 2024

Walkthrough

This pull request introduces significant changes to user management functionalities across several files. Key modifications include the removal of user creation and fetching capabilities in the UserApi.tsx file, alongside related action types in ReduxActionConstants.tsx. The createUserSaga has been eliminated from the sagas, and the UserControllerCE now processes user creation through form-encoded data instead of JSON. Additionally, Cypress commands have been updated to enhance testing reliability, and helper functions have been streamlined. Overall, these changes reflect a shift in how user-related operations are managed within the application.

Changes

File Change Summary
app/client/cypress/support/commands.js - Updated SignupFromAPI command, removing headers object.
- Added startInterceptRoutesForS3 command for API intercepts.
- Adjusted element interaction methods and added error handling in several commands.
app/client/src/ce/api/UserApi.tsx - Removed interfaces: LoginUserRequest, CreateUserRequest, CreateUserResponse, FetchUserRequest, FetchUserResponse.
- Deleted methods: createUser, fetchUser.
app/client/src/ce/constants/ReduxActionConstants.tsx - Removed action types: CREATE_USER_INIT, CREATE_USER_SUCCESS, CREATE_USER_ERROR.
app/client/src/ce/sagas/userSagas.tsx - Removed createUserSaga function and its associated logic.
app/client/src/ee/sagas/userSagas.tsx - Removed registration of createUserSaga from saga handling.
app/client/src/pages/UserAuth/helpers.ts - Removed CreatePasswordFormValues type and signupFormSubmitHandler function.
- Updated parameter and return types for resetPasswordSubmitHandler and forgotPasswordSubmitHandler.
app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java - Removed create method; added createFormEncoded method for user creation via form data.
app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java - Updated expected JSON output in the objectMapper_BeanCreated_WithPublicJsonViewAsDefault test.

Possibly related PRs

  • chore: Remove unused JSON superuser signup route #37378: The removal of the CreateSuperUserRequest interface and createSuperUser method in UserApi.tsx is related to the main PR's changes in the UserApi.tsx file, which also involved significant modifications to user management functionalities.
  • chore: Remove unused UserData.role #37381: The removal of the role field from the UpdateUserRequest interface and related changes in userSagas.tsx and UserData.java are directly connected to the main PR's focus on refining user management and API interactions, specifically regarding user roles.

Suggested labels

Bug

Suggested reviewers

  • nidhi-nair
  • trishaanand
  • abhvsn
  • mohanarpit

🌟 In the land of code, where functions reside,
A user creation saga took a swift ride.
With headers removed and types cast away,
New paths were forged for a brighter day.
Commands were polished, and tests made anew,
In this realm of code, we bid adieu! 🌟


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 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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Nov 14, 2024
@sharat87 sharat87 added the ok-to-test Required label for CI label Nov 14, 2024
Copy link

Failed server tests

  • com.appsmith.server.configurations.CommonConfigTest#objectMapper_BeanCreated_WithPublicJsonViewAsDefault

@sharat87 sharat87 marked this pull request as ready for review November 14, 2024 15:57
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 (1)
app/client/src/pages/UserAuth/helpers.ts (1)

56-60: Consider consolidating error handling patterns.

While the type improvements are good, I notice that error handling differs slightly between resetPasswordSubmitHandler and forgotPasswordSubmitHandler (one sets email to empty string, the other doesn't). Consider standardizing this pattern.

   }).catch((error) => {
-    error.email = "";
     throw new SubmissionError(error);
   });
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8a45e5a and f27d2c9.

📒 Files selected for processing (8)
  • app/client/cypress/support/commands.js (0 hunks)
  • app/client/src/ce/api/UserApi.tsx (0 hunks)
  • app/client/src/ce/constants/ReduxActionConstants.tsx (0 hunks)
  • app/client/src/ce/sagas/userSagas.tsx (0 hunks)
  • app/client/src/ee/sagas/userSagas.tsx (0 hunks)
  • app/client/src/pages/UserAuth/helpers.ts (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java (0 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java (1 hunks)
💤 Files with no reviewable changes (6)
  • app/client/cypress/support/commands.js
  • app/client/src/ce/api/UserApi.tsx
  • app/client/src/ce/constants/ReduxActionConstants.tsx
  • app/client/src/ce/sagas/userSagas.tsx
  • app/client/src/ee/sagas/userSagas.tsx
  • app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java
🔇 Additional comments (3)
app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java (1)

30-30: LGTM! Verify related view configurations

The updated assertion aligns with the removal of JSON signup handler. However, let's verify that this change is consistently reflected in related view configurations.

app/client/src/pages/UserAuth/helpers.ts (2)

4-4: LGTM! Good type safety improvement.

The explicit import of Dispatch type enhances type safety by replacing any type.


34-38: Verify the promise resolution handling in consumers.

The function now explicitly returns Promise<undefined> instead of Promise<any>. While this is more type-safe, ensure all consumers handle this correctly.

✅ Verification successful

Let's search more broadly to find any usage of this handler and understand the Promise handling context in the authentication flow.


Type change to Promise<undefined> is safe and properly handled

The function is only used in ResetPassword.tsx as a form submit handler, where the Promise resolution value is not used. The pattern is consistent with other auth handlers like forgotPasswordSubmitHandler which also return Promise<undefined>.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any direct usage of resetPasswordSubmitHandler
rg "resetPasswordSubmitHandler\(" -A 3

Length of output: 40


Script:

#!/bin/bash
# Search for resetPasswordSubmitHandler in TypeScript/JavaScript files
rg -t ts -t js "resetPasswordSubmitHandler" -B 2 -A 2

# Search for files containing resetPassword in their name
fd "resetPassword" 

# Look for any Promise-related handling in the UserAuth directory
rg "Promise" "app/client/src/pages/UserAuth" -B 2 -A 2

Length of output: 2649

@@ -27,6 +27,6 @@ public void objectMapper_BeanCreated_WithPublicJsonViewAsDefault() throws JsonPr
userData.setUserPermissions(null);

String value = objectMapper.writeValueAsString(userData);
JSONAssert.assertEquals("{\"proficiency\":\"abcd\",\"role\":\"new_role\"}", value, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Unsure of why the test case got updated as part of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Case of working on the wrong branch. 🙂
This change is already on release.

@sharat87 sharat87 merged commit 646f29f into release Nov 15, 2024
46 checks passed
@sharat87 sharat87 deleted the chore/no-json-signup branch November 15, 2024 07:09
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
This PR removes the JSON-version of signup API handler, and its unused
references. We use the other Form-body-version of this API, but not
this. So this isn't needed.

Fewer things there are, fewer there are to protect.

## Automation

/test sanity authentication

### 🔍 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/11838832000>
> Commit: f27d2c9
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11838832000&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Authentication`
> Spec:
> <hr>Thu, 14 Nov 2024 14:49:54 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **New Features**
- Introduced new Cypress commands for enhanced API interactions and UI
validations.
	- Added a method for handling user creation through form-encoded data.

- **Bug Fixes**
	- Improved error handling and validation checks in various commands.

- **Documentation**
- Updated type definitions and submit handler functions for better
clarity and maintainability.

- **Chores**
- Removed unused user management functionalities, streamlining the
codebase.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
This PR removes the JSON-version of signup API handler, and its unused
references. We use the other Form-body-version of this API, but not
this. So this isn't needed.

Fewer things there are, fewer there are to protect.

## Automation

/test sanity authentication

### 🔍 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/11838832000>
> Commit: f27d2c9
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11838832000&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Authentication`
> Spec:
> <hr>Thu, 14 Nov 2024 14:49:54 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **New Features**
- Introduced new Cypress commands for enhanced API interactions and UI
validations.
	- Added a method for handling user creation through form-encoded data.

- **Bug Fixes**
	- Improved error handling and validation checks in various commands.

- **Documentation**
- Updated type definitions and submit handler functions for better
clarity and maintainability.

- **Chores**
- Removed unused user management functionalities, streamlining the
codebase.

<!-- 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.

2 participants