PromucFlow_constructor/app/client/src/entities/DataTree/dataTreeAction.ts
Ankita Kinger 1012c43ee7
chore: Splitting entities reducer for supporting more reducers on EE (#27560)
## Description

Splitting entities reducer for supporting more reducers on EE

#### PR fixes following issue(s)
Fixes [#27559](https://github.com/appsmithorg/appsmith/issues/27559)

#### Type of change
- Chore (housekeeping or task changes that don't impact user perception)

## Testing

#### How Has This Been Tested?
- [x] Manual
- [ ] JUnit
- [ ] Jest
- [x] Cypress

## 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
- [ ] 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/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#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
2023-09-22 18:12:20 +05:30

82 lines
2.3 KiB
TypeScript

import type { DependencyMap, DynamicPath } from "utils/DynamicBindingUtils";
import { ENTITY_TYPE } from "entities/DataTree/dataTreeFactory";
import type { ActionData } from "@appsmith/reducers/entityReducers/actionsReducer";
import {
getBindingAndReactivePathsOfAction,
getDataTreeActionConfigPath,
} from "entities/Action/actionProperties";
import type { ActionEntity, ActionEntityConfig } from "./types";
export const generateDataTreeAction = (
action: ActionData,
editorConfig: any[],
dependencyConfig: DependencyMap = {},
): {
unEvalEntity: ActionEntity;
configEntity: ActionEntityConfig;
} => {
let dynamicBindingPathList: DynamicPath[] = [];
let datasourceUrl = "";
// update paths
if (
action.config.dynamicBindingPathList &&
action.config.dynamicBindingPathList.length
) {
dynamicBindingPathList = action.config.dynamicBindingPathList.map((d) => ({
...d,
key: d.key === "datasourceUrl" ? d.key : `config.${d.key}`,
}));
}
if (
action.config.datasource &&
"datasourceConfiguration" in action.config.datasource
) {
datasourceUrl = action.config.datasource.datasourceConfiguration?.url ?? "";
}
const dependencyMap: DependencyMap = {};
Object.entries(dependencyConfig).forEach(([dependent, dependencies]) => {
dependencyMap[getDataTreeActionConfigPath(dependent)] = dependencies.map(
getDataTreeActionConfigPath,
);
});
const { bindingPaths, reactivePaths } = getBindingAndReactivePathsOfAction(
action.config,
editorConfig,
dynamicBindingPathList,
);
return {
unEvalEntity: {
actionId: action.config.id,
run: {},
clear: {},
data: action.data ? action.data.body : undefined,
isLoading: action.isLoading,
responseMeta: {
statusCode: action.data?.statusCode,
isExecutionSuccess: action.data?.isExecutionSuccess || false,
headers: action.data?.headers,
},
config: action.config.actionConfiguration,
ENTITY_TYPE: ENTITY_TYPE.ACTION,
datasourceUrl,
},
configEntity: {
actionId: action.config.id,
name: action.config.name,
pluginId: action.config.pluginId,
pluginType: action.config.pluginType,
dynamicBindingPathList,
ENTITY_TYPE: ENTITY_TYPE.ACTION,
bindingPaths,
reactivePaths,
dependencyMap,
logBlackList: {},
},
};
};