Skip to content

feat: Replacing execute on load toggle with run behaviour in all actions / jsactions #40355

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

Merged
merged 28 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a9803cf
feat: Migrate executeOnLoad to runBehavior enum
ankitakinger Apr 22, 2025
acccb98
Merge pull request #40347 from appsmithorg/feat/replace-executeOnLoad…
vivek-appsmith Apr 23, 2025
3858d4d
feat: Replacing `executeOnLoad` with `runBehavior` in all action conf…
ankitakinger Apr 23, 2025
606b940
feat: Replacing remaining instances of `executeOnLoad` with `runBehav…
ankitakinger Apr 24, 2025
17bb150
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Apr 24, 2025
f61747a
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Apr 25, 2025
eff5699
chore: Update type for run behavior for some instances (#40393)
ankitakinger Apr 25, 2025
19605a6
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Apr 29, 2025
3867bcf
fix: Updating JSFunctionSettings unit test to fix failure (#40480)
ankitakinger Apr 29, 2025
d1af0b8
fix: Cyclic dependencies for reactive queries run behavior changes (#…
ankitakinger Apr 30, 2025
fd15967
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Apr 30, 2025
0c8bd0b
Merge branch 'feat/reactive-actions-run-behaviour' of https://github.…
ankitakinger Apr 30, 2025
62ccf03
ci: Fixing cypress tests that are failing due to the change from exec…
ankitakinger Apr 30, 2025
c5d2f5d
ci: Fixing remaining 4 failing cypress test cases (#40515)
ankitakinger Apr 30, 2025
bc2dcec
chore: Updating the spelling for `runBehaviour` (#40490)
ankitakinger May 2, 2025
fbaadc2
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger May 2, 2025
fb3aa4b
Merge branch 'feat/reactive-actions-run-behaviour' of https://github.…
ankitakinger May 2, 2025
0c74aee
ci: Updating fixtures to replace executeOnLoad with reactiveActions (…
ankitakinger May 2, 2025
5856863
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger May 7, 2025
1796b9d
Merge branch 'feat/reactive-actions-run-behaviour' of https://github.…
ankitakinger May 7, 2025
2e29675
Merge branch 'release' into feat/reactive-actions-run-behaviour
May 7, 2025
a46ef1c
Merge branch 'feat/reactive-actions-run-behaviour' of https://github.…
ankitakinger May 7, 2025
fa5b583
Merge branch 'release' into feat/reactive-actions-run-behaviour
May 7, 2025
ee2aeca
Merge branch 'feat/reactive-actions-run-behaviour' of https://github.…
ankitakinger May 8, 2025
d0a1e83
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger May 8, 2025
bf058d0
ci: Fixing partial export spec (#40611)
ankitakinger May 8, 2025
f34a597
feat: Updated references of all executeOnLoad to runBehaviour (#40361)
sneha122 May 8, 2025
7cd7438
feat: execute on load backwards compatibility backend changes (#40644)
sneha122 May 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig";

export const THEME = EditorTheme.LIGHT;

export enum ActionRunBehaviour {
ON_PAGE_LOAD = "ON_PAGE_LOAD",
MANUAL = "MANUAL",
}

export const RUN_BEHAVIOR = {
ON_PAGE_LOAD: {
label: "On page load",
subText: "Query runs when the page loads or when manually triggered",
value: ActionRunBehaviour.ON_PAGE_LOAD,
},
MANUAL: {
label: "Manual",
subText: "Query only runs when called in an event or JS with .run()",
value: ActionRunBehaviour.MANUAL,
},
};

export const RUN_BEHAVIOR_VALUES = Object.values(RUN_BEHAVIOR);

export type ActionRunBehaviourType = `${ActionRunBehaviour}`;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
const BASE_ACTION: ApiAction = {
dynamicBindingPathList: [],
cacheResponse: "",
executeOnLoad: false,
runBehavior: "MANUAL",
invalids: [],
isValid: false,
workspaceId: "",
Expand Down
13 changes: 7 additions & 6 deletions app/client/src/actions/pluginActionActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { EventLocation } from "ee/utils/analyticsUtilTypes";
import type { GenerateDestinationIdInfoReturnType } from "ee/sagas/helpers";
import type { Span } from "instrumentation/types";
import type { EvaluationReduxAction } from "./EvaluationReduxActionTypes";
import type { ActionRunBehaviour } from "PluginActionEditor/constants/PluginActionConstants";

export const createActionRequest = (
payload: Partial<Action>,
Expand Down Expand Up @@ -351,29 +352,29 @@ export const executePageLoadActions = (
};
};

export const setActionsToExecuteOnPageLoad = (
export const setActionsRunBehavior = (
actions: Array<{
executeOnLoad: boolean;
runBehavior: ActionRunBehaviour;
id: string;
name: string;
}>,
) => {
return {
type: ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD,
type: ReduxActionTypes.SET_ACTION_RUN_BEHAVIOR,
payload: actions,
};
};

export const setJSActionsToExecuteOnPageLoad = (
export const setJSActionsRunBehavior = (
actions: Array<{
executeOnLoad: boolean;
runBehavior: ActionRunBehaviour;
id: string;
name: string;
collectionId?: string;
}>,
) => {
return {
type: ReduxActionTypes.SET_JS_ACTION_TO_EXECUTE_ON_PAGELOAD,
type: ReduxActionTypes.SET_JS_ACTION_RUN_BEHAVIOR,
payload: actions,
};
};
Expand Down
9 changes: 5 additions & 4 deletions app/client/src/api/ActionAPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { APIRequest } from "constants/AppsmithActionConstants/ActionConstan
import type { WidgetType } from "constants/WidgetConstants";
import type { ActionParentEntityTypeInterface } from "ee/entities/Engine/actionHelpers";
import type { PostActionRunConfig } from "./types";
import type { ActionRunBehaviourType } from "PluginActionEditor/constants/PluginActionConstants";

export interface Property {
key: string;
Expand Down Expand Up @@ -301,12 +302,12 @@ class ActionAPI extends API {
});
}

static async toggleActionExecuteOnLoad(
static async updateActionRunBehavior(
actionId: string,
shouldExecute: boolean,
runBehavior: ActionRunBehaviourType,
) {
return API.put(ActionAPI.url + `/executeOnLoad/${actionId}`, undefined, {
flag: shouldExecute.toString(),
return API.put(ActionAPI.url + `/runBehavior/${actionId}`, undefined, {
behavior: runBehavior,
});
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/client/src/api/PageApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
import type { DSLWidget } from "WidgetProvider/constants";
import type { FetchApplicationResponse } from "ee/api/ApplicationApi";
import type { APP_MODE } from "entities/App";
import type { ActionRunBehaviour } from "PluginActionEditor/constants/PluginActionConstants";

export interface FetchPageRequest {
pageId: string;
Expand Down Expand Up @@ -69,7 +70,7 @@ export interface SavePageResponseData {
dsl: Partial<DSLWidget>;
messages: string[];
actionUpdates: Array<{
executeOnLoad: boolean;
runBehavior: ActionRunBehaviour;
id: string;
name: string;
collectionId?: string;
Expand Down
17 changes: 8 additions & 9 deletions app/client/src/ce/constants/ReduxActionConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ const JSEditorActionTypes = {
SET_FUNCTION_PROPERTY: "SET_FUNCTION_PROPERTY",
UPDATE_JS_FUNCTION_PROPERTY_INIT: "UPDATE_JS_FUNCTION_PROPERTY_INIT",
UPDATE_JS_FUNCTION_PROPERTY_SUCCESS: "UPDATE_JS_FUNCTION_PROPERTY_SUCCESS",
TOGGLE_FUNCTION_EXECUTE_ON_LOAD_INIT: "TOGGLE_FUNCTION_EXECUTE_ON_LOAD_INIT",
TOGGLE_FUNCTION_EXECUTE_ON_LOAD_SUCCESS:
"TOGGLE_FUNCTION_EXECUTE_ON_LOAD_SUCCESS",
SET_JS_ACTION_TO_EXECUTE_ON_PAGELOAD: "SET_JS_ACTION_TO_EXECUTE_ON_PAGELOAD",
SET_JS_ACTION_RUN_BEHAVIOR: "SET_JS_ACTION_RUN_BEHAVIOR",
SET_ACTIVE_JS_ACTION: "SET_ACTIVE_JS_ACTION",
UPDATE_FUNCTION_RUN_BEHAVIOR_INIT: "UPDATE_FUNCTION_RUN_BEHAVIOR_INIT",
UPDATE_FUNCTION_RUN_BEHAVIOR_SUCCESS: "UPDATE_FUNCTION_RUN_BEHAVIOR_SUCCESS",
};

const JSEditorActionErrorTypes = {
Expand All @@ -85,6 +84,7 @@ const JSEditorActionErrorTypes = {
REFACTOR_JS_ACTION_NAME_ERROR: "REFACTOR_JS_ACTION_NAME_ERROR",
UPDATE_JS_ACTION_BODY_ERROR: "UPDATE_JS_ACTION_BODY_ERROR",
UPDATE_JS_FUNCTION_PROPERTY_ERROR: "UPDATE_JS_FUNCTION_PROPERTY_ERROR",
UPDATE_FUNCTION_RUN_BEHAVIOR_ERROR: "UPDATE_FUNCTION_RUN_BEHAVIOR_ERROR",
};

const GitActionTypes = {
Expand Down Expand Up @@ -805,10 +805,9 @@ const ActionActionTypes = {
SET_ACTION_PROPERTY: "SET_ACTION_PROPERTY",
UPDATE_ACTION_PROPERTY: "UPDATE_ACTION_PROPERTY",
SWITCH_DATASOURCE: "SWITCH_DATASOURCE",
SET_ACTION_TO_EXECUTE_ON_PAGELOAD: "SET_ACTION_TO_EXECUTE_ON_PAGELOAD",
TOGGLE_ACTION_EXECUTE_ON_LOAD_SUCCESS:
"TOGGLE_ACTION_EXECUTE_ON_LOAD_SUCCESS",
TOGGLE_ACTION_EXECUTE_ON_LOAD_INIT: "TOGGLE_ACTION_EXECUTE_ON_LOAD_INIT",
SET_ACTION_RUN_BEHAVIOR: "SET_ACTION_RUN_BEHAVIOR",
UPDATE_ACTION_RUN_BEHAVIOR_INIT: "UPDATE_ACTION_RUN_BEHAVIOR_INIT",
UPDATE_ACTION_RUN_BEHAVIOR_SUCCESS: "UPDATE_ACTION_RUN_BEHAVIOR_SUCCESS",
};

const ActionActionErrorTypes = {
Expand All @@ -822,7 +821,7 @@ const ActionActionErrorTypes = {
FETCH_ACTIONS_FOR_PAGE_ERROR: "FETCH_ACTIONS_FOR_PAGE_ERROR",
SAVE_ACTION_NAME_ERROR: "SAVE_ACTION_NAME_ERROR",
SAVE_API_NAME_ERROR: "SAVE_API_NAME_ERROR",
TOGGLE_ACTION_EXECUTE_ON_LOAD_ERROR: "TOGGLE_ACTION_EXECUTE_ON_LOAD_ERROR",
UPDATE_ACTION_RUN_BEHAVIOR_ERROR: "UPDATE_ACTION_RUN_BEHAVIOR_ERROR",
};

const PropertyPanelActionTypes = {
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2583,7 +2583,7 @@ export const PREPARED_STATEMENT_WARNING = {

export const JS_EDITOR_SETTINGS = {
TITLE: () => "Settings",
ON_LOAD_TITLE: () => "Choose the functions to run on page load",
ON_LOAD_TITLE: () => "Choose functions run behavior",
};

export const CUSTOM_WIDGET_BUILDER_TAB_TITLE = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("generateDataTreeJSAction", () => {
body: "async () => {\n\t\t//use async-await or promises\n\t}",
jsArguments: [],
},
executeOnLoad: false,
runBehavior: "MANUAL",
dynamicBindingPathList: [
{
key: "body",
Expand Down Expand Up @@ -91,7 +91,7 @@ describe("generateDataTreeJSAction", () => {
body: "() => {\n\t\t//write code here\n\t}",
jsArguments: [],
},
executeOnLoad: false,
runBehavior: "MANUAL",
clientSideExecution: true,
dynamicBindingPathList: [
{
Expand Down Expand Up @@ -239,7 +239,7 @@ describe("generateDataTreeJSAction", () => {
body: "async () => {\n\t\t//use async-await or promises\n\t}",
jsArguments: [],
},
executeOnLoad: false,
runBehavior: "MANUAL",
dynamicBindingPathList: [
{
key: "body",
Expand Down Expand Up @@ -286,7 +286,7 @@ describe("generateDataTreeJSAction", () => {
body: "() => {\n\t\t//write code here\n\t}",
jsArguments: [],
},
executeOnLoad: false,
runBehavior: "MANUAL",
clientSideExecution: true,
dynamicBindingPathList: [
{
Expand Down
9 changes: 5 additions & 4 deletions app/client/src/ce/reducers/entityReducers/actionsReducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
UpdateActionPropertyActionPayload,
} from "actions/pluginActionActions";
import { klona } from "klona";
import type { ActionRunBehaviour } from "PluginActionEditor/constants/PluginActionConstants";

export interface ActionData {
isLoading: boolean;
Expand Down Expand Up @@ -310,11 +311,11 @@ export const handlers = {
},
]);
},
[ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD]: (
[ReduxActionTypes.SET_ACTION_RUN_BEHAVIOR]: (
draftMetaState: ActionDataState,
action: ReduxAction<
Array<{
executeOnLoad: boolean;
runBehavior: ActionRunBehaviour;
id: string;
name: string;
}>
Expand All @@ -324,8 +325,8 @@ export const handlers = {

draftMetaState.forEach((action) => {
if (action.config.id in actionUpdateSearch) {
action.config.executeOnLoad =
actionUpdateSearch[action.config.id].executeOnLoad;
action.config.runBehavior =
actionUpdateSearch[action.config.id].runBehavior;
}
});
},
Expand Down
13 changes: 7 additions & 6 deletions app/client/src/ce/reducers/entityReducers/jsActionsReducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { set, keyBy, findIndex, unset } from "lodash";
import { create } from "mutative";
import { klona } from "klona";
import type { ActionRunBehaviour } from "PluginActionEditor/constants/PluginActionConstants";

export const initialState: JSCollectionDataState = [];

Expand Down Expand Up @@ -360,19 +361,19 @@ export const handlers = {

return a;
}),
[ReduxActionTypes.TOGGLE_FUNCTION_EXECUTE_ON_LOAD_SUCCESS]: (
[ReduxActionTypes.UPDATE_FUNCTION_RUN_BEHAVIOR_SUCCESS]: (
state: JSCollectionDataState,
action: ReduxAction<{
actionId: string;
collectionId: string;
executeOnLoad: boolean;
runBehavior: ActionRunBehaviour;
}>,
): JSCollectionDataState =>
state.map((a) => {
if (a.config.id === action.payload.collectionId) {
const updatedActions = a.config.actions.map((jsAction) => {
if (jsAction.id === action.payload.actionId) {
set(jsAction, `executeOnLoad`, action.payload.executeOnLoad);
set(jsAction, `runBehavior`, action.payload.runBehavior);
}

return jsAction;
Expand All @@ -389,11 +390,11 @@ export const handlers = {

return a;
}),
[ReduxActionTypes.SET_JS_ACTION_TO_EXECUTE_ON_PAGELOAD]: (
[ReduxActionTypes.SET_JS_ACTION_RUN_BEHAVIOR]: (
state: JSCollectionDataState,
action: ReduxAction<
Array<{
executeOnLoad: boolean;
runBehavior: ActionRunBehaviour;
id: string;
name: string;
collectionId: string;
Expand All @@ -410,7 +411,7 @@ export const handlers = {

allActions.forEach((js) => {
if (js.id in actionUpdateSearch) {
js.executeOnLoad = actionUpdateSearch[js.id].executeOnLoad;
js.runBehavior = actionUpdateSearch[js.id].runBehavior;
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions app/client/src/ce/sagas/PageSagas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ import {
fetchActionsForPageError,
fetchActionsForPageSuccess,
fetchActionsForView,
setActionsToExecuteOnPageLoad,
setJSActionsToExecuteOnPageLoad,
setActionsRunBehavior,
setJSActionsRunBehavior,
} from "actions/pluginActionActions";
import type { UrlDataState } from "reducers/entityReducers/appReducer";
import { APP_MODE } from "entities/App";
Expand Down Expand Up @@ -536,15 +536,15 @@ export function* savePageSaga(action: ReduxAction<{ isRetry?: boolean }>) {
);

if (actions && actions.length) {
yield put(setActionsToExecuteOnPageLoad(actions));
yield put(setActionsRunBehavior(actions));
}

const jsActions = actionUpdates.filter((d) =>
d.hasOwnProperty("collectionId"),
);

if (jsActions && jsActions.length) {
yield put(setJSActionsToExecuteOnPageLoad(jsActions));
yield put(setJSActionsRunBehavior(jsActions));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const jsObject: JSCollectionData = {
jsArguments: [],
isAsync: false,
},
executeOnLoad: false,
runBehavior: "MANUAL",
clientSideExecution: true,
dynamicBindingPathList: [
{
Expand Down Expand Up @@ -86,7 +86,7 @@ const jsObject: JSCollectionData = {
jsArguments: [],
isAsync: true,
},
executeOnLoad: false,
runBehavior: "MANUAL",
clientSideExecution: true,
dynamicBindingPathList: [
{
Expand Down
Loading
Loading