From 96c4be94b658325c1ab8d09ee1bd1d70c3b28987 Mon Sep 17 00:00:00 2001 From: rishabhrathod01 Date: Wed, 11 Dec 2024 23:25:05 +0530 Subject: [PATCH] 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 };