fix: show loading state in JS Editor (#12820)

This commit is contained in:
Favour Ohanekwu 2022-04-12 23:17:56 -07:00 committed by GitHub
parent f973c2d86d
commit b102d32761
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -54,7 +54,7 @@ export const refactorJSCollectionAction = (payload: {
};
};
export const executeJSFunction = (payload: {
export const executeJSFunctionInit = (payload: {
collectionName: string;
action: JSAction;
collectionId: string;

View File

@ -1,5 +1,5 @@
import { createReducer } from "utils/AppsmithUtils";
import { JSCollection } from "entities/JSCollection";
import { JSAction, JSCollection } from "entities/JSCollection";
import {
ReduxActionTypes,
ReduxAction,
@ -247,9 +247,9 @@ const jsActionsReducer = createReducer(initialState, {
[ReduxActionTypes.EXECUTE_JS_FUNCTION_INIT]: (
state: JSCollectionDataState,
action: ReduxAction<{
results: any;
collectionName: string;
collectionId: string;
actionId: string;
action: JSAction;
}>,
): JSCollectionDataState =>
state.map((a) => {
@ -258,7 +258,7 @@ const jsActionsReducer = createReducer(initialState, {
...a,
isExecuting: {
...a.isExecuting,
[action.payload.actionId]: true,
[action.payload.action.id]: true,
},
};
}

View File

@ -41,6 +41,7 @@ import {
refactorJSCollectionAction,
updateJSCollectionBodySuccess,
updateJSFunction,
executeJSFunctionInit,
} from "actions/jsPaneActions";
import { getCurrentOrgId } from "selectors/organizationSelectors";
import { getPluginIdOfPackageName } from "sagas/selectors";
@ -303,6 +304,13 @@ export function* handleExecuteJSFunctionSaga(data: {
}): any {
const { action, collectionId, collectionName } = data;
const actionId = action.id;
yield put(
executeJSFunctionInit({
collectionName,
action,
collectionId,
}),
);
try {
const result = yield call(executeFunction, collectionName, action);
yield put({