diff --git a/app/client/src/entities/DataTree/dataTreeFactory.ts b/app/client/src/entities/DataTree/dataTreeFactory.ts index a285558e100..26a4fe16f99 100644 --- a/app/client/src/entities/DataTree/dataTreeFactory.ts +++ b/app/client/src/entities/DataTree/dataTreeFactory.ts @@ -39,11 +39,6 @@ export enum EvaluationSubstitutionType { SMART_SUBSTITUTE = "SMART_SUBSTITUTE", } -// Private widgets do not get evaluated -// For example, for widget Button1 in a List widget List1, List1.template.Button1.text gets evaluated, -// so there is no need to evaluate Button1.text -export type PrivateWidgets = Record; - export interface DataTreeAction extends Omit { data: ActionResponse["body"]; @@ -86,7 +81,6 @@ export interface DataTreeWidget extends WidgetProps { validationPaths: Record; ENTITY_TYPE: ENTITY_TYPE.WIDGET; logBlackList: Record; - privateWidgets: PrivateWidgets; } export interface DataTreeAppsmith extends Omit { diff --git a/app/client/src/entities/DataTree/dataTreeWidget.test.ts b/app/client/src/entities/DataTree/dataTreeWidget.test.ts index 09227e1a5a4..48ccaf1d76b 100644 --- a/app/client/src/entities/DataTree/dataTreeWidget.test.ts +++ b/app/client/src/entities/DataTree/dataTreeWidget.test.ts @@ -251,7 +251,6 @@ describe("generateDataTreeWidget", () => { defaultProps: { text: "defaultText", }, - privateWidgets: {}, }; const result = generateDataTreeWidget(widget, widgetMetaProps); diff --git a/app/client/src/entities/DataTree/dataTreeWidget.ts b/app/client/src/entities/DataTree/dataTreeWidget.ts index 281ac540820..2243f642bff 100644 --- a/app/client/src/entities/DataTree/dataTreeWidget.ts +++ b/app/client/src/entities/DataTree/dataTreeWidget.ts @@ -78,8 +78,5 @@ export const generateDataTreeWidget = ( triggerPaths, validationPaths, ENTITY_TYPE: ENTITY_TYPE.WIDGET, - privateWidgets: { - ...widget.privateWidgets, - }, }; }; diff --git a/app/client/src/sagas/PostEvaluationSagas.ts b/app/client/src/sagas/PostEvaluationSagas.ts index de7af2a0e7b..c089e82c95d 100644 --- a/app/client/src/sagas/PostEvaluationSagas.ts +++ b/app/client/src/sagas/PostEvaluationSagas.ts @@ -3,7 +3,6 @@ import { DataTree } from "entities/DataTree/dataTreeFactory"; import { DataTreeDiff, DataTreeDiffEvent, - getDataTreeWithoutPrivateWidgets, getEntityNameAndPropertyPath, isAction, isJSAction, @@ -368,13 +367,7 @@ export function* updateTernDefinitions( } if (shouldUpdate) { const start = performance.now(); - // remove private widgets from dataTree used for autocompletion - const treeWithoutPrivateWidgets = getDataTreeWithoutPrivateWidgets( - dataTree, - ); - const { def, entityInfo } = dataTreeTypeDefCreator( - treeWithoutPrivateWidgets, - ); + const { def, entityInfo } = dataTreeTypeDefCreator(dataTree); TernServer.updateDef("DATA_TREE", def, entityInfo); const end = performance.now(); log.debug("Tern", { updates }); diff --git a/app/client/src/selectors/editorSelectors.tsx b/app/client/src/selectors/editorSelectors.tsx index a4818e87880..1af5c91cd52 100644 --- a/app/client/src/selectors/editorSelectors.tsx +++ b/app/client/src/selectors/editorSelectors.tsx @@ -402,7 +402,6 @@ const createLoadingWidget = ( validationPaths: {}, logBlackList: {}, isLoading: true, - privateWidgets: {}, }; }; diff --git a/app/client/src/utils/DSLMigrations.ts b/app/client/src/utils/DSLMigrations.ts index 7663bcc1939..3ad9afd22b0 100644 --- a/app/client/src/utils/DSLMigrations.ts +++ b/app/client/src/utils/DSLMigrations.ts @@ -45,7 +45,6 @@ import { migrateCheckboxGroupWidgetInlineProperty } from "./migrations/CheckboxG import { migrateMapWidgetIsClickedMarkerCentered } from "./migrations/MapWidget"; import { DSLWidget } from "widgets/constants"; import { migrateRecaptchaType } from "./migrations/ButtonWidgetMigrations"; -import { PrivateWidgets } from "entities/DataTree/dataTreeFactory"; /** * adds logBlackList key for all list widget children @@ -91,12 +90,12 @@ const addLogBlackListToAllListWidgetChildren = ( * @param currentDSL * @returns */ -const addPrivateWidgetsToAllListWidgets = ( +export const addPrivateWidgetsToAllListWidgets = ( currentDSL: ContainerWidgetProps, ) => { currentDSL.children = currentDSL.children?.map((child: WidgetProps) => { if (child.type === "LIST_WIDGET") { - const privateWidgets: PrivateWidgets = {}; + const privateWidgets: Record = {}; Object.keys(child.template).forEach((entityName) => { privateWidgets[entityName] = true; }); diff --git a/app/client/src/utils/DSLMigrationsUtils.test.ts b/app/client/src/utils/DSLMigrationsUtils.test.ts index ec9df808f02..d3b25fbffe6 100644 --- a/app/client/src/utils/DSLMigrationsUtils.test.ts +++ b/app/client/src/utils/DSLMigrationsUtils.test.ts @@ -1,12 +1,11 @@ -import { transformDSL } from "./DSLMigrations"; -import { LATEST_PAGE_VERSION, RenderModes } from "constants/WidgetConstants"; +import { addPrivateWidgetsToAllListWidgets } from "./DSLMigrations"; +import { RenderModes } from "constants/WidgetConstants"; import { ContainerWidgetProps } from "widgets/ContainerWidget/widget"; import { WidgetProps } from "widgets/BaseWidget"; describe("correctly migrate dsl", () => { it("AddsPrivateWidgetsToAllListWidgets", () => { const currentVersion = 49; - const nextVersion = LATEST_PAGE_VERSION; const currentDSL: ContainerWidgetProps = { backgroundColor: "none", bottomRow: 740, @@ -586,7 +585,7 @@ describe("correctly migrate dsl", () => { backgroundColor: "none", bottomRow: 740, canExtend: true, - version: nextVersion, + version: currentVersion, children: [ { widgetName: "Input1", @@ -1156,14 +1155,13 @@ describe("correctly migrate dsl", () => { snapRows: 125, topRow: 0, type: "CANVAS_WIDGET", - version: nextVersion, widgetId: "0", widgetName: "MainContainer", renderMode: RenderModes.CANVAS, isLoading: false, }; - const actualNextDsl = transformDSL(currentDSL, false); + const actualNextDsl = addPrivateWidgetsToAllListWidgets(currentDSL); expect(actualNextDsl).toEqual(expectedNextDSL); }); diff --git a/app/client/src/widgets/ListWidget/widget/index.tsx b/app/client/src/widgets/ListWidget/widget/index.tsx index 03673890756..0719843e990 100644 --- a/app/client/src/widgets/ListWidget/widget/index.tsx +++ b/app/client/src/widgets/ListWidget/widget/index.tsx @@ -12,7 +12,6 @@ import { omit, floor, isEmpty, - isEqual, } from "lodash"; import memoizeOne from "memoize-one"; import shallowEqual from "shallowequal"; @@ -38,15 +37,8 @@ import derivedProperties from "./parseDerivedProperties"; import { DSLWidget } from "widgets/constants"; import { entityDefinitions } from "utils/autocomplete/EntityDefinitions"; import { escapeSpecialChars } from "../../WidgetUtils"; -import { PrivateWidgets } from "entities/DataTree/dataTreeFactory"; const LIST_WIDGEY_PAGINATION_HEIGHT = 36; - -/* in the List Widget, "children.0.children.0.children.0.children" is the path to the list of all - widgets present in the List Widget -*/ -const PATH_TO_ALL_WIDGETS_IN_LIST_WIDGET = - "children.0.children.0.children.0.children"; class ListWidget extends BaseWidget, WidgetState> { state = { page: 1, @@ -81,11 +73,7 @@ class ListWidget extends BaseWidget, WidgetState> { this.generateChildrenDefaultPropertiesMap(this.props); this.generateChildrenMetaPropertiesMap(this.props); this.generateChildrenEntityDefinitions(this.props); - - // add privateWidgets to ListWidget - this.addPrivateWidgetsForChildren(this.props); } - /** * generates the children entity definitions for children * @@ -124,21 +112,6 @@ class ListWidget extends BaseWidget, WidgetState> { } } - // updates the "privateWidgets" field of the List Widget - addPrivateWidgetsForChildren(props: ListWidgetProps) { - const privateWidgets: PrivateWidgets = {}; - const listWidgetChildren: WidgetProps[] = get( - props, - PATH_TO_ALL_WIDGETS_IN_LIST_WIDGET, - ); - if (!listWidgetChildren) return; - listWidgetChildren.map((child) => { - privateWidgets[child.widgetName] = true; - }); - - super.updateWidgetProperty("privateWidgets", privateWidgets); - } - generateChildrenDefaultPropertiesMap = ( props: ListWidgetProps, ) => { @@ -200,16 +173,6 @@ class ListWidget extends BaseWidget, WidgetState> { }; componentDidUpdate(prevProps: ListWidgetProps) { - const currentListWidgetChildren: WidgetProps[] = get( - this.props, - PATH_TO_ALL_WIDGETS_IN_LIST_WIDGET, - ); - - const previousListWidgetChildren: WidgetProps[] = get( - prevProps, - PATH_TO_ALL_WIDGETS_IN_LIST_WIDGET, - ); - if ( xor( Object.keys(get(prevProps, "template", {})), @@ -269,11 +232,6 @@ class ListWidget extends BaseWidget, WidgetState> { }, ); } - - // Update privateWidget field if there is a change in the List widget children - if (!isEqual(currentListWidgetChildren, previousListWidgetChildren)) { - this.addPrivateWidgetsForChildren(this.props); - } } static getDefaultPropertiesMap(): Record { diff --git a/app/client/src/workers/DataTreeEvaluator.ts b/app/client/src/workers/DataTreeEvaluator.ts index 121daaa1dc4..c6a9353bf55 100644 --- a/app/client/src/workers/DataTreeEvaluator.ts +++ b/app/client/src/workers/DataTreeEvaluator.ts @@ -22,7 +22,6 @@ import { DataTreeWidget, ENTITY_TYPE, EvaluationSubstitutionType, - PrivateWidgets, } from "entities/DataTree/dataTreeFactory"; import { addDependantsOfNestedPropertyPaths, @@ -48,7 +47,6 @@ import { getParams, updateJSCollectionInDataTree, removeFunctionsAndVariableJSCollection, - isPrivateEntityPath, } from "workers/evaluationUtils"; import _ from "lodash"; import { applyChange, Diff, diff } from "deep-diff"; @@ -85,7 +83,6 @@ export default class DataTreeEvaluator { widgetConfigMap: WidgetTypeConfigMap = {}; evalTree: DataTree = {}; allKeys: Record = {}; - privateWidgets: PrivateWidgets = {}; oldUnEvalTree: DataTree = {}; errors: EvalError[] = []; resolvedFunctions: Record = {}; @@ -486,17 +483,6 @@ export default class DataTreeEvaluator { return dependencyMap; } - getPrivateWidgets(dataTree: DataTree): PrivateWidgets { - let privateWidgets: PrivateWidgets = {}; - Object.keys(dataTree).forEach((entityName) => { - const entity = dataTree[entityName]; - if (isWidget(entity) && !_.isEmpty(entity.privateWidgets)) { - privateWidgets = { ...privateWidgets, ...entity.privateWidgets }; - } - }); - return privateWidgets; - } - listEntityDependencies( entity: DataTreeWidget | DataTreeAction | DataTreeJSAction, entityName: string, @@ -582,13 +568,9 @@ export default class DataTreeEvaluator { sortedDependencies: Array, ): DataTree { const tree = _.cloneDeep(oldUnevalTree); - this.privateWidgets = this.getPrivateWidgets(oldUnevalTree); try { return sortedDependencies.reduce( (currentTree: DataTree, fullPropertyPath: string) => { - // do not evaluate private entities - if (isPrivateEntityPath(this.privateWidgets, fullPropertyPath)) - return currentTree; const { entityName, propertyPath } = getEntityNameAndPropertyPath( fullPropertyPath, ); diff --git a/app/client/src/workers/evaluation.test.ts b/app/client/src/workers/evaluation.test.ts index 9d22e62e571..b3b9da67236 100644 --- a/app/client/src/workers/evaluation.test.ts +++ b/app/client/src/workers/evaluation.test.ts @@ -225,7 +225,6 @@ const BASE_WIDGET: DataTreeWidget = { triggerPaths: {}, validationPaths: {}, ENTITY_TYPE: ENTITY_TYPE.WIDGET, - privateWidgets: {}, }; const BASE_ACTION: DataTreeAction = { diff --git a/app/client/src/workers/evaluationUtils.test.ts b/app/client/src/workers/evaluationUtils.test.ts index 822a88ccdca..7987e925c03 100644 --- a/app/client/src/workers/evaluationUtils.test.ts +++ b/app/client/src/workers/evaluationUtils.test.ts @@ -1,106 +1,4 @@ -import { RenderModes } from "constants/WidgetConstants"; -import { ValidationTypes } from "constants/WidgetValidation"; -import { - DataTreeWidget, - ENTITY_TYPE, - EvaluationSubstitutionType, - PrivateWidgets, -} from "entities/DataTree/dataTreeFactory"; -import { - getAllPaths, - getAllPrivateWidgetsInDataTree, - getDataTreeWithoutPrivateWidgets, - isPrivateEntityPath, -} from "./evaluationUtils"; - -const BASE_WIDGET: DataTreeWidget = { - logBlackList: {}, - widgetId: "randomID", - widgetName: "randomWidgetName", - bottomRow: 0, - isLoading: false, - leftColumn: 0, - parentColumnSpace: 0, - parentRowSpace: 0, - renderMode: RenderModes.CANVAS, - rightColumn: 0, - topRow: 0, - type: "SKELETON_WIDGET", - parentId: "0", - version: 1, - bindingPaths: {}, - triggerPaths: {}, - validationPaths: {}, - ENTITY_TYPE: ENTITY_TYPE.WIDGET, - privateWidgets: {}, -}; - -const testDataTree: Record = { - Text1: { - ...BASE_WIDGET, - widgetName: "Text1", - text: "Label", - type: "TEXT_WIDGET", - bindingPaths: { - text: EvaluationSubstitutionType.TEMPLATE, - }, - validationPaths: { - text: { type: ValidationTypes.TEXT }, - }, - }, - Text2: { - ...BASE_WIDGET, - widgetName: "Text2", - text: "{{Text1.text}}", - dynamicBindingPathList: [{ key: "text" }], - type: "TEXT_WIDGET", - bindingPaths: { - text: EvaluationSubstitutionType.TEMPLATE, - }, - validationPaths: { - text: { type: ValidationTypes.TEXT }, - }, - }, - Text3: { - ...BASE_WIDGET, - widgetName: "Text3", - text: "{{Text1.text}}", - dynamicBindingPathList: [{ key: "text" }], - type: "TEXT_WIDGET", - bindingPaths: { - text: EvaluationSubstitutionType.TEMPLATE, - }, - validationPaths: { - text: { type: ValidationTypes.TEXT }, - }, - }, - Text4: { - ...BASE_WIDGET, - widgetName: "Text4", - text: "{{Text1.text}}", - dynamicBindingPathList: [{ key: "text" }], - type: "TEXT_WIDGET", - bindingPaths: { - text: EvaluationSubstitutionType.TEMPLATE, - }, - validationPaths: { - text: { type: ValidationTypes.TEXT }, - }, - }, - - List1: { - ...BASE_WIDGET, - privateWidgets: { - Text2: true, - }, - }, - List2: { - ...BASE_WIDGET, - privateWidgets: { - Text3: true, - }, - }, -}; +import { getAllPaths } from "./evaluationUtils"; describe("Correctly handle paths", () => { it("getsAllPaths", () => { @@ -141,91 +39,3 @@ describe("Correctly handle paths", () => { expect(actual).toStrictEqual(result); }); }); - -describe("privateWidgets", () => { - it("correctly checks if path is a PrivateEntityPath", () => { - const privateWidgets: PrivateWidgets = { - Button1: true, - Image1: true, - Button2: true, - Image2: true, - }; - - expect( - isPrivateEntityPath(privateWidgets, "List1.template.Button1.text"), - ).toBeFalsy(); - expect(isPrivateEntityPath(privateWidgets, "Button1.text")).toBeTruthy(); - expect( - isPrivateEntityPath(privateWidgets, "List2.template.Image2.data"), - ).toBeFalsy(); - expect(isPrivateEntityPath(privateWidgets, "Image2.data")).toBeTruthy(); - }); - - it("Returns list of all privateWidgets", () => { - const expectedPrivateWidgetsList = { - Text2: true, - Text3: true, - }; - - const actualPrivateWidgetsList = getAllPrivateWidgetsInDataTree( - testDataTree, - ); - - expect(expectedPrivateWidgetsList).toStrictEqual(actualPrivateWidgetsList); - }); - - it("Returns data tree without privateWidgets", () => { - const expectedDataTreeWithoutPrivateWidgets: Record< - string, - DataTreeWidget - > = { - Text1: { - ...BASE_WIDGET, - widgetName: "Text1", - text: "Label", - type: "TEXT_WIDGET", - bindingPaths: { - text: EvaluationSubstitutionType.TEMPLATE, - }, - validationPaths: { - text: { type: ValidationTypes.TEXT }, - }, - }, - - Text4: { - ...BASE_WIDGET, - widgetName: "Text4", - text: "{{Text1.text}}", - dynamicBindingPathList: [{ key: "text" }], - type: "TEXT_WIDGET", - bindingPaths: { - text: EvaluationSubstitutionType.TEMPLATE, - }, - validationPaths: { - text: { type: ValidationTypes.TEXT }, - }, - }, - - List1: { - ...BASE_WIDGET, - privateWidgets: { - Text2: true, - }, - }, - List2: { - ...BASE_WIDGET, - privateWidgets: { - Text3: true, - }, - }, - }; - - const actualDataTreeWithoutPrivateWidgets = getDataTreeWithoutPrivateWidgets( - testDataTree, - ); - - expect(expectedDataTreeWithoutPrivateWidgets).toStrictEqual( - actualDataTreeWithoutPrivateWidgets, - ); - }); -}); diff --git a/app/client/src/workers/evaluationUtils.ts b/app/client/src/workers/evaluationUtils.ts index 30356319652..3e0e94fe38c 100644 --- a/app/client/src/workers/evaluationUtils.ts +++ b/app/client/src/workers/evaluationUtils.ts @@ -19,7 +19,6 @@ import { ENTITY_TYPE, DataTreeJSAction, EvaluationSubstitutionType, - PrivateWidgets, } from "entities/DataTree/dataTreeFactory"; import _ from "lodash"; import { WidgetTypeConfigMap } from "utils/WidgetFactory"; @@ -724,38 +723,3 @@ export const removeFunctionsAndVariableJSCollection = ( _.set(modifiedDataTree, `${entity.name}.meta`, meta); return modifiedDataTree; }; - -export const isPrivateEntityPath = ( - privateWidgets: PrivateWidgets, - fullPropertyPath: string, -) => { - const entityName = fullPropertyPath.split(".")[0]; - if (Object.keys(privateWidgets).indexOf(entityName) !== -1) { - return true; - } - return false; -}; - -export const getAllPrivateWidgetsInDataTree = ( - dataTree: DataTree, -): PrivateWidgets => { - let privateWidgets: PrivateWidgets = {}; - - Object.keys(dataTree).forEach((entityName) => { - const entity = dataTree[entityName]; - if (isWidget(entity) && !_.isEmpty(entity.privateWidgets)) { - privateWidgets = { ...privateWidgets, ...entity.privateWidgets }; - } - }); - - return privateWidgets; -}; - -export const getDataTreeWithoutPrivateWidgets = ( - dataTree: DataTree, -): DataTree => { - const privateWidgets = getAllPrivateWidgetsInDataTree(dataTree); - const privateWidgetNames = Object.keys(privateWidgets); - const treeWithoutPrivateWidgets = _.omit(dataTree, privateWidgetNames); - return treeWithoutPrivateWidgets; -};