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: remove redundant eval trigger #36764

Merged
merged 10 commits into from
Oct 10, 2024
Merged

Conversation

rishabhrathod01
Copy link
Contributor

@rishabhrathod01 rishabhrathod01 commented Oct 8, 2024

Fixes #36237

Automation

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

🔍 Cypress test results

Tip

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


Thu, 10 Oct 2024 09:40:31 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new action types for fetching published page resources, enhancing state management during the fetch process.
    • Streamlined the resource-fetching logic in the AppViewer component for improved efficiency.
  • Bug Fixes

    • Updated action handlers to accurately reflect the fetching state for published page resources.
  • Refactor

    • Simplified parameters for several functions related to page setup and fetching, promoting better clarity and maintainability.
  • Tests

    • Adjusted test cases to align with the updated action payload structure for fetching published pages.

Copy link
Contributor

coderabbitai bot commented Oct 8, 2024

Walkthrough

The changes in this pull request primarily involve modifications to the pageActions.tsx file, where the structure of action payloads has been refined. The firstLoad property has been removed from the FetchPublishedPageActionPayload, while a new basePageId property has been added to the FetchPublishedPageResourcesPayload. Additionally, the signatures of functions such as fetchPublishedPageAction and setupPublishedPage have been updated to reflect these structural changes. Other files, including sagas and reducers, have also been updated to align with these new action types and payload structures.

Changes

File Change Summary
app/client/src/actions/pageActions.tsx - Removed firstLoad from FetchPublishedPageActionPayload.
- Added basePageId: string to FetchPublishedPageResourcesPayload.
- Updated fetchPublishedPageAction to accept { basePageId, pageId }.
- Updated setupPublishedPage to remove firstLoad and include bustCache.
app/client/src/ce/constants/ReduxActionConstants.tsx - Added new action type: FETCH_PUBLISHED_PAGE_RESOURCES_SUCCESS.
- Added new error type: FETCH_PUBLISHED_PAGE_RESOURCES_ERROR.
app/client/src/ce/sagas/PageSagas.tsx - Added updateCanvasLayout and postFetchedPublishedPage functions.
- Refactored fetchPublishedPageSaga and fetchPublishedPageResourcesSaga to use the new functions.
app/client/src/ce/sagas/__tests__/PageSaga.test.ts - Updated test cases for setupPublishedPageSaga to remove firstLoad from action payload.
app/client/src/entities/Engine/AppViewerEngine.ts - Updated setupPublishedPage call to remove redundant parameter.
app/client/src/pages/AppViewer/index.tsx - Simplified imports and replaced setupPublishedPage with fetchPublishedPageResources.
app/client/src/reducers/uiReducers/appViewReducer.tsx - Added handlers for FETCH_PUBLISHED_PAGE_RESOURCES_INIT and FETCH_PUBLISHED_PAGE_RESOURCES_SUCCESS.

Possibly related PRs

Suggested labels

Test, ok-to-test, Widgets & Accelerators Pod

Suggested reviewers

  • ayushpahwa
  • nidhi-nair
  • sharat87

🎉 In the code’s dance, changes take flight,
Removing firstLoad, making it right.
New basePageId, a structure refined,
In sagas and reducers, harmony aligned.
With tests updated, the flow is so clear,
Cheers to the changes, let’s give a cheer! 🎊


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 Bug Something isn't working label Oct 8, 2024
@rishabhrathod01 rishabhrathod01 marked this pull request as ready for review October 8, 2024 17:43
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/AppViewer/index.tsx (1)

165-170: Excellent work on refactoring the page resource fetching, students!

Your modification to use fetchPublishedPageResources instead of setupPublishedPage is a step in the right direction. This change streamlines our code and makes the intent clearer. Well done!

However, to make your code even more readable, consider destructuring the pageId from the pages.find() result. Here's a small homework assignment for you:

Try refactoring the code like this:

const page = pages.find((page) => page.basePageId === basePageId);
if (page?.pageId) {
  dispatch(
    fetchPublishedPageResources({
      basePageId,
      pageId: page.pageId,
    }),
  );
}

This approach avoids nested property access and makes the code a bit easier to follow. Keep up the good work!

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8463d02 and 026ef4e.

📒 Files selected for processing (7)
  • app/client/src/actions/pageActions.tsx (2 hunks)
  • app/client/src/ce/constants/ReduxActionConstants.tsx (1 hunks)
  • app/client/src/ce/sagas/PageSagas.tsx (5 hunks)
  • app/client/src/ce/sagas/tests/PageSaga.test.ts (0 hunks)
  • app/client/src/entities/Engine/AppViewerEngine.ts (1 hunks)
  • app/client/src/pages/AppViewer/index.tsx (2 hunks)
  • app/client/src/reducers/uiReducers/appViewReducer.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/ce/sagas/tests/PageSaga.test.ts
🧰 Additional context used
🔇 Additional comments (13)
app/client/src/reducers/uiReducers/appViewReducer.tsx (3)

29-33: Excellent addition, class! Let's discuss the new FETCH_PUBLISHED_PAGE_RESOURCES_INIT action handler.

This new handler is doing a splendid job of setting our isFetchingPage state to true when we begin fetching published page resources. It's like raising your hand to answer a question - it shows we're actively working on something!

Remember, class, this is important because:

  1. It helps us track when a fetch operation is in progress.
  2. We can use this state to show loading indicators in our UI.
  3. It follows the same pattern as our existing FETCH_PUBLISHED_PAGE_INIT handler, maintaining consistency in our code.

Keep up the good work!


52-59: Well done on adding the FETCH_PUBLISHED_PAGE_RESOURCES_SUCCESS action handler!

Class, let's examine this new addition to our reducer. This handler is responsible for setting our isFetchingPage state back to false when we've successfully fetched our published page resources. It's like putting your hand down after you've finished answering a question - it shows we're done with our task!

Here's why this is important:

  1. It signals the completion of our fetch operation.
  2. We can use this to remove loading indicators from our UI.
  3. It maintains symmetry with our INIT action, providing a clear start and end to our fetching process.

Remember, good code tells a story, and this handler helps complete the narrative of our resource fetching process. Excellent work!


Line range hint 29-59: Class, let's summarize what we've learned from these changes!

These additions to our appViewReducer are like adding new chapters to our Redux storybook. They enhance our ability to manage the state of fetching published page resources, which is crucial for keeping our application's narrative coherent and our users informed.

Here's what we've accomplished:

  1. We've added symmetrical handlers for initializing and completing the fetch process.
  2. We're maintaining consistency with our existing patterns, which is key for code readability.
  3. We've improved our ability to manage loading states, which will enhance our user experience.

Remember, class, good state management is like good storytelling - it keeps everyone on the same page and prevents confusion. These changes do just that!

Keep up the excellent work, and don't forget to apply these principles in your future coding adventures!

app/client/src/entities/Engine/AppViewerEngine.ts (1)

108-108: Class, let's examine this change carefully.

Now, students, we've noticed an interesting modification in our code. The setupPublishedPage function call has had one of its parameters removed. This is like changing the ingredients in a recipe - it might affect the final dish!

Let's break it down:

  1. We've removed the second true parameter from the function call.
  2. This change could potentially alter how our page setup process works.

Here's your homework assignment:

  1. Verify that this change aligns with the updated setupPublishedPage function definition. We want to make sure our function is receiving all the ingredients it needs!
  2. If this change is correct, please update any relevant documentation. Remember, good documentation is like a clear lesson plan - it helps everyone understand what's happening.

Can anyone tell me why it's important to keep our function calls and definitions in sync?

To help us with our verification, let's use this little helper:

Remember, class, always double-check your work!

app/client/src/pages/AppViewer/index.tsx (1)

31-31: Well done on simplifying the import statement, class!

I'm pleased to see you've consolidated the imports related to fetching published page resources. This change not only makes our code more concise but also indicates a thoughtful refactoring of our action creators. Remember, clean imports lead to cleaner code!

app/client/src/actions/pageActions.tsx (3)

300-307: Now, let's turn our attention to the fetchPublishedPageResources function.

Students, observe how the function signature has evolved. We're now using object destructuring to accept basePageId and pageId as parameters. This is a more elegant approach that aligns with our updated interface.

Can anyone tell me the benefits of this new structure? It provides better clarity and makes the function more flexible for future additions. Also, notice how the payload now includes basePageId. This ensures consistency with our interface changes.

Remember, when we make changes like this, it's crucial to update all the places where this function is called. Let's verify that:

#!/bin/bash
# Search for calls to fetchPublishedPageResources
rg "fetchPublishedPageResources\(" --type typescript

Line range hint 693-703: Let's examine the changes to our setupPublishedPage function, class.

Notice how we've removed the firstLoad parameter. Can anyone tell me what implications this might have? It suggests we're changing our approach to handling the initial page load.

Also, observe that bustCache is now a required parameter. This is an important change in our cache management strategy. It forces developers to be explicit about whether they want to bust the cache or not.

These changes could have a significant impact on our page setup process. We need to ensure that all calls to this function are updated accordingly.

Let's do a quick check to see where we might need to update our code:

#!/bin/bash
# Search for calls to setupPublishedPage
rg "setupPublishedPage\(" --type typescript

76-77: Class, let's examine the addition of basePageId to our interface.

The addition of basePageId: string to the FetchPublishedPageResourcesPayload interface is an interesting development. Can anyone tell me how this might affect our page resource fetching process? It seems we're now distinguishing between a base page and the current page. This could have implications for how we manage page inheritance or versioning. Let's discuss the potential use cases for this new property.

To ensure we understand the full impact of this change, let's investigate its usage:

app/client/src/ce/constants/ReduxActionConstants.tsx (3)

984-985: Well done, class! These new constants are a great addition to our Redux action types.

I'm pleased to see you've added FETCH_PUBLISHED_PAGE_RESOURCES_INIT and FETCH_PUBLISHED_PAGE_RESOURCES_SUCCESS to our AppViewActionTypes. These new action types will help us manage the state of fetching published page resources more effectively.

Remember, class, when we add new action types, it's important to consider their impact on the rest of our application. These new constants suggest we're improving how we handle published pages, which could lead to better performance or new features for our users.

Don't forget to update any relevant reducers and sagas to handle these new action types!


986-986: Excellent work on adding the error type, students!

I see you've included FETCH_PUBLISHED_PAGE_RESOURCES_ERROR in our AppViewActionErrorTypes. This is very good! Always remember, proper error handling is crucial in our Redux applications.

Now, let's review our error handling best practices:

  1. Use this error type in your reducers to update the state when an error occurs.
  2. In your sagas or thunks, make sure to dispatch this error action when the fetch fails.
  3. Consider creating a user-friendly error message that can be displayed in the UI.

Keep up the good work, and don't forget to test your error scenarios thoroughly!


984-986: Class, let's summarize what we've learned from these changes!

These additions to our Redux action constants are focused and well-integrated:

  1. We've added FETCH_PUBLISHED_PAGE_RESOURCES_INIT and FETCH_PUBLISHED_PAGE_RESOURCES_SUCCESS to AppViewActionTypes.
  2. We've also included FETCH_PUBLISHED_PAGE_RESOURCES_ERROR in AppViewActionErrorTypes.

These changes suggest we're enhancing our handling of published page resources. This could lead to improved performance or new features in our application's view mode.

Remember, when we make changes like these, we need to consider the broader impact:

  • Update relevant reducers and sagas
  • Implement proper error handling
  • Test thoroughly, including success and error scenarios

Great job on maintaining consistency with our existing code structure. Keep up the excellent work!

app/client/src/ce/sagas/PageSagas.tsx (2)

1439-1445: ⚠️ Potential issue

Confirm 'fetchPublishedPageAction' Accepts 'pageWithMigratedDsl' Parameter

Dear students, in lines 1439 to 1445, we are passing pageWithMigratedDsl as the third argument to fetchPublishedPageAction. It's important to verify that fetchPublishedPageAction is designed to accept this parameter. If it doesn't, this might cause issues during action dispatching.

Let's run a script to verify the action's parameters:


416-420: ⚠️ Potential issue

Ensure 'response.pageWithMigratedDsl' is of Type 'FetchPageResponse'

Dear students, in lines 416 to 420, we are passing response.pageWithMigratedDsl to the function postFetchedPublishedPage. Please verify that response.pageWithMigratedDsl is indeed of type FetchPageResponse, as expected by postFetchedPublishedPage. If it isn't, this could lead to type errors or unexpected behavior during execution.

Let's run a script to confirm the type of response.pageWithMigratedDsl:

✅ Verification successful

Let's run a corrected script to verify the type of response.pageWithMigratedDsl:


Alright, let's adjust our approach to successfully verify the type of response.pageWithMigratedDsl. We'll focus our search on TypeScript files by specifying their extensions directly.


Great job! The type of response.pageWithMigratedDsl is correctly defined as FetchPageResponse, aligning with the expectations of the postFetchedPublishedPage function. Everything looks good here!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the type of 'response.pageWithMigratedDsl' when passed to 'postFetchedPublishedPage'

# Search for the definition of 'postFetchedPublishedPage' to confirm expected parameter types
rg --type typescript 'export function\* postFetchedPublishedPage\(' -A 5

# Search where 'response.pageWithMigratedDsl' is defined to check its type
rg --type typescript 'const response =.*' -A 5

# Find all instances where 'postFetchedPublishedPage' is called
rg 'postFetchedPublishedPage\(' -A 3

Length of output: 1051


Script:

#!/bin/bash
# Description: Corrected script to verify the type of 'response.pageWithMigratedDsl' when passed to 'postFetchedPublishedPage'

# Search for the definition of 'postFetchedPublishedPage' to confirm expected parameter types
rg --type typescript 'export function\* postFetchedPublishedPage\(' -A 5

# Search where 'response' is defined to check the type of 'pageWithMigratedDsl'
rg --type typescript 'const response =.*' -A 5

# Find all instances where 'postFetchedPublishedPage' is called
rg 'postFetchedPublishedPage\(' -A 3

Length of output: 480


Script:

#!/bin/bash
# Description: Updated script to verify the type of 'response.pageWithMigratedDsl' when passed to 'postFetchedPublishedPage'

# Search for the definition of 'postFetchedPublishedPage' to confirm expected parameter types in .ts and .tsx files
rg 'export function\* postFetchedPublishedPage\(' --glob '*.ts' --glob '*.tsx' -A 5

# Search where 'response.pageWithMigratedDsl' is defined to check its type in .ts and .tsx files
rg 'const response =.*' --glob '*.ts' --glob '*.tsx' -A 5

# Find all instances where 'postFetchedPublishedPage' is called in .ts and .tsx files
rg 'postFetchedPublishedPage\(' --glob '*.ts' --glob '*.tsx' -A 3

Length of output: 56748

@github-actions github-actions bot added Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage QA Needs QA attention QA Pod Issues under the QA Pod Query & JS Pod Issues related to the query & JS Pod Release labels Oct 8, 2024
@rishabhrathod01 rishabhrathod01 added the ok-to-test Required label for CI label Oct 10, 2024
@rishabhrathod01 rishabhrathod01 merged commit 00981e3 into release Oct 10, 2024
212 checks passed
@rishabhrathod01 rishabhrathod01 deleted the fix/redundant-eval-trigger-ce branch October 10, 2024 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI QA Pod Issues under the QA Pod QA Needs QA attention Query & JS Pod Issues related to the query & JS Pod Release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Eval getting triggered twice on page switch in deployed mode
2 participants