> Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > One Click Binding - https://github.com/appsmithorg/TestSmith/issues/2390 > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Vemparala Surya Vamsi <vamsi@appsmith.com>
353 lines
7.5 KiB
TypeScript
353 lines
7.5 KiB
TypeScript
import type { ActionResponse, PaginationField } from "api/ActionAPI";
|
|
import type {
|
|
EvaluationReduxAction,
|
|
AnyReduxAction,
|
|
ReduxAction,
|
|
ReduxActionWithoutPayload,
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
|
import type { JSUpdate } from "utils/JSPaneUtils";
|
|
import {
|
|
ReduxActionErrorTypes,
|
|
ReduxActionTypes,
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
|
import type { Action } from "entities/Action";
|
|
import { batchAction } from "actions/batchActions";
|
|
import type { ExecuteErrorPayload } from "constants/AppsmithActionConstants/ActionConstants";
|
|
import type { ModalInfo } from "reducers/uiReducers/modalActionReducer";
|
|
|
|
export const createActionRequest = (payload: Partial<Action>) => {
|
|
return {
|
|
type: ReduxActionTypes.CREATE_ACTION_INIT,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const createActionSuccess = (payload: Action) => {
|
|
return {
|
|
type: ReduxActionTypes.CREATE_ACTION_SUCCESS,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export type FetchActionsPayload = {
|
|
applicationId: string;
|
|
};
|
|
|
|
export const fetchActions = (
|
|
{ applicationId }: { applicationId: string },
|
|
postEvalActions: Array<AnyReduxAction>,
|
|
): EvaluationReduxAction<unknown> => {
|
|
return {
|
|
type: ReduxActionTypes.FETCH_ACTIONS_INIT,
|
|
payload: { applicationId },
|
|
postEvalActions,
|
|
};
|
|
};
|
|
|
|
export const fetchActionsForView = ({
|
|
applicationId,
|
|
}: {
|
|
applicationId: string;
|
|
}): ReduxAction<FetchActionsPayload> => {
|
|
return {
|
|
type: ReduxActionTypes.FETCH_ACTIONS_VIEW_MODE_INIT,
|
|
payload: { applicationId },
|
|
};
|
|
};
|
|
|
|
export const fetchActionsForPage = (
|
|
pageId: string,
|
|
): EvaluationReduxAction<unknown> => {
|
|
return {
|
|
type: ReduxActionTypes.FETCH_ACTIONS_FOR_PAGE_INIT,
|
|
payload: { pageId },
|
|
};
|
|
};
|
|
|
|
export const fetchActionsForPageSuccess = (
|
|
actions: Action[],
|
|
): EvaluationReduxAction<unknown> => {
|
|
return {
|
|
type: ReduxActionTypes.FETCH_ACTIONS_FOR_PAGE_SUCCESS,
|
|
payload: actions,
|
|
};
|
|
};
|
|
|
|
export const fetchActionsForPageError = () => {
|
|
return {
|
|
type: ReduxActionErrorTypes.FETCH_ACTIONS_FOR_PAGE_ERROR,
|
|
};
|
|
};
|
|
|
|
export const runActionViaShortcut = () => {
|
|
return {
|
|
type: ReduxActionTypes.RUN_ACTION_SHORTCUT_REQUEST,
|
|
};
|
|
};
|
|
|
|
export const runAction = (
|
|
id: string,
|
|
paginationField?: PaginationField,
|
|
skipOpeningDebugger = false,
|
|
) => {
|
|
return {
|
|
type: ReduxActionTypes.RUN_ACTION_REQUEST,
|
|
payload: {
|
|
id,
|
|
paginationField,
|
|
skipOpeningDebugger,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const softRefreshActions = () => {
|
|
return {
|
|
type: ReduxActionTypes.PLUGIN_SOFT_REFRESH,
|
|
};
|
|
};
|
|
|
|
export const showActionConfirmationModal = (payload: ModalInfo) => {
|
|
return {
|
|
type: ReduxActionTypes.SHOW_ACTION_MODAL,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const cancelActionConfirmationModal = (payload: string) => {
|
|
return {
|
|
type: ReduxActionTypes.CANCEL_ACTION_MODAL + `_FOR_${payload.trim()}`,
|
|
};
|
|
};
|
|
|
|
export const acceptActionConfirmationModal = (payload: string) => {
|
|
return {
|
|
type: ReduxActionTypes.CONFIRM_ACTION_MODAL + `_FOR_${payload.trim()}`,
|
|
};
|
|
};
|
|
|
|
export const updateAction = (payload: { id: string }) => {
|
|
return batchAction({
|
|
type: ReduxActionTypes.UPDATE_ACTION_INIT,
|
|
payload,
|
|
});
|
|
};
|
|
|
|
export const updateActionSuccess = (payload: { data: Action }) => {
|
|
return {
|
|
type: ReduxActionTypes.UPDATE_ACTION_SUCCESS,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const clearActionResponse = (actionId: string) => {
|
|
return {
|
|
type: ReduxActionTypes.CLEAR_ACTION_RESPONSE,
|
|
payload: {
|
|
actionId,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const deleteAction = (payload: {
|
|
id: string;
|
|
name: string;
|
|
onSuccess?: () => void;
|
|
}) => {
|
|
return {
|
|
type: ReduxActionTypes.DELETE_ACTION_INIT,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const deleteActionSuccess = (payload: { id: string }) => {
|
|
return {
|
|
type: ReduxActionTypes.DELETE_ACTION_SUCCESS,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const moveActionRequest = (payload: {
|
|
id: string;
|
|
destinationPageId: string;
|
|
originalPageId: string;
|
|
name: string;
|
|
}) => {
|
|
return {
|
|
type: ReduxActionTypes.MOVE_ACTION_INIT,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const moveActionSuccess = (payload: Action) => {
|
|
return {
|
|
type: ReduxActionTypes.MOVE_ACTION_SUCCESS,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const moveActionError = (payload: {
|
|
id: string;
|
|
originalPageId: string;
|
|
}) => {
|
|
return {
|
|
type: ReduxActionErrorTypes.MOVE_ACTION_ERROR,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const copyActionRequest = (payload: {
|
|
id: string;
|
|
destinationPageId: string;
|
|
name: string;
|
|
}) => {
|
|
return {
|
|
type: ReduxActionTypes.COPY_ACTION_INIT,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const copyActionSuccess = (payload: Action) => {
|
|
return {
|
|
type: ReduxActionTypes.COPY_ACTION_SUCCESS,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const copyActionError = (payload: {
|
|
id: string;
|
|
destinationPageId: string;
|
|
}) => {
|
|
return {
|
|
type: ReduxActionErrorTypes.COPY_ACTION_ERROR,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const executePluginActionRequest = (payload: { id: string }) => ({
|
|
type: ReduxActionTypes.EXECUTE_PLUGIN_ACTION_REQUEST,
|
|
payload: payload,
|
|
});
|
|
|
|
export const executePluginActionSuccess = (payload: {
|
|
id: string;
|
|
response: ActionResponse;
|
|
isPageLoad?: boolean;
|
|
}) => ({
|
|
type: ReduxActionTypes.EXECUTE_PLUGIN_ACTION_SUCCESS,
|
|
payload: payload,
|
|
});
|
|
|
|
export const setActionResponseDisplayFormat = (
|
|
payload: UpdateActionPropertyActionPayload,
|
|
) => ({
|
|
type: ReduxActionTypes.SET_ACTION_RESPONSE_DISPLAY_FORMAT,
|
|
payload: payload,
|
|
});
|
|
|
|
export const executePluginActionError = (
|
|
executeErrorPayload: ExecuteErrorPayload,
|
|
): ReduxAction<ExecuteErrorPayload> => {
|
|
return {
|
|
type: ReduxActionErrorTypes.EXECUTE_PLUGIN_ACTION_ERROR,
|
|
payload: executeErrorPayload,
|
|
};
|
|
};
|
|
|
|
export const saveActionName = (payload: { id: string; name: string }) => ({
|
|
type: ReduxActionTypes.SAVE_ACTION_NAME_INIT,
|
|
payload: payload,
|
|
});
|
|
|
|
export type SetActionPropertyPayload = {
|
|
actionId: string;
|
|
propertyName: string;
|
|
value: any;
|
|
skipSave?: boolean;
|
|
};
|
|
|
|
export const setActionProperty = (
|
|
payload: SetActionPropertyPayload,
|
|
postEvalActions?: Array<AnyReduxAction>,
|
|
) => ({
|
|
type: ReduxActionTypes.SET_ACTION_PROPERTY,
|
|
payload,
|
|
postEvalActions,
|
|
});
|
|
|
|
export type UpdateActionPropertyActionPayload = {
|
|
id: string;
|
|
field: string;
|
|
value: any;
|
|
};
|
|
|
|
export const updateActionProperty = (
|
|
payload: UpdateActionPropertyActionPayload,
|
|
postEvalActions?: Array<AnyReduxAction>,
|
|
) => {
|
|
return batchAction({
|
|
type: ReduxActionTypes.UPDATE_ACTION_PROPERTY,
|
|
payload,
|
|
postEvalActions,
|
|
});
|
|
};
|
|
|
|
export const executePageLoadActions = (): ReduxActionWithoutPayload => ({
|
|
type: ReduxActionTypes.EXECUTE_PAGE_LOAD_ACTIONS,
|
|
});
|
|
|
|
export const executeJSUpdates = (
|
|
payload: Record<string, JSUpdate>,
|
|
): ReduxAction<unknown> => ({
|
|
type: ReduxActionTypes.EXECUTE_JS_UPDATES,
|
|
payload,
|
|
});
|
|
|
|
export const setActionsToExecuteOnPageLoad = (
|
|
actions: Array<{
|
|
executeOnLoad: boolean;
|
|
id: string;
|
|
name: string;
|
|
}>,
|
|
) => {
|
|
return {
|
|
type: ReduxActionTypes.SET_ACTION_TO_EXECUTE_ON_PAGELOAD,
|
|
payload: actions,
|
|
};
|
|
};
|
|
|
|
export const setJSActionsToExecuteOnPageLoad = (
|
|
actions: Array<{
|
|
executeOnLoad: boolean;
|
|
id: string;
|
|
name: string;
|
|
collectionId?: string;
|
|
}>,
|
|
) => {
|
|
return {
|
|
type: ReduxActionTypes.SET_JS_ACTION_TO_EXECUTE_ON_PAGELOAD,
|
|
payload: actions,
|
|
};
|
|
};
|
|
|
|
export const bindDataOnCanvas = (payload: {
|
|
queryId: string;
|
|
applicationId: string;
|
|
pageId: string;
|
|
}) => {
|
|
return {
|
|
type: ReduxActionTypes.BIND_DATA_ON_CANVAS,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export default {
|
|
createAction: createActionRequest,
|
|
fetchActions,
|
|
runAction: runAction,
|
|
deleteAction,
|
|
deleteActionSuccess,
|
|
updateAction,
|
|
updateActionSuccess,
|
|
bindDataOnCanvas,
|
|
};
|