chore: split for module instance evaluation on ee (#29027)

## Description
Module instance evaluation required split to be extended on EE

#### 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
- [ ] Manual
- [ ] JUnit
- [ ] Jest
- [ ] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
>
>
#### 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
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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
This commit is contained in:
Apeksha Bhosale 2023-11-22 15:02:44 +05:30 committed by GitHub
parent a8380a0f76
commit 6e39d11b14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 104 additions and 8 deletions

View File

@ -1,5 +1,11 @@
type ID = string;
export enum MODULE_TYPE {
QUERY = "QUERY_MODULE",
JS = "JS",
UI = "UI",
}
export interface ModuleInput {
id: string;
propertyName: string;

View File

@ -0,0 +1,23 @@
import type { MODULE_TYPE } from "@appsmith/constants/ModuleConstants";
export type ModuleId = string;
export type ModuleInstanceId = string;
export enum ModuleInstanceCreatorType {
MODULE = "MODULE",
PAGE = "PAGE",
}
export interface ModuleInstance {
id: ModuleInstanceId;
type: MODULE_TYPE;
moduleId: ModuleId;
name: string;
creatorId: string;
creatorType: ModuleInstanceCreatorType;
inputs: {
[key: string]: string;
};
jsonPathKeys: {
[key: string]: any;
};
}

View File

@ -1,5 +1,5 @@
import { PluginType } from "entities/Action";
import { generateDataTreeJSAction } from "entities/DataTree/dataTreeJSAction";
import { generateDataTreeJSAction } from "./dataTreeJSAction";
import type { JSCollectionData } from "reducers/entityReducers/jsActionsReducer";
describe("generateDataTreeJSAction", () => {

View File

@ -0,0 +1,13 @@
import type { ModuleInstance } from "@appsmith/constants/ModuleInstanceConstants";
export const generateModuleInstance = (
// eslint-disable-next-line @typescript-eslint/no-unused-vars
moduleInstance: ModuleInstance,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
moduleInstanceEntities: any,
) => {
return {
configEntity: null,
unEvalEntity: null,
};
};

View File

@ -18,6 +18,7 @@ import type { AppTheme } from "entities/AppTheming";
import type { LoadingEntitiesState } from "reducers/evaluationReducers/loadingEntitiesReducer";
import type { LayoutSystemTypes } from "layoutSystems/types";
import type { Module } from "@appsmith/constants/ModuleConstants";
import type { ModuleInstance } from "@appsmith/constants/ModuleInstanceConstants";
export type ActionDispatcher = (...args: any[]) => ActionDescription;
@ -64,6 +65,9 @@ export interface ActionEntityConfig extends EntityConfig {
pluginId: PluginId;
actionId: string;
name: string;
moduleId?: string;
moduleInstanceId?: string;
isPublic?: boolean;
}
// JSAction (JSObject) entity Types
@ -188,6 +192,8 @@ export interface DataTreeSeed {
metaWidgets: MetaWidgetsReduxState;
isMobile: boolean;
moduleInputs: Module["inputsForm"];
moduleInstances: Record<string, ModuleInstance>;
moduleInstanceEntities: any;
layoutSystemType: LayoutSystemTypes;
loadingEntities: LoadingEntitiesState;
}

View File

@ -46,6 +46,7 @@ import { getFormValues } from "redux-form";
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
import { MAX_DATASOURCE_SUGGESTIONS } from "pages/Editor/Explorer/hooks";
import type { Module } from "@appsmith/constants/ModuleConstants";
import type { ModuleInstance } from "@appsmith/constants/ModuleInstanceConstants";
import type { Plugin } from "api/PluginApi";
export const getEntities = (state: AppState): AppState["entities"] =>
@ -1313,3 +1314,14 @@ export const getEntityExplorerDatasources = (state: AppState): Datasource[] => {
export function getInputsForModule(): Module["inputsForm"] {
return [];
}
export const getModuleInstances = (): Record<string, ModuleInstance> => {
return {};
};
export const getModuleInstanceEntities = () => {
return {
actions: [],
jsCollections: [],
};
};

View File

@ -972,7 +972,7 @@ export const isAPathDynamicBindingPath = (
propertyPath: string,
) => {
return (
(isAction(entity) || isWidget(entity) || isJSAction(entity)) &&
isWidgetActionOrJsObject(entity) &&
isPathADynamicBinding(entityConfig, propertyPath)
);
};

View File

@ -0,0 +1 @@
export * from "ce/constants/ModuleInstanceConstants";

View File

@ -0,0 +1 @@
export * from "ce/entities/DataTree/dataTreeAction";

View File

@ -0,0 +1 @@
export * from "ce/entities/DataTree/dataTreeJSAction.test";

View File

@ -0,0 +1 @@
export * from "ce/entities/DataTree/dataTreeJSAction";

View File

@ -0,0 +1 @@
export * from "ce/entities/DataTree/dataTreeModuleInstance";

View File

@ -159,6 +159,7 @@ export interface BaseAction {
errorReports?: Array<LayoutOnLoadActionErrors>;
isPublic?: boolean;
moduleId?: string;
moduleInstanceId?: string;
}
interface BaseApiAction extends BaseAction {

View File

@ -1,5 +1,5 @@
import { generateDataTreeAction } from "entities/DataTree/dataTreeAction";
import { generateDataTreeJSAction } from "entities/DataTree/dataTreeJSAction";
import { generateDataTreeAction } from "@appsmith/entities/DataTree/dataTreeAction";
import { generateDataTreeJSAction } from "@appsmith/entities/DataTree/dataTreeJSAction";
import { generateDataTreeWidget } from "entities/DataTree/dataTreeWidget";
import log from "loglevel";
import {
@ -18,7 +18,7 @@ import type {
UnEvalTree,
} from "entities/DataTree/dataTreeTypes";
import { isEmpty } from "lodash";
import { generateModuleInstance } from "@appsmith/entities/DataTree/dataTreeModuleInstance";
export class DataTreeFactory {
static create({
actions,
@ -30,6 +30,8 @@ export class DataTreeFactory {
loadingEntities,
metaWidgets,
moduleInputs,
moduleInstanceEntities,
moduleInstances,
pluginDependencyConfig,
theme,
widgets,
@ -73,6 +75,19 @@ export class DataTreeFactory {
}
}
if (!isEmpty(moduleInstances)) {
Object.values(moduleInstances).forEach((moduleInstance) => {
const { configEntity, unEvalEntity } = generateModuleInstance(
moduleInstance,
moduleInstanceEntities,
);
if (!!configEntity && !!unEvalEntity) {
dataTree[moduleInstance.name] = unEvalEntity;
configTree[moduleInstance.name] = configEntity;
}
});
}
Object.values(widgets).forEach((widget) => {
const { configEntity, unEvalEntity } = generateDataTreeWidget(
widget,

View File

@ -6,6 +6,8 @@ import {
getPluginEditorConfigs,
getCurrentJSCollections,
getInputsForModule,
getModuleInstances,
getModuleInstanceEntities,
} from "@appsmith/selectors/entitiesSelector";
import type { WidgetEntity } from "@appsmith/entities/DataTree/types";
import type { DataTree } from "entities/DataTree/dataTreeTypes";
@ -58,6 +60,19 @@ const getCurrentActionEntities = createSelector(
},
);
const getModulesData = createSelector(
getInputsForModule,
getModuleInstances,
getModuleInstanceEntities,
(moduleInputs, moduleInstances, moduleInstanceEntities) => {
return {
moduleInputs: moduleInputs,
moduleInstances: moduleInstances,
moduleInstanceEntities: moduleInstanceEntities,
};
},
);
export const getUnevaluatedDataTree = createSelector(
getCurrentActionEntities,
getWidgetsForEval,
@ -68,9 +83,9 @@ export const getUnevaluatedDataTree = createSelector(
getPluginDependencyConfig,
getSelectedAppThemeProperties,
getMetaWidgets,
getInputsForModule,
getLayoutSystemPayload,
getLoadingEntities,
getModulesData,
(
currentActionEntities,
widgets,
@ -81,9 +96,9 @@ export const getUnevaluatedDataTree = createSelector(
pluginDependencyConfig,
selectedAppThemeProperty,
metaWidgets,
moduleInputs,
layoutSystemPayload,
loadingEntities,
modulesData,
) => {
const pageList = pageListPayload || [];
return DataTreeFactory.create({
@ -96,9 +111,9 @@ export const getUnevaluatedDataTree = createSelector(
pluginDependencyConfig,
theme: selectedAppThemeProperty,
metaWidgets,
moduleInputs,
loadingEntities,
...layoutSystemPayload,
...modulesData,
});
},
);