Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create a async execute trigger flow #39009

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ export function* executeActionTriggers(
return response;
}

// This function gets called when a user clicks on a button on the canvas UI
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function* executeAppAction(payload: ExecuteTriggerPayload): any {
export function* executeAppAction(payload: ExecuteTriggerPayload): Generator {
const {
callbackData,
dynamicString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface TriggerSource {
isJSAction?: boolean;
actionId?: string;
}

export enum TriggerKind {
EVENT_EXECUTION = "EVENT_EXECUTION", // Eg. Button onClick
JS_FUNCTION_EXECUTION = "JS_FUNCTION_EXECUTION", // Executing js function from jsObject page
Expand All @@ -34,9 +35,7 @@ export enum TriggerKind {
export interface ExecuteTriggerPayload {
dynamicString: string;
event: ExecuteActionPayloadEvent;
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
callbackData?: Array<any>;
callbackData?: Array<unknown>;
triggerPropertyName?: string;
source?: TriggerSource;
widgetId?: string;
Expand Down
5 changes: 2 additions & 3 deletions app/client/src/sagas/EvaluationsSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,7 @@ export function* evaluateAndExecuteDynamicTrigger(
dynamicTrigger: string,
eventType: EventType,
triggerMeta: TriggerMeta,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
callbackData?: Array<any>,
callbackData?: Array<unknown>,
globalContext?: Record<string, unknown>,
) {
const rootSpan = startRootSpan("DataTreeFactory.create");
Expand Down Expand Up @@ -889,6 +887,7 @@ export function* evaluationLoopWithDebounce(
}
}
}

// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function* evaluateActionSelectorFieldSaga(action: any) {
Expand Down
1 change: 1 addition & 0 deletions app/client/src/utils/WorkerUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export class GracefulWorkerService {
completeWebworkerComputationRoot?.setAttribute("taskType", method);
completeWebworkerComputationRoot?.end(endTime);
}

/**
* Send a request to the worker for processing.
* If the worker isn't ready, we wait for it to become ready.
Expand Down
27 changes: 27 additions & 0 deletions app/client/src/workers/Evaluation/asyncWorkerActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import store from "store";
import { getUnevaluatedDataTree } from "selectors/dataTreeSelectors";
import { evalWorker } from "utils/workerInstances";
import { EVAL_WORKER_ACTIONS } from "ee/workers/Evaluation/evalWorkerActions";
import { runSaga } from "redux-saga";
import { TriggerKind } from "constants/AppsmithActionConstants/ActionConstants";

export async function UNSTABLE_executeDynamicTrigger(dynamicTrigger: string) {
const state = store.getState();
const unEvalTree = getUnevaluatedDataTree(state);

const result = runSaga(
{},
evalWorker.request,
EVAL_WORKER_ACTIONS.EVAL_TRIGGER,
{
unEvalTree,
dynamicTrigger,
triggerMeta: {
onPageLoad: false,
triggerKind: TriggerKind.EVENT_EXECUTION,
},
},
);

return result.toPromise();
}
Loading