fix: revert success flag from trigger response (#15641)
This commit is contained in:
parent
819d43b5d0
commit
66d3205f4f
|
|
@ -49,7 +49,6 @@ import {
|
||||||
} from "sagas/ActionExecution/GetCurrentLocationSaga";
|
} from "sagas/ActionExecution/GetCurrentLocationSaga";
|
||||||
import { requestModalConfirmationSaga } from "sagas/UtilSagas";
|
import { requestModalConfirmationSaga } from "sagas/UtilSagas";
|
||||||
import { ModalType } from "reducers/uiReducers/modalActionReducer";
|
import { ModalType } from "reducers/uiReducers/modalActionReducer";
|
||||||
import { get, set, size } from "lodash";
|
|
||||||
|
|
||||||
export type TriggerMeta = {
|
export type TriggerMeta = {
|
||||||
source?: TriggerSource;
|
source?: TriggerSource;
|
||||||
|
|
@ -68,7 +67,7 @@ export function* executeActionTriggers(
|
||||||
triggerMeta: TriggerMeta,
|
triggerMeta: TriggerMeta,
|
||||||
): any {
|
): any {
|
||||||
// when called via a promise, a trigger can return some value to be used in .then
|
// when called via a promise, a trigger can return some value to be used in .then
|
||||||
let response: unknown[] = [{ success: true }];
|
let response: unknown[] = [];
|
||||||
switch (trigger.type) {
|
switch (trigger.type) {
|
||||||
case ActionTriggerType.RUN_PLUGIN_ACTION:
|
case ActionTriggerType.RUN_PLUGIN_ACTION:
|
||||||
response = yield call(
|
response = yield call(
|
||||||
|
|
@ -118,8 +117,6 @@ export function* executeActionTriggers(
|
||||||
eventType,
|
eventType,
|
||||||
triggerMeta,
|
triggerMeta,
|
||||||
);
|
);
|
||||||
// response return only one object into array
|
|
||||||
set(response, "0.success", true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ActionTriggerType.WATCH_CURRENT_LOCATION:
|
case ActionTriggerType.WATCH_CURRENT_LOCATION:
|
||||||
|
|
@ -129,14 +126,10 @@ export function* executeActionTriggers(
|
||||||
eventType,
|
eventType,
|
||||||
triggerMeta,
|
triggerMeta,
|
||||||
);
|
);
|
||||||
// response return only one object into array
|
|
||||||
set(response, "0.success", true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ActionTriggerType.STOP_WATCHING_CURRENT_LOCATION:
|
case ActionTriggerType.STOP_WATCHING_CURRENT_LOCATION:
|
||||||
response = yield call(stopWatchCurrentLocation, eventType, triggerMeta);
|
response = yield call(stopWatchCurrentLocation, eventType, triggerMeta);
|
||||||
// response return only one object into array
|
|
||||||
set(response, "0.success", true);
|
|
||||||
break;
|
break;
|
||||||
case ActionTriggerType.CONFIRMATION_MODAL:
|
case ActionTriggerType.CONFIRMATION_MODAL:
|
||||||
const payloadInfo = {
|
const payloadInfo = {
|
||||||
|
|
@ -165,6 +158,7 @@ export function* executeAppAction(payload: ExecuteTriggerPayload): any {
|
||||||
source,
|
source,
|
||||||
triggerPropertyName,
|
triggerPropertyName,
|
||||||
} = payload;
|
} = payload;
|
||||||
|
|
||||||
log.debug({ dynamicString, callbackData, globalContext });
|
log.debug({ dynamicString, callbackData, globalContext });
|
||||||
if (dynamicString === undefined) {
|
if (dynamicString === undefined) {
|
||||||
throw new Error("Executing undefined action");
|
throw new Error("Executing undefined action");
|
||||||
|
|
@ -188,16 +182,9 @@ function* initiateActionTriggerExecution(
|
||||||
// it will be created again while execution
|
// it will be created again while execution
|
||||||
AppsmithConsole.deleteError(`${source?.id}-${triggerPropertyName}`);
|
AppsmithConsole.deleteError(`${source?.id}-${triggerPropertyName}`);
|
||||||
try {
|
try {
|
||||||
const res: unknown[] = yield call(executeAppAction, action.payload);
|
yield call(executeAppAction, action.payload);
|
||||||
if (event.callback) {
|
if (event.callback) {
|
||||||
/**
|
event.callback({ success: true });
|
||||||
* result.success flag added to fire notification after successfully trigger
|
|
||||||
* size of triggers checked for dependent action trigger i.e call success message after getting current location
|
|
||||||
*/
|
|
||||||
const success = !!(
|
|
||||||
get(res, "result.success") || size(get(res, "triggers"))
|
|
||||||
);
|
|
||||||
event.callback({ success });
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof UncaughtPromiseError || e instanceof TriggerFailureError) {
|
if (e instanceof UncaughtPromiseError || e instanceof TriggerFailureError) {
|
||||||
|
|
|
||||||
|
|
@ -406,14 +406,9 @@ export default function* executePluginActionTriggerSaga(
|
||||||
callbackData: [payload.body, params],
|
callbackData: [payload.body, params],
|
||||||
...triggerMeta,
|
...triggerMeta,
|
||||||
});
|
});
|
||||||
return [{ success: true }];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// added success flag for successfull api execution and handle callback
|
return [payload.body, params];
|
||||||
return [
|
|
||||||
set((payload.body || {}) as Record<string, unknown>, "success", true),
|
|
||||||
params,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function* runActionShortcutSaga() {
|
function* runActionShortcutSaga() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user