diff --git a/app/client/src/actions/actionActions.ts b/app/client/src/actions/actionActions.ts index 11f299e8a0..216aae3c56 100644 --- a/app/client/src/actions/actionActions.ts +++ b/app/client/src/actions/actionActions.ts @@ -229,7 +229,13 @@ export const updateActionProperty = ( }); }; -export const setActionsToExecuteOnPageLoad = (actions: string[]) => { +export const setActionsToExecuteOnPageLoad = ( + actions: Array<{ + executeOnLoad: boolean; + id: string; + name: string; + }>, +) => { return { type: ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD, payload: actions, diff --git a/app/client/src/api/PageApi.tsx b/app/client/src/api/PageApi.tsx index fa98192236..30853bb479 100644 --- a/app/client/src/api/PageApi.tsx +++ b/app/client/src/api/PageApi.tsx @@ -49,6 +49,12 @@ export interface SavePageResponse extends ApiResponse { id: string; layoutOnLoadActions: PageAction[][]; dsl: Partial>; + messages: string[]; + actionUpdates: Array<{ + executeOnLoad: boolean; + id: string; + name: string; + }>; }; } diff --git a/app/client/src/reducers/entityReducers/actionsReducer.tsx b/app/client/src/reducers/entityReducers/actionsReducer.tsx index 3e627b624d..7de4ab4ec0 100644 --- a/app/client/src/reducers/entityReducers/actionsReducer.tsx +++ b/app/client/src/reducers/entityReducers/actionsReducer.tsx @@ -339,12 +339,20 @@ const actionsReducer = createReducer(initialState, { }), [ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD]: ( state: ActionDataState, - actionIds: ReduxAction, + action: ReduxAction< + Array<{ + executeOnLoad: boolean; + id: string; + name: string; + }> + >, ) => { return produce(state, (draft) => { + const actionUpdateSearch = _.keyBy(action.payload, "id"); draft.forEach((action, index) => { - if (actionIds.payload.indexOf(action.config.id) > -1) { - draft[index].config.executeOnLoad = true; + if (action.config.id in actionUpdateSearch) { + draft[index].config.executeOnLoad = + actionUpdateSearch[action.config.id].executeOnLoad; } }); }); diff --git a/app/client/src/sagas/PageSagas.tsx b/app/client/src/sagas/PageSagas.tsx index 93f8932804..df62bd012e 100644 --- a/app/client/src/sagas/PageSagas.tsx +++ b/app/client/src/sagas/PageSagas.tsx @@ -77,6 +77,8 @@ import PerformanceTracker, { PerformanceTransactionName, } from "utils/PerformanceTracker"; import { WidgetTypes } from "constants/WidgetConstants"; +import { Toaster } from "components/ads/Toast"; +import { Variant } from "components/ads/common"; const getWidgetName = (state: AppState, widgetId: string) => state.entities.canvasWidgets[widgetId]; @@ -323,13 +325,19 @@ function* savePageSaga() { ); const isValidResponse = yield validateResponse(savePageResponse); if (isValidResponse) { - if ( - savePageResponse.data.layoutOnLoadActions && - savePageResponse.data.layoutOnLoadActions.length > 0 - ) { - for (const actionSet of savePageResponse.data.layoutOnLoadActions) { - yield put(setActionsToExecuteOnPageLoad(actionSet.map((a) => a.id))); - } + const { messages, actionUpdates } = savePageResponse.data; + // Show toast messages from the server + if (messages && messages.length) { + savePageResponse.data.messages.forEach((message) => { + Toaster.show({ + text: message, + type: Variant.info, + }); + }); + } + // Update actions + if (actionUpdates && actionUpdates.length > 0) { + yield put(setActionsToExecuteOnPageLoad(actionUpdates)); } yield put(savePageSuccess(savePageResponse)); PerformanceTracker.stopAsyncTracking(