fix: revert success flag from trigger response (#15641)

This commit is contained in:
Bhavin K 2022-08-04 17:30:53 +05:30 committed by GitHub
parent 819d43b5d0
commit 66d3205f4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 23 deletions

View File

@ -49,7 +49,6 @@ import {
} from "sagas/ActionExecution/GetCurrentLocationSaga";
import { requestModalConfirmationSaga } from "sagas/UtilSagas";
import { ModalType } from "reducers/uiReducers/modalActionReducer";
import { get, set, size } from "lodash";
export type TriggerMeta = {
source?: TriggerSource;
@ -68,7 +67,7 @@ export function* executeActionTriggers(
triggerMeta: TriggerMeta,
): any {
// 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) {
case ActionTriggerType.RUN_PLUGIN_ACTION:
response = yield call(
@ -118,8 +117,6 @@ export function* executeActionTriggers(
eventType,
triggerMeta,
);
// response return only one object into array
set(response, "0.success", true);
break;
case ActionTriggerType.WATCH_CURRENT_LOCATION:
@ -129,14 +126,10 @@ export function* executeActionTriggers(
eventType,
triggerMeta,
);
// response return only one object into array
set(response, "0.success", true);
break;
case ActionTriggerType.STOP_WATCHING_CURRENT_LOCATION:
response = yield call(stopWatchCurrentLocation, eventType, triggerMeta);
// response return only one object into array
set(response, "0.success", true);
break;
case ActionTriggerType.CONFIRMATION_MODAL:
const payloadInfo = {
@ -165,6 +158,7 @@ export function* executeAppAction(payload: ExecuteTriggerPayload): any {
source,
triggerPropertyName,
} = payload;
log.debug({ dynamicString, callbackData, globalContext });
if (dynamicString === undefined) {
throw new Error("Executing undefined action");
@ -188,16 +182,9 @@ function* initiateActionTriggerExecution(
// it will be created again while execution
AppsmithConsole.deleteError(`${source?.id}-${triggerPropertyName}`);
try {
const res: unknown[] = yield call(executeAppAction, action.payload);
yield call(executeAppAction, action.payload);
if (event.callback) {
/**
* 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 });
event.callback({ success: true });
}
} catch (e) {
if (e instanceof UncaughtPromiseError || e instanceof TriggerFailureError) {

View File

@ -406,14 +406,9 @@ export default function* executePluginActionTriggerSaga(
callbackData: [payload.body, params],
...triggerMeta,
});
return [{ success: true }];
}
}
// added success flag for successfull api execution and handle callback
return [
set((payload.body || {}) as Record<string, unknown>, "success", true),
params,
];
return [payload.body, params];
}
function* runActionShortcutSaga() {