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; collectionName: string;
action: JSAction; action: JSAction;
collectionId: string; collectionId: string;

View File

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

View File

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