Show a toast when action executeOnLoad status updates (#3042)
This commit is contained in:
parent
56170b0cdf
commit
ebd61efcca
|
|
@ -229,7 +229,13 @@ export const updateActionProperty = (
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setActionsToExecuteOnPageLoad = (actions: string[]) => {
|
export const setActionsToExecuteOnPageLoad = (
|
||||||
|
actions: Array<{
|
||||||
|
executeOnLoad: boolean;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}>,
|
||||||
|
) => {
|
||||||
return {
|
return {
|
||||||
type: ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD,
|
type: ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD,
|
||||||
payload: actions,
|
payload: actions,
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,12 @@ export interface SavePageResponse extends ApiResponse {
|
||||||
id: string;
|
id: string;
|
||||||
layoutOnLoadActions: PageAction[][];
|
layoutOnLoadActions: PageAction[][];
|
||||||
dsl: Partial<ContainerWidgetProps<any>>;
|
dsl: Partial<ContainerWidgetProps<any>>;
|
||||||
|
messages: string[];
|
||||||
|
actionUpdates: Array<{
|
||||||
|
executeOnLoad: boolean;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -339,12 +339,20 @@ const actionsReducer = createReducer(initialState, {
|
||||||
}),
|
}),
|
||||||
[ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD]: (
|
[ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD]: (
|
||||||
state: ActionDataState,
|
state: ActionDataState,
|
||||||
actionIds: ReduxAction<string[]>,
|
action: ReduxAction<
|
||||||
|
Array<{
|
||||||
|
executeOnLoad: boolean;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}>
|
||||||
|
>,
|
||||||
) => {
|
) => {
|
||||||
return produce(state, (draft) => {
|
return produce(state, (draft) => {
|
||||||
|
const actionUpdateSearch = _.keyBy(action.payload, "id");
|
||||||
draft.forEach((action, index) => {
|
draft.forEach((action, index) => {
|
||||||
if (actionIds.payload.indexOf(action.config.id) > -1) {
|
if (action.config.id in actionUpdateSearch) {
|
||||||
draft[index].config.executeOnLoad = true;
|
draft[index].config.executeOnLoad =
|
||||||
|
actionUpdateSearch[action.config.id].executeOnLoad;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,8 @@ import PerformanceTracker, {
|
||||||
PerformanceTransactionName,
|
PerformanceTransactionName,
|
||||||
} from "utils/PerformanceTracker";
|
} from "utils/PerformanceTracker";
|
||||||
import { WidgetTypes } from "constants/WidgetConstants";
|
import { WidgetTypes } from "constants/WidgetConstants";
|
||||||
|
import { Toaster } from "components/ads/Toast";
|
||||||
|
import { Variant } from "components/ads/common";
|
||||||
|
|
||||||
const getWidgetName = (state: AppState, widgetId: string) =>
|
const getWidgetName = (state: AppState, widgetId: string) =>
|
||||||
state.entities.canvasWidgets[widgetId];
|
state.entities.canvasWidgets[widgetId];
|
||||||
|
|
@ -323,13 +325,19 @@ function* savePageSaga() {
|
||||||
);
|
);
|
||||||
const isValidResponse = yield validateResponse(savePageResponse);
|
const isValidResponse = yield validateResponse(savePageResponse);
|
||||||
if (isValidResponse) {
|
if (isValidResponse) {
|
||||||
if (
|
const { messages, actionUpdates } = savePageResponse.data;
|
||||||
savePageResponse.data.layoutOnLoadActions &&
|
// Show toast messages from the server
|
||||||
savePageResponse.data.layoutOnLoadActions.length > 0
|
if (messages && messages.length) {
|
||||||
) {
|
savePageResponse.data.messages.forEach((message) => {
|
||||||
for (const actionSet of savePageResponse.data.layoutOnLoadActions) {
|
Toaster.show({
|
||||||
yield put(setActionsToExecuteOnPageLoad(actionSet.map((a) => a.id)));
|
text: message,
|
||||||
}
|
type: Variant.info,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Update actions
|
||||||
|
if (actionUpdates && actionUpdates.length > 0) {
|
||||||
|
yield put(setActionsToExecuteOnPageLoad(actionUpdates));
|
||||||
}
|
}
|
||||||
yield put(savePageSuccess(savePageResponse));
|
yield put(savePageSuccess(savePageResponse));
|
||||||
PerformanceTracker.stopAsyncTracking(
|
PerformanceTracker.stopAsyncTracking(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user