Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reverts private widgets feature #10693

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions app/client/src/entities/DataTree/dataTreeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, true>;

export interface DataTreeAction
extends Omit<ActionDataWithMeta, "data" | "config"> {
data: ActionResponse["body"];
Expand Down Expand Up @@ -86,7 +81,6 @@ export interface DataTreeWidget extends WidgetProps {
validationPaths: Record<string, ValidationConfig>;
ENTITY_TYPE: ENTITY_TYPE.WIDGET;
logBlackList: Record<string, true>;
privateWidgets: PrivateWidgets;
}

export interface DataTreeAppsmith extends Omit<AppDataState, "store"> {
Expand Down
1 change: 0 additions & 1 deletion app/client/src/entities/DataTree/dataTreeWidget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ describe("generateDataTreeWidget", () => {
defaultProps: {
text: "defaultText",
},
privateWidgets: {},
};

const result = generateDataTreeWidget(widget, widgetMetaProps);
Expand Down
3 changes: 0 additions & 3 deletions app/client/src/entities/DataTree/dataTreeWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,5 @@ export const generateDataTreeWidget = (
triggerPaths,
validationPaths,
ENTITY_TYPE: ENTITY_TYPE.WIDGET,
privateWidgets: {
...widget.privateWidgets,
},
};
};
9 changes: 1 addition & 8 deletions app/client/src/sagas/PostEvaluationSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { DataTree } from "entities/DataTree/dataTreeFactory";
import {
DataTreeDiff,
DataTreeDiffEvent,
getDataTreeWithoutPrivateWidgets,
getEntityNameAndPropertyPath,
isAction,
isJSAction,
Expand Down Expand Up @@ -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 });
Expand Down
1 change: 0 additions & 1 deletion app/client/src/selectors/editorSelectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ const createLoadingWidget = (
validationPaths: {},
logBlackList: {},
isLoading: true,
privateWidgets: {},
};
};

Expand Down
5 changes: 2 additions & 3 deletions app/client/src/utils/DSLMigrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,12 +90,12 @@ const addLogBlackListToAllListWidgetChildren = (
* @param currentDSL
* @returns
*/
const addPrivateWidgetsToAllListWidgets = (
export const addPrivateWidgetsToAllListWidgets = (
currentDSL: ContainerWidgetProps<WidgetProps>,
) => {
currentDSL.children = currentDSL.children?.map((child: WidgetProps) => {
if (child.type === "LIST_WIDGET") {
const privateWidgets: PrivateWidgets = {};
const privateWidgets: Record<string, true> = {};
Object.keys(child.template).forEach((entityName) => {
privateWidgets[entityName] = true;
});
Expand Down
10 changes: 4 additions & 6 deletions app/client/src/utils/DSLMigrationsUtils.test.ts
Original file line number Diff line number Diff line change
@@ -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<WidgetProps> = {
backgroundColor: "none",
bottomRow: 740,
Expand Down Expand Up @@ -586,7 +585,7 @@ describe("correctly migrate dsl", () => {
backgroundColor: "none",
bottomRow: 740,
canExtend: true,
version: nextVersion,
version: currentVersion,
children: [
{
widgetName: "Input1",
Expand Down Expand Up @@ -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);
});
Expand Down
42 changes: 0 additions & 42 deletions app/client/src/widgets/ListWidget/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
omit,
floor,
isEmpty,
isEqual,
} from "lodash";
import memoizeOne from "memoize-one";
import shallowEqual from "shallowequal";
Expand All @@ -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<ListWidgetProps<WidgetProps>, WidgetState> {
state = {
page: 1,
Expand Down Expand Up @@ -81,11 +73,7 @@ class ListWidget extends BaseWidget<ListWidgetProps<WidgetProps>, 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
*
Expand Down Expand Up @@ -124,21 +112,6 @@ class ListWidget extends BaseWidget<ListWidgetProps<WidgetProps>, WidgetState> {
}
}

// updates the "privateWidgets" field of the List Widget
addPrivateWidgetsForChildren(props: ListWidgetProps<WidgetProps>) {
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<WidgetProps>,
) => {
Expand Down Expand Up @@ -200,16 +173,6 @@ class ListWidget extends BaseWidget<ListWidgetProps<WidgetProps>, WidgetState> {
};

componentDidUpdate(prevProps: ListWidgetProps<WidgetProps>) {
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", {})),
Expand Down Expand Up @@ -269,11 +232,6 @@ class ListWidget extends BaseWidget<ListWidgetProps<WidgetProps>, 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<string, string> {
Expand Down
18 changes: 0 additions & 18 deletions app/client/src/workers/DataTreeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
DataTreeWidget,
ENTITY_TYPE,
EvaluationSubstitutionType,
PrivateWidgets,
} from "entities/DataTree/dataTreeFactory";
import {
addDependantsOfNestedPropertyPaths,
Expand All @@ -48,7 +47,6 @@ import {
getParams,
updateJSCollectionInDataTree,
removeFunctionsAndVariableJSCollection,
isPrivateEntityPath,
} from "workers/evaluationUtils";
import _ from "lodash";
import { applyChange, Diff, diff } from "deep-diff";
Expand Down Expand Up @@ -85,7 +83,6 @@ export default class DataTreeEvaluator {
widgetConfigMap: WidgetTypeConfigMap = {};
evalTree: DataTree = {};
allKeys: Record<string, true> = {};
privateWidgets: PrivateWidgets = {};
oldUnEvalTree: DataTree = {};
errors: EvalError[] = [];
resolvedFunctions: Record<string, any> = {};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -582,13 +568,9 @@ export default class DataTreeEvaluator {
sortedDependencies: Array<string>,
): 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,
);
Expand Down
1 change: 0 additions & 1 deletion app/client/src/workers/evaluation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ const BASE_WIDGET: DataTreeWidget = {
triggerPaths: {},
validationPaths: {},
ENTITY_TYPE: ENTITY_TYPE.WIDGET,
privateWidgets: {},
};

const BASE_ACTION: DataTreeAction = {
Expand Down
Loading