PromucFlow_constructor/app/client/src/actions/evaluationActions.ts

121 lines
3.9 KiB
TypeScript
Raw Normal View History

2021-07-20 10:02:56 +00:00
import {
ReduxAction,
ReduxActionErrorTypes,
ReduxActionTypes,
} from "constants/ReduxActionConstants";
2021-07-20 10:02:56 +00:00
import _ from "lodash";
import { DataTree } from "entities/DataTree/dataTreeFactory";
import { DependencyMap } from "utils/DynamicBindingUtils";
2021-07-20 10:02:56 +00:00
import { Diff } from "deep-diff";
import { QueryActionConfig } from "../entities/Action";
2021-07-20 10:02:56 +00:00
export const FIRST_EVAL_REDUX_ACTIONS = [
// Pages
ReduxActionTypes.FETCH_PAGE_SUCCESS,
ReduxActionTypes.FETCH_PUBLISHED_PAGE_SUCCESS,
];
export const EVALUATE_REDUX_ACTIONS = [
...FIRST_EVAL_REDUX_ACTIONS,
// Actions
ReduxActionTypes.FETCH_ACTIONS_SUCCESS,
ReduxActionTypes.FETCH_PLUGIN_FORM_CONFIGS_SUCCESS,
ReduxActionTypes.FETCH_ACTIONS_VIEW_MODE_SUCCESS,
ReduxActionErrorTypes.FETCH_ACTIONS_ERROR,
ReduxActionErrorTypes.FETCH_ACTIONS_VIEW_MODE_ERROR,
ReduxActionTypes.FETCH_ACTIONS_FOR_PAGE_SUCCESS,
ReduxActionTypes.SUBMIT_CURL_FORM_SUCCESS,
ReduxActionTypes.CREATE_ACTION_SUCCESS,
ReduxActionTypes.UPDATE_ACTION_PROPERTY,
ReduxActionTypes.DELETE_ACTION_SUCCESS,
ReduxActionTypes.COPY_ACTION_SUCCESS,
ReduxActionTypes.MOVE_ACTION_SUCCESS,
ReduxActionTypes.RUN_ACTION_SUCCESS,
ReduxActionErrorTypes.RUN_ACTION_ERROR,
ReduxActionTypes.EXECUTE_PLUGIN_ACTION_SUCCESS,
ReduxActionErrorTypes.EXECUTE_PLUGIN_ACTION_ERROR,
ReduxActionTypes.CLEAR_ACTION_RESPONSE,
feat: JS Editor (#6003) * Changes to add js plugin * routes+reducer+create template * added debugger to js editor page * entity explorer changes * create js function * added copy, move and delete action * added js plugin * added existing js functions to data tree * removed actionconfig for js collection * new js function added to data tree and entity as well * parsing flow added * changes to data tree * parse and update js functions * small changes for def creator for js action * create delete modified * small changes for update * update flow change * entity properties added * removed linting errors * small changes in entity explorer * changes for update * move, copy implementation * conflict resolved * changes for dependecy map creation * Only make the variables the binding paths * Basic eval sync working * Minor fixes * removed unwanted code * entity props and autocomplete * saving in progress show * redirection fix after delete js action * removed unnecessary line * Fixing merge conflict * added sample body * removed dummy data and added plugin Type * few PR comments fixed * automplete fix * few more PR comments fix * PR commnets fix * move and copy api change * js colleciton name refactor & 'move to page' changes & search * view changes * autocomplete added for js collections * removing till async is implemented * small changes * separate js pane response view * Executing functions * js collection to js objects * entity explorer issue and resolve action on page switch * removed unused line * small color fix * js file icon added * added js action to property pane * Property pane changes for actions * property pane changes for js functions * showing syntax error for now * actions sorted in response tab * added js objects to slash and recent entitties * enabling this to be used inside of function * eval fix * feature flag changes for entity explorer and property pane * debugger changes * copy bug fix * small changes for eval * debugger bug fix * chnaged any to specific types * error in console fix * icons update * fixed test case * test case fix * non empty check for functions * evaluate test case fix * added new icons * text change * updated time for debounce for trial * after release mereg * changed icon * after merge * PR comments simple * fixed PR comments - redux form, settings remove * js object interface changes * name refactor * export default change * delete resolve actions chnage * after merge * adding execute fn as 3rd option and removed create new js function * issue 7054 fixed - app crash * execute function on response tab changes * refactor function name part 1 * refactor of js function name * try catch added refactor * test fix * not used line removed * test cases locator fixed Co-authored-by: Nidhi <nidhi.nair93@gmail.com> Co-authored-by: hetunandu <hetu@appsmith.com>
2021-09-08 17:32:22 +00:00
// JS Actions
ReduxActionTypes.FETCH_JS_ACTIONS_SUCCESS,
ReduxActionTypes.CREATE_JS_ACTION_SUCCESS,
ReduxActionErrorTypes.FETCH_JS_ACTIONS_ERROR,
ReduxActionTypes.DELETE_JS_ACTION_SUCCESS,
ReduxActionTypes.COPY_JS_ACTION_SUCCESS,
ReduxActionTypes.MOVE_JS_ACTION_SUCCESS,
ReduxActionErrorTypes.FETCH_JS_ACTIONS_ERROR,
ReduxActionTypes.FETCH_JS_ACTIONS_FOR_PAGE_SUCCESS,
ReduxActionTypes.FETCH_JS_ACTIONS_VIEW_MODE_SUCCESS,
ReduxActionErrorTypes.FETCH_JS_ACTIONS_VIEW_MODE_ERROR,
ReduxActionTypes.UPDATE_JS_ACTION_BODY_SUCCESS,
2021-07-20 10:02:56 +00:00
// App Data
ReduxActionTypes.SET_APP_MODE,
ReduxActionTypes.FETCH_USER_DETAILS_SUCCESS,
ReduxActionTypes.UPDATE_APP_PERSISTENT_STORE,
ReduxActionTypes.UPDATE_APP_TRANSIENT_STORE,
ReduxActionTypes.SET_USER_CURRENT_GEO_LOCATION,
2021-07-20 10:02:56 +00:00
// Widgets
ReduxActionTypes.UPDATE_LAYOUT,
ReduxActionTypes.UPDATE_WIDGET_PROPERTY,
ReduxActionTypes.UPDATE_WIDGET_NAME_SUCCESS,
// Widget Meta
ReduxActionTypes.SET_META_PROP,
ReduxActionTypes.RESET_WIDGET_META,
// Batches
ReduxActionTypes.BATCH_UPDATES_SUCCESS,
];
export const shouldProcessBatchedAction = (action: ReduxAction<unknown>) => {
if (
action.type === ReduxActionTypes.BATCH_UPDATES_SUCCESS &&
Array.isArray(action.payload)
) {
const batchedActionTypes = action.payload.map(
(batchedAction) => batchedAction.type,
);
return (
_.intersection(EVALUATE_REDUX_ACTIONS, batchedActionTypes).length > 0
);
}
return true;
};
export const setEvaluatedTree = (
dataTree: DataTree,
updates: Diff<DataTree, DataTree>[],
): ReduxAction<{ dataTree: DataTree; updates: Diff<DataTree, DataTree>[] }> => {
return {
type: ReduxActionTypes.SET_EVALUATED_TREE,
payload: { dataTree, updates },
};
};
export const setDependencyMap = (
inverseDependencyMap: DependencyMap,
): ReduxAction<{ inverseDependencyMap: DependencyMap }> => {
return {
type: ReduxActionTypes.SET_EVALUATION_INVERSE_DEPENDENCY_MAP,
payload: { inverseDependencyMap },
};
};
// Called when a form is being setup, for setting up the base condition evaluations for the form
export const initFormEvaluations = (
editorConfig: any,
settingConfig: any,
formId: string,
) => {
return {
type: ReduxActionTypes.INIT_FORM_EVALUATION,
payload: { editorConfig, settingConfig, formId },
};
};
// Called when there is change in the data of the form, re evaluates the whole form
export const startFormEvaluations = (
formId: string,
formData: QueryActionConfig,
) => {
return {
type: ReduxActionTypes.RUN_FORM_EVALUATION,
payload: { formId, actionConfiguration: formData },
};
};