From 0377b37bbc8a8f219b447c7b6224ae762c3fdaa9 Mon Sep 17 00:00:00 2001 From: sneha122 Date: Thu, 29 May 2025 15:01:06 +0530 Subject: [PATCH] fix: explicit automatic actions to be included in layout on load actions as well (#40778) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR fixes an issue in reactivity where if we have configured any action to be automatic explicitly (By changing from settings in action editor), then this action was not getting included in the layoutOnLoadActions (This matrix informs frontend on what actions it needs to execute on page load). Since we want all automatic actions to be on page load as well, whatever actions user configure explicitly to be automatic, should be included in page load as well. This PR fixes that. **Steps to test:** 1. Create an app with 2 queries -> Query1 and Query2 2. Go to Query1 -> settings and change run behaviour to be automatic. 3. Bind this query Query1 to Table1 widget 4. Reload the page and see if the table is getting populated or not Fixes #40781 _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.Sanity" ### :mag: Cypress test results > [!TIP] > ๐ŸŸข ๐ŸŸข ๐ŸŸข All cypress tests have passed! ๐ŸŽ‰ ๐ŸŽ‰ ๐ŸŽ‰ > Workflow run: > Commit: 0eca6f90a21ab10faaf7794a98567ccce4bef541 > Cypress dashboard. > Tags: `@tag.Sanity` > Spec: >
Thu, 29 May 2025 08:24:56 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit ## Summary by CodeRabbit - **Bug Fixes** - Improved detection of actions set to run automatically on page load, ensuring both "ON_PAGE_LOAD" and "AUTOMATIC" run behaviors are now recognized. This enhances reliability for users who configure actions to execute when a page loads. - Refined the logic for identifying user-configured executables that should not run on page load, now accurately recognizing only those set to "MANUAL" run behavior. --------- Co-authored-by: โ€œsneha122โ€ <โ€œsneha@appsmith.comโ€> --- .../onload/internal/OnLoadExecutablesUtilCEImpl.java | 3 ++- .../repositories/ce/CustomNewActionRepositoryCEImpl.java | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java index ea6da0f5fc..2cecaaa051 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java @@ -1309,7 +1309,8 @@ public class OnLoadExecutablesUtilCEImpl implements OnLoadExecutablesUtilCE { private boolean hasUserSetExecutableToNotRunOnPageLoad(Executable executable) { if (TRUE.equals(executable.getUserSetOnLoad()) - && executable.getRunBehaviour() != RunBehaviourEnum.ON_PAGE_LOAD) { + && (executable.getRunBehaviour() == null + || RunBehaviourEnum.MANUAL.equals(executable.getRunBehaviour()))) { return true; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java index 124767a758..7af73cc398 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java @@ -182,9 +182,10 @@ public class CustomNewActionRepositoryCEImpl extends BaseAppsmithRepositoryImpl< public Flux findUnpublishedActionsByPageIdAndRunbehaviourSetByUserOnPageLoad( String pageId, AclPermission permission) { BridgeQuery q = Bridge.or( - // First condition: new runBehaviour = ON_PAGE_LOAD - Bridge.equal( - NewAction.Fields.unpublishedAction_runBehaviour, RunBehaviourEnum.ON_PAGE_LOAD), + // First condition: new runBehaviour = ON_PAGE_LOAD or AUTOMATIC + Bridge.in( + NewAction.Fields.unpublishedAction_runBehaviour, + List.of(RunBehaviourEnum.ON_PAGE_LOAD.name(), RunBehaviourEnum.AUTOMATIC.name())), // Second condition: legacy executeOnLoad = true Bridge.isTrue(NewAction.Fields.unpublishedAction_executeOnLoad)) .isTrue(NewAction.Fields.unpublishedAction_userSetOnLoad)