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 {
|
||||
type: ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD,
|
||||
payload: actions,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ export interface SavePageResponse extends ApiResponse {
|
|||
id: string;
|
||||
layoutOnLoadActions: PageAction[][];
|
||||
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]: (
|
||||
state: ActionDataState,
|
||||
actionIds: ReduxAction<string[]>,
|
||||
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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user