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

fix: Add mode property to forkApplicationSaga #35841

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Aug 22, 2024

Description

This pull request adds the mode property to the forkApplicationSaga function in the ApplicationSagas.tsx file.

The mode property is set to APP_MODE.EDIT, allowing for better control and customization of the application editing mode.

Fixes #35835
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

/ok-to-test tags="@tag.Fork"

🔍 Cypress test results

Tip

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


Thu, 22 Aug 2024 12:33:03 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Enhanced the application forking functionality by introducing an edit mode, allowing for more flexible handling of different operational states during the forking process.
    • Improved state management in the page list by adding properties for tracking the current page and base page ID, enhancing user interaction with the page list.

This commit adds the `mode` property to the `forkApplicationSaga` function in the `ApplicationSagas.tsx` file. The `mode` property is set to `APP_MODE.EDIT`. This change allows for better control and customization of the application editing mode.
@rahulbarwal rahulbarwal added the Widgets & Accelerators Pod Issues related to widgets & Accelerators label Aug 22, 2024
@rahulbarwal rahulbarwal requested review from jacquesikot and nidhi-nair and removed request for ayushpahwa August 22, 2024 09:33
@rahulbarwal rahulbarwal self-assigned this Aug 22, 2024
Copy link
Contributor

coderabbitai bot commented Aug 22, 2024

Walkthrough

The update introduces modifications to the forkApplicationSaga function in ApplicationSagas.tsx by adding a mode property with the value APP_MODE.EDIT to the dispatched payload. Additionally, the pageListReducer has been enhanced to include currentBasePageId and currentPageId properties in the state. These changes aim to improve the application’s functionality and state management during the forking process and page tracking.

Changes

File Change Summary
app/client/src/ce/sagas/ApplicationSagas.tsx Added mode: APP_MODE.EDIT to the payload in the forkApplicationSaga function.
app/client/src/reducers/entityReducers/pageListReducer.tsx Added currentBasePageId and currentPageId properties to the state object in the reducer.

Assessment against linked issues

Objective Addressed Explanation
400 - Bad request error when forking apps (e.g., #35835)

🎉 In code we trust, with changes bright,
Forked applications take their flight.
With modes defined, they dance and sway,
In edit bliss, they find their way.
A bug resolved, now all is right! ✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@github-actions github-actions bot added Artifact Platform Product Issues related to the application platform Bug Something isn't working Critical This issue needs immediate attention. Drop everything else Fork App Issues related to forking apps Git Platform Issues related to the git & the app platform Needs Triaging Needs attention from maintainers to triage Production Regressed Scenarios that were working before but have now regressed and removed Bug Something isn't working labels Aug 22, 2024
@rahulbarwal rahulbarwal added the ok-to-test Required label for CI label Aug 22, 2024
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Aug 22, 2024
@rahulbarwal rahulbarwal changed the title Add mode property to forkApplicationSaga fix: Add mode property to forkApplicationSaga Aug 22, 2024
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions github-actions bot added the Bug Something isn't working label Aug 22, 2024
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/10505588490.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 35841.
recreate: .

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ae4190f and dfae0dd.

Files selected for processing (1)
  • app/client/src/ce/sagas/ApplicationSagas.tsx (1 hunks)
Additional context used
Learnings (2)
Common learnings
Learnt from: ankitakinger
PR: appsmithorg/appsmith#29965
File: app/client/src/ce/sagas/ApplicationSagas.tsx:736-742
Timestamp: 2024-01-03T09:53:22.824Z
Learning: The use of `editorId` instead of `appId` is an intentional change in the PR and is part of reverting to a previous functionality.
app/client/src/ce/sagas/ApplicationSagas.tsx (1)
Learnt from: ankitakinger
PR: appsmithorg/appsmith#29965
File: app/client/src/ce/sagas/ApplicationSagas.tsx:736-742
Timestamp: 2024-01-03T09:53:22.824Z
Learning: The use of `editorId` instead of `appId` is an intentional change in the PR and is part of reverting to a previous functionality.
Additional comments not posted (1)
app/client/src/ce/sagas/ApplicationSagas.tsx (1)

691-691: Verify the impact of adding mode: APP_MODE.EDIT.

The addition of the mode property with the value APP_MODE.EDIT in the payload aligns with the PR objectives. However, ensure that this change does not introduce any unintended side effects in the application logic.

Run the following script to verify the usage and impact of the APP_MODE.EDIT constant in the codebase:

Verification successful

Let's correct the script and search for APP_MODE.EDIT across the codebase to understand its usage and impact.


The addition of mode: APP_MODE.EDIT is consistent and safe.

The APP_MODE.EDIT constant is widely used across the codebase in various contexts, such as sagas, selectors, and components. Its integration into the forkApplicationSaga function aligns with existing patterns and should not introduce unintended side effects.

  • The usage of APP_MODE.EDIT is consistent and aligns with the application's logic for handling edit modes.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `APP_MODE.EDIT` in the codebase.

# Test: Search for the usage of `APP_MODE.EDIT`. Expect: Consistent usage across the codebase.
rg --type tsx -A 5 $'APP_MODE.EDIT'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify the usage of `APP_MODE.EDIT` in the codebase.

# Test: Search for the usage of `APP_MODE.EDIT`. Expect: Consistent usage across the codebase.
rg 'APP_MODE\.EDIT' -A 5

Length of output: 25525

Copy link

Deploy-Preview-URL: https://ce-35841.dp.appsmith.com

jacquesikot
jacquesikot previously approved these changes Aug 22, 2024
@jacquesikot
Copy link
Contributor

@rahulbarwal Why is this change just added? There is an if check for this action.payload.editMode in the code, so why did we not need to pass this before, but now we need to pass it, what changed? Or did we just miss it earlier?

…educer

This commit adds the currentBasePageId and currentPageId properties to the pageListReducer in the pageListReducer.tsx file. These properties are set to the basePageId of the defaultPage. This change allows for better tracking and management of the current base page and current page in the application.
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/10507741119.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 35841.
recreate: .

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dfae0dd and eba9176.

Files selected for processing (1)
  • app/client/src/reducers/entityReducers/pageListReducer.tsx (1 hunks)
Additional context used
Learnings (1)
Common learnings
Learnt from: ankitakinger
PR: appsmithorg/appsmith#29965
File: app/client/src/ce/sagas/ApplicationSagas.tsx:736-742
Timestamp: 2024-01-03T09:53:22.824Z
Learning: The use of `editorId` instead of `appId` is an intentional change in the PR and is part of reverting to a previous functionality.
Additional comments not posted (1)
app/client/src/reducers/entityReducers/pageListReducer.tsx (1)

64-65: Verify the usage of currentBasePageId and currentPageId.

The addition of currentBasePageId and currentPageId enhances state management. Make sure these properties are correctly utilized throughout the application to avoid inconsistencies.

Run the following script to verify the usage of these properties:

Verification successful

Let's try again to verify the usage of currentBasePageId and currentPageId in the codebase. I'll adjust the script to search without specifying the file type, which should resolve the issue.


Consistent Usage of currentBasePageId and currentPageId Verified

The properties currentBasePageId and currentPageId are consistently used across the codebase, including selectors, sagas, and components. This indicates that the changes made in the reducer are well-integrated into the application's logic.

  • Files where these properties are used:
    • app/client/test/factories/AppIDEFactoryUtils.ts
    • app/client/src/selectors/appViewSelectors.tsx
    • app/client/src/sagas/ActionExecution/NavigateActionSaga.ts
    • app/client/src/sagas/selectors.tsx
    • app/client/src/pages/Editor/index.tsx
    • ...and many more.

These findings confirm that the state management enhancements are correctly utilized throughout the application.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `currentBasePageId` and `currentPageId` in the codebase.

# Test: Search for the usage of `currentBasePageId` and `currentPageId`. Expect: Consistent usage across the codebase.
rg --type tsx -A 5 $'currentBasePageId|currentPageId'

Length of output: 82


Script:

#!/bin/bash
# Description: Verify the usage of `currentBasePageId` and `currentPageId` in the codebase.

# Test: Search for the usage of `currentBasePageId` and `currentPageId`. Expect: Consistent usage across the codebase.
rg 'currentBasePageId|currentPageId' -A 5

Length of output: 78963

Copy link

Deploy-Preview-URL: https://ce-35841.dp.appsmith.com

@rahulbarwal
Copy link
Contributor Author

@rahulbarwal Why is this change just added? There is an if check for this action.payload.editMode in the code, so why did we not need to pass this before, but now we need to pass it, what changed? Or did we just miss it earlier?

@jacquesikot I ran a git bisect to find the answer to this very question. It points to default resources PR: #34765
My guess is that prior to this the PagesAPI did not care if you missed mode parameter and now it does and errors out.
@nidhi-nair to confirm.

@@ -61,6 +61,8 @@ export const pageListReducer = createReducer(initialState, {
...action.payload,
defaultPageId: defaultPage?.pageId,
defaultBasePageId: defaultPage?.basePageId,
currentBasePageId: defaultPage?.basePageId,
Copy link
Contributor

Choose a reason for hiding this comment

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

What do these properties help with @rahulbarwal ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nidhi-nair

These properties are used by editor header to show the current page at top.
Basically, after adding edit mode, the page name in the list was not updating correctly, and reason was that it used currentPageId property.
When we forked an app form editor, it already has currentPageId which was not getting updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, thanks! I'm approving the PR as a quick fix, but is there a way to add tests to these flows as well?

@rahulbarwal rahulbarwal merged commit bac1350 into release Aug 23, 2024
44 checks passed
@rahulbarwal rahulbarwal deleted the fix/35835/addmode-in-fetch-app-pages-flow branch August 23, 2024 06:56
brayn003 added a commit that referenced this pull request Aug 26, 2024
brayn003 added a commit that referenced this pull request Aug 26, 2024
## Description
Reverts #35841

## Automation

/ok-to-test tags="@tag.All"

### 🔍 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/10555144301>
> Commit: f01f27d
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10555144301&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Mon, 26 Aug 2024 08:05:27 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Artifact Platform Product Issues related to the application platform Bug Something isn't working Critical This issue needs immediate attention. Drop everything else Fork App Issues related to forking apps Git Platform Issues related to the git & the app platform Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production Regressed Scenarios that were working before but have now regressed Widgets & Accelerators Pod Issues related to widgets & Accelerators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: 400 - Bad request error seen while forking apps from within the application
3 participants