2022-04-12 10:50:01 +00:00
|
|
|
import {
|
|
|
|
|
ReduxAction,
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2021-09-08 17:32:22 +00:00
|
|
|
import { JSCollection, JSAction } from "entities/JSCollection";
|
2022-03-17 12:05:17 +00:00
|
|
|
import { RefactorAction, SetFunctionPropertyPayload } from "api/JSActionAPI";
|
2022-04-28 16:51:02 +00:00
|
|
|
|
2021-09-08 17:32:22 +00:00
|
|
|
export const createNewJSCollection = (
|
|
|
|
|
pageId: string,
|
|
|
|
|
): ReduxAction<{ pageId: string }> => ({
|
|
|
|
|
type: ReduxActionTypes.CREATE_NEW_JS_ACTION,
|
|
|
|
|
payload: { pageId },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const updateJSCollection = (
|
|
|
|
|
body: string,
|
|
|
|
|
id: string,
|
|
|
|
|
): ReduxAction<{ body: string; id: string }> => ({
|
|
|
|
|
type: ReduxActionTypes.UPDATE_JS_ACTION_INIT,
|
|
|
|
|
payload: { body, id },
|
|
|
|
|
});
|
|
|
|
|
|
2021-11-08 06:49:22 +00:00
|
|
|
export const updateJSCollectionBody = (
|
|
|
|
|
body: string,
|
|
|
|
|
id: string,
|
2021-12-07 09:45:18 +00:00
|
|
|
isReplay = false,
|
|
|
|
|
): ReduxAction<{ body: string; id: string; isReplay?: boolean }> => ({
|
2021-11-08 06:49:22 +00:00
|
|
|
type: ReduxActionTypes.UPDATE_JS_ACTION_BODY_INIT,
|
2021-12-07 09:45:18 +00:00
|
|
|
payload: { body, id, isReplay },
|
2021-11-08 06:49:22 +00:00
|
|
|
});
|
|
|
|
|
|
2021-09-08 17:32:22 +00:00
|
|
|
export const updateJSCollectionSuccess = (payload: { data: JSCollection }) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.UPDATE_JS_ACTION_SUCCESS,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-08 06:49:22 +00:00
|
|
|
export const updateJSCollectionBodySuccess = (payload: {
|
|
|
|
|
data: JSCollection;
|
|
|
|
|
}) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.UPDATE_JS_ACTION_BODY_SUCCESS,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-08 17:32:22 +00:00
|
|
|
export const refactorJSCollectionAction = (payload: {
|
2021-10-19 11:53:15 +00:00
|
|
|
refactorAction: RefactorAction;
|
|
|
|
|
actionCollection: JSCollection;
|
2021-09-08 17:32:22 +00:00
|
|
|
}) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.REFACTOR_JS_ACTION_NAME,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-04-13 06:17:56 +00:00
|
|
|
export const executeJSFunctionInit = (payload: {
|
2021-09-08 17:32:22 +00:00
|
|
|
collectionName: string;
|
|
|
|
|
action: JSAction;
|
2021-09-28 07:31:46 +00:00
|
|
|
collectionId: string;
|
2021-09-08 17:32:22 +00:00
|
|
|
}) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.EXECUTE_JS_FUNCTION_INIT,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-03-17 12:05:17 +00:00
|
|
|
|
2022-04-06 07:22:18 +00:00
|
|
|
export const startExecutingJSFunction = (payload: {
|
|
|
|
|
collectionName: string;
|
|
|
|
|
action: JSAction;
|
|
|
|
|
collectionId: string;
|
|
|
|
|
}) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.START_EXECUTE_JS_FUNCTION,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-03-17 12:05:17 +00:00
|
|
|
export const updateFunctionProperty = (payload: SetFunctionPropertyPayload) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SET_FUNCTION_PROPERTY,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const updateJSFunction = (payload: SetFunctionPropertyPayload) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.UPDATE_JS_FUNCTION_PROPERTY_INIT,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-04-28 16:51:02 +00:00
|
|
|
|
|
|
|
|
export const setActiveJSAction = (payload: {
|
|
|
|
|
jsCollectionId: string;
|
|
|
|
|
jsActionId: string;
|
|
|
|
|
}) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SET_ACTIVE_JS_ACTION,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|