-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat: made changes to expose the App's height and width as part of the appsmith.ui state object #41339
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
feat: made changes to expose the App's height and width as part of the appsmith.ui state object #41339
Changes from 1 commit
71e7be8
2208b17
d87c395
1099d28
c360db0
1b50c59
f12b699
134a977
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { ReduxActionTypes } from "ee/constants/ReduxActionConstants"; | ||
|
|
||
| export const updateWindowDimensions = (height: number, width: number) => ({ | ||
| type: ReduxActionTypes.UPDATE_WINDOW_DIMENSIONS, | ||
| payload: { height, width }, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { createImmerReducer } from "utils/ReducerUtils"; | ||
| import { ReduxActionTypes } from "ee/constants/ReduxActionConstants"; | ||
| import type { ReduxAction } from "actions/ReduxActionTypes"; | ||
|
|
||
| export interface WindowDimensionsState { | ||
| height: number; | ||
| width: number; | ||
| } | ||
|
|
||
| const initialState: WindowDimensionsState = { | ||
| height: typeof window !== "undefined" ? window.innerHeight : 0, | ||
| width: typeof window !== "undefined" ? window.innerWidth : 0, | ||
| }; | ||
|
|
||
| const windowReducer = createImmerReducer(initialState, { | ||
| [ReduxActionTypes.UPDATE_WINDOW_DIMENSIONS]: ( | ||
| state: WindowDimensionsState, | ||
| action: ReduxAction<{ height: number; width: number }>, | ||
| ) => { | ||
| state.height = action.payload.height; | ||
| state.width = action.payload.width; | ||
| }, | ||
| }); | ||
|
|
||
| export default windowReducer; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { ReduxActionTypes } from "ee/constants/ReduxActionConstants"; | ||
| import { takeLatest, select, call } from "redux-saga/effects"; | ||
| import { evaluateTreeSaga } from "./EvaluationsSaga"; | ||
| import { getUnevaluatedDataTree } from "selectors/dataTreeSelectors"; | ||
|
|
||
| export function* handleWindowDimensionsUpdate() { | ||
| const unEvalAndConfigTree = yield select(getUnevaluatedDataTree); | ||
|
|
||
| yield call(evaluateTreeSaga, unEvalAndConfigTree); | ||
| } | ||
|
||
|
|
||
| export default function* windowSaga() { | ||
| yield takeLatest( | ||
| ReduxActionTypes.UPDATE_WINDOW_DIMENSIONS, | ||
| handleWindowDimensionsUpdate, | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ import { | |
| import "url-search-params-polyfill"; | ||
| import type { DefaultRootState } from "react-redux"; | ||
| import { getSelectedAppThemeProperties } from "./appThemingSelectors"; | ||
| import { getWindowDimensions } from "./windowSelectors"; | ||
| import type { LoadingEntitiesState } from "reducers/evaluationReducers/loadingEntitiesReducer"; | ||
| import _, { get } from "lodash"; | ||
| import type { EvaluationError } from "utils/DynamicBindingUtils"; | ||
|
|
@@ -149,6 +150,7 @@ export const getUnevaluatedDataTree = createSelector( | |
| getMetaWidgetsFromUnevaluatedDataTree, | ||
| getAppData, | ||
| getSelectedAppThemeProperties, | ||
| getWindowDimensions, | ||
| getCurrentAppWorkspace, | ||
| getCurrentApplication, | ||
| getCurrentPageName, | ||
|
|
@@ -160,6 +162,7 @@ export const getUnevaluatedDataTree = createSelector( | |
| metaWidgets, | ||
| appData, | ||
| theme, | ||
| windowDimensions, | ||
| currentWorkspace, | ||
| currentApplication, | ||
| getCurrentPageName, | ||
|
|
@@ -182,6 +185,7 @@ export const getUnevaluatedDataTree = createSelector( | |
| // taking precedence in case the key is the same | ||
| store: appData.store, | ||
| theme, | ||
| ui: windowDimensions, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the structure of The assignment 🏁 Script executed: #!/bin/bash
# Search for existing references to appsmith.ui to verify structure expectations
rg -nP 'appsmith\.ui\b' --type=ts --type=tsx -C3Length of output: 27 Length of output: 34 🏁 Script executed: #!/bin/bash
# Also search for ui property assignments and windowDimensions usage in dataTree context
rg -nP '(ui\s*:|windowDimensions)' app/client/src/selectors/dataTreeSelectors.ts -C5Length of output: 691 🏁 Script executed: #!/bin/bash
# Search for dataTree object construction to understand the structure
rg -nP 'dataTree\s*=\s*\{' --type=typescript -C10Length of output: 34 Length of output: 2717 🏁 Script executed: #!/bin/bash
# Search for ui property references in the same file
rg -n 'ui:' app/client/src/selectors/dataTreeSelectors.tsLength of output: 31 🏁 Script executed: #!/bin/bash
# Find windowDimensions type/definition
rg -nP 'windowDimensions\s*[=:|]' -C3 | head -50Length of output: 613 🏁 Script executed: #!/bin/bash
# Search for appsmith.ui references without type flags
rg -n 'appsmith\.ui' -C2Length of output: 3987 Length of output: 451 🏁 Script executed: #!/bin/bash
# Also check if ui is defined in AppDataState (which AppsmithEntity extends from)
rg -n 'interface AppDataState|type AppDataState' -A15Length of output: 1319 Length of output: 656 🏁 Script executed: #!/bin/bash
# Search for any type extensions or augmentations of AppsmithEntity that add ui property
rg -n 'AppsmithEntity' app/client/src/ce/entities/DataTree/types.ts -A30Length of output: 906 Add The assignment of Update export interface AppsmithEntity extends Omit<AppDataState, "store"> {
ENTITY_TYPE: typeof ENTITY_TYPE.APPSMITH;
store: Record<string, unknown>;
theme: AppTheme["properties"];
ui: { width: number; height: number };
currentPageName: string;
workspaceName: string;
appName: string;
currentEnvironmentName: string;
}🤖 Prompt for AI Agents |
||
| currentPageName: getCurrentPageName, | ||
| workspaceName: currentWorkspace.name, | ||
| appName: currentApplication?.name, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import type { DefaultRootState } from "react-redux"; | ||
|
|
||
| export const getWindowDimensions = (state: DefaultRootState) => { | ||
| return state.ui.windowDimensions; | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.