Skip to content

Commit

Permalink
feat: Add currentPage, workspace, application name to appsmith context
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhrathod01 committed Dec 11, 2024
1 parent 61c90ce commit 96c4be9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/client/src/ce/entities/DataTree/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export interface AppsmithEntity extends Omit<AppDataState, "store"> {
ENTITY_TYPE: typeof ENTITY_TYPE.APPSMITH;
store: Record<string, unknown>;
theme: AppTheme["properties"];
currentPageName: string;
workspaceName: string;
appName: string;
}

export interface DataTreeSeed {
Expand Down
23 changes: 22 additions & 1 deletion app/client/src/selectors/dataTreeSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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 };
Expand Down

0 comments on commit 96c4be9

Please sign in to comment.