From 96c4be94b658325c1ab8d09ee1bd1d70c3b28987 Mon Sep 17 00:00:00 2001 From: rishabhrathod01 Date: Wed, 11 Dec 2024 23:25:05 +0530 Subject: [PATCH 1/5] feat: Add currentPage, workspace, application name to appsmith context --- app/client/src/ce/entities/DataTree/types.ts | 3 +++ app/client/src/selectors/dataTreeSelectors.ts | 23 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/client/src/ce/entities/DataTree/types.ts b/app/client/src/ce/entities/DataTree/types.ts index 04a5877c4a1..b2240f15f85 100644 --- a/app/client/src/ce/entities/DataTree/types.ts +++ b/app/client/src/ce/entities/DataTree/types.ts @@ -189,6 +189,9 @@ export interface AppsmithEntity extends Omit { ENTITY_TYPE: typeof ENTITY_TYPE.APPSMITH; store: Record; theme: AppTheme["properties"]; + currentPageName: string; + workspaceName: string; + appName: string; } export interface DataTreeSeed { diff --git a/app/client/src/selectors/dataTreeSelectors.ts b/app/client/src/selectors/dataTreeSelectors.ts index 1babbe0563b..f803035b336 100644 --- a/app/client/src/selectors/dataTreeSelectors.ts +++ b/app/client/src/selectors/dataTreeSelectors.ts @@ -41,6 +41,9 @@ import { getCurrentWorkflowActions, getCurrentWorkflowJSActions, } from "ee/selectors/workflowSelectors"; +import { getCurrentApplication } from "ee/selectors/applicationSelectors"; +import { getCurrentAppWorkspace } from "ee/selectors/selectedWorkspaceSelectors"; +import { getCurrentPageName } from "./editorSelectors"; export const getLoadingEntities = (state: AppState) => state.evaluations.loadingEntities; @@ -137,7 +140,20 @@ export const getUnevaluatedDataTree = createSelector( getMetaWidgetsFromUnevaluatedDataTree, getAppData, getSelectedAppThemeProperties, - (actions, jsActions, widgets, metaWidgets, appData, theme) => { + getCurrentAppWorkspace, + getCurrentApplication, + getCurrentPageName, + ( + actions, + jsActions, + widgets, + metaWidgets, + appData, + theme, + currentWorkspace, + currentApplication, + getCurrentPageName, + ) => { let dataTree: UnEvalTree = { ...actions.dataTree, ...jsActions.dataTree, @@ -149,12 +165,17 @@ export const getUnevaluatedDataTree = createSelector( ...widgets.configTree, }; + // const { currentPageName, workspaceName, appName } = someObj; + dataTree.appsmith = { ...appData, // combine both persistent and transient state with the transient state // taking precedence in case the key is the same store: appData.store, theme, + currentPageName: getCurrentPageName, + workspaceName: currentWorkspace.name, + appName: currentApplication?.name, } as AppsmithEntity; (dataTree.appsmith as AppsmithEntity).ENTITY_TYPE = ENTITY_TYPE.APPSMITH; dataTree = { ...dataTree, ...metaWidgets.dataTree }; From 6c39e11c41b5784d7d21ce3d68344999e5af6069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csneha122=E2=80=9D?= <“sneha@appsmith.com”> Date: Tue, 17 Dec 2024 12:04:15 +0530 Subject: [PATCH 2/5] fix: cyclic dependency issue fixed --- app/client/src/selectors/dataTreeSelectors.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/client/src/selectors/dataTreeSelectors.ts b/app/client/src/selectors/dataTreeSelectors.ts index f803035b336..82394603abc 100644 --- a/app/client/src/selectors/dataTreeSelectors.ts +++ b/app/client/src/selectors/dataTreeSelectors.ts @@ -43,7 +43,7 @@ import { } from "ee/selectors/workflowSelectors"; import { getCurrentApplication } from "ee/selectors/applicationSelectors"; import { getCurrentAppWorkspace } from "ee/selectors/selectedWorkspaceSelectors"; -import { getCurrentPageName } from "./editorSelectors"; +import type { PageListReduxState } from "reducers/entityReducers/pageListReducer"; export const getLoadingEntities = (state: AppState) => state.evaluations.loadingEntities; @@ -133,6 +133,15 @@ const getMetaWidgetsFromUnevaluatedDataTree = createSelector( DataTreeFactory.metaWidgets(metaWidgets, widgetsMeta, loadingEntities), ); +// * This is only for internal use to avoid cyclic dependency issue +const getPageListState = (state: AppState) => state.entities.pageList; +const getCurrentPageName = createSelector( + getPageListState, + (pageList: PageListReduxState) => + pageList.pages.find((page) => page.pageId === pageList.currentPageId) + ?.pageName, +); + export const getUnevaluatedDataTree = createSelector( getActionsFromUnevaluatedDataTree, getJSActionsFromUnevaluatedDataTree, From 8acdb47e4188263ce61cec65b8410106ebba3c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csneha122=E2=80=9D?= <“sneha@appsmith.com”> Date: Mon, 23 Dec 2024 10:38:24 +0530 Subject: [PATCH 3/5] code review comments addressed --- app/client/src/selectors/dataTreeSelectors.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/client/src/selectors/dataTreeSelectors.ts b/app/client/src/selectors/dataTreeSelectors.ts index 82394603abc..b64f4fbba4f 100644 --- a/app/client/src/selectors/dataTreeSelectors.ts +++ b/app/client/src/selectors/dataTreeSelectors.ts @@ -174,8 +174,6 @@ export const getUnevaluatedDataTree = createSelector( ...widgets.configTree, }; - // const { currentPageName, workspaceName, appName } = someObj; - dataTree.appsmith = { ...appData, // combine both persistent and transient state with the transient state From b6a7de6c2f20011efe27a4ea7b6a9bfb050e64ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csneha122=E2=80=9D?= <“sneha@appsmith.com”> Date: Mon, 23 Dec 2024 10:55:53 +0530 Subject: [PATCH 4/5] env name added to appsmith context as well --- app/client/src/ce/entities/DataTree/types.ts | 1 + app/client/src/selectors/dataTreeSelectors.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/client/src/ce/entities/DataTree/types.ts b/app/client/src/ce/entities/DataTree/types.ts index 42652009b95..11c43bf725a 100644 --- a/app/client/src/ce/entities/DataTree/types.ts +++ b/app/client/src/ce/entities/DataTree/types.ts @@ -193,6 +193,7 @@ export interface AppsmithEntity extends Omit { currentPageName: string; workspaceName: string; appName: string; + currentEnvName: string; } export interface DataTreeSeed { diff --git a/app/client/src/selectors/dataTreeSelectors.ts b/app/client/src/selectors/dataTreeSelectors.ts index b64f4fbba4f..983f827bd7a 100644 --- a/app/client/src/selectors/dataTreeSelectors.ts +++ b/app/client/src/selectors/dataTreeSelectors.ts @@ -44,6 +44,7 @@ import { import { getCurrentApplication } from "ee/selectors/applicationSelectors"; import { getCurrentAppWorkspace } from "ee/selectors/selectedWorkspaceSelectors"; import type { PageListReduxState } from "reducers/entityReducers/pageListReducer"; +import { getCurrentEnvironmentName } from "ee/selectors/environmentSelectors"; export const getLoadingEntities = (state: AppState) => state.evaluations.loadingEntities; @@ -152,6 +153,7 @@ export const getUnevaluatedDataTree = createSelector( getCurrentAppWorkspace, getCurrentApplication, getCurrentPageName, + getCurrentEnvironmentName, ( actions, jsActions, @@ -162,6 +164,7 @@ export const getUnevaluatedDataTree = createSelector( currentWorkspace, currentApplication, getCurrentPageName, + currentEnvironmentName, ) => { let dataTree: UnEvalTree = { ...actions.dataTree, @@ -183,6 +186,7 @@ export const getUnevaluatedDataTree = createSelector( currentPageName: getCurrentPageName, workspaceName: currentWorkspace.name, appName: currentApplication?.name, + currentEnvName: currentEnvironmentName, } as AppsmithEntity; (dataTree.appsmith as AppsmithEntity).ENTITY_TYPE = ENTITY_TYPE.APPSMITH; dataTree = { ...dataTree, ...metaWidgets.dataTree }; From eec4292d3bc1db86bdcf089061a6d2c7d8fa2205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csneha122=E2=80=9D?= <“sneha@appsmith.com”> Date: Mon, 23 Dec 2024 12:52:50 +0530 Subject: [PATCH 5/5] fix: removed current env and fixed cypress tests --- .../e2e/Regression/ClientSide/Autocomplete/JS_AC1_spec.ts | 4 ++-- app/client/src/ce/entities/DataTree/types.ts | 1 - app/client/src/selectors/dataTreeSelectors.ts | 4 ---- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/Autocomplete/JS_AC1_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Autocomplete/JS_AC1_spec.ts index f8190d48f01..d37b4389a20 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Autocomplete/JS_AC1_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Autocomplete/JS_AC1_spec.ts @@ -298,7 +298,7 @@ describe("Autocomplete tests", { tags: ["@tag.JS", "@tag.Binding"] }, () => { ) .type("."); - agHelper.GetNAssertElementText(locators._hints, "geolocation"); + agHelper.GetNAssertElementText(locators._hints, "appName"); }); }); @@ -313,6 +313,6 @@ describe("Autocomplete tests", { tags: ["@tag.JS", "@tag.Binding"] }, () => { .type("{downArrow}{leftArrow}{leftArrow}"); agHelper.TypeText(locators._codeMirrorTextArea, "."); - agHelper.GetNAssertElementText(locators._hints, "geolocation"); + agHelper.GetNAssertElementText(locators._hints, "appName"); }); }); diff --git a/app/client/src/ce/entities/DataTree/types.ts b/app/client/src/ce/entities/DataTree/types.ts index 11c43bf725a..42652009b95 100644 --- a/app/client/src/ce/entities/DataTree/types.ts +++ b/app/client/src/ce/entities/DataTree/types.ts @@ -193,7 +193,6 @@ export interface AppsmithEntity extends Omit { currentPageName: string; workspaceName: string; appName: string; - currentEnvName: string; } export interface DataTreeSeed { diff --git a/app/client/src/selectors/dataTreeSelectors.ts b/app/client/src/selectors/dataTreeSelectors.ts index 983f827bd7a..b64f4fbba4f 100644 --- a/app/client/src/selectors/dataTreeSelectors.ts +++ b/app/client/src/selectors/dataTreeSelectors.ts @@ -44,7 +44,6 @@ import { import { getCurrentApplication } from "ee/selectors/applicationSelectors"; import { getCurrentAppWorkspace } from "ee/selectors/selectedWorkspaceSelectors"; import type { PageListReduxState } from "reducers/entityReducers/pageListReducer"; -import { getCurrentEnvironmentName } from "ee/selectors/environmentSelectors"; export const getLoadingEntities = (state: AppState) => state.evaluations.loadingEntities; @@ -153,7 +152,6 @@ export const getUnevaluatedDataTree = createSelector( getCurrentAppWorkspace, getCurrentApplication, getCurrentPageName, - getCurrentEnvironmentName, ( actions, jsActions, @@ -164,7 +162,6 @@ export const getUnevaluatedDataTree = createSelector( currentWorkspace, currentApplication, getCurrentPageName, - currentEnvironmentName, ) => { let dataTree: UnEvalTree = { ...actions.dataTree, @@ -186,7 +183,6 @@ export const getUnevaluatedDataTree = createSelector( currentPageName: getCurrentPageName, workspaceName: currentWorkspace.name, appName: currentApplication?.name, - currentEnvName: currentEnvironmentName, } as AppsmithEntity; (dataTree.appsmith as AppsmithEntity).ENTITY_TYPE = ENTITY_TYPE.APPSMITH; dataTree = { ...dataTree, ...metaWidgets.dataTree };