PromucFlow_constructor/app/client/src/components/autoHeightOverlay/store.ts

101 lines
2.4 KiB
TypeScript
Raw Normal View History

fix: Switch to preview mode performance issue (#18457) * In progress fixes for auto height perf * Revert collapse logic * Revert changes * Remove console logs, and fix tests * Fix scenario where container widgets don't collapse * Bring back hidden widgets * fix: Overlapping of widgets while reflowing other widgets (#18460) * fix: api url z-index to show it above response panel (#18200) * chore: Switched to sequential checks instead of a parallel one for RTS check (#18440) fix: Switched to sequential checks instead of a parallel one * chore: Added size limit check for the message before sending the data to segment (#18453) * fix: Allowing multi form to json switching and eliminating json to form sw… (#18192) * Allowing multi form to json switching and eliminating json to form switching unless form data is cleared * Fix failing jest test case Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> * add missed width and height limits instead of incrementing depth by 1 Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Nidhi <nidhi@appsmith.com> Co-authored-by: Anagh Hegde <anagh@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> * fix: auto height with limits deselect widget (#18455) * fix: api url z-index to show it above response panel (#18200) * chore: Switched to sequential checks instead of a parallel one for RTS check (#18440) fix: Switched to sequential checks instead of a parallel one * chore: Added size limit check for the message before sending the data to segment (#18453) * fix: Allowing multi form to json switching and eliminating json to form sw… (#18192) * Allowing multi form to json switching and eliminating json to form switching unless form data is cleared * Fix failing jest test case Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> * refactor overlay and handles state into ui reducer and added a check for is limits changing in the widgets editor as well * added helpful comments at relevant places Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Nidhi <nidhi@appsmith.com> Co-authored-by: Anagh Hegde <anagh@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Ankur Singhal <ankurrsinghal@gmail.com> * changes the label on limit handles collision to height * fix: issues related to tabs widget in auto height (#18468) * Fix issues related to tabs widget in auto height * Fix issue where preview mode canvas did not scroll * Fix scroll issues with fixed containers * Fix issue where tabs widget computed the canvas height incorrectly * Re-compute in case of tabs widget * fix: widgets increase spacing (#18462) * Change how the spacing works when widgets push or pull widgets below * Fix type issues in test file * Fix tests to reflect changes * Add comment to describe why we're generating distanceToNearestAbove Co-authored-by: rahulramesha <71900764+rahulramesha@users.noreply.github.com> Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Nidhi <nidhi@appsmith.com> Co-authored-by: Anagh Hegde <anagh@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: ankurrsinghal <ankur@appsmith.com> Co-authored-by: Ankur Singhal <ankurrsinghal@gmail.com>
2022-11-27 17:12:00 +00:00
import { GridDefaults } from "constants/WidgetConstants";
interface AutoHeightLimitsUIState {
isMaxDotDragging: boolean;
isMinDotDragging: boolean;
maxY: number; // the actual value
maxdY: number; // the difference during dragging
minY: number; // the actual value
mindY: number; // the difference during dragging
}
type SET_MAX_Y = { type: "SET_MAX_Y"; payload: { maxY: number } };
type SET_MIN_Y = { type: "SET_MIN_Y"; payload: { minY: number } };
type SET_MAX_D_Y = { type: "SET_MAX_D_Y"; payload: { maxdY: number } };
type SET_MIN_D_Y = { type: "SET_MIN_D_Y"; payload: { mindY: number } };
type SET_IS_MIN_DOT_DRAGGING = {
type: "SET_IS_MIN_DOT_DRAGGING";
payload: { isMinDotDragging: boolean };
};
type SET_IS_MAX_DOT_DRAGGING = {
type: "SET_IS_MAX_DOT_DRAGGING";
payload: { isMaxDotDragging: boolean };
};
type AutoHeightLimitsUIAction =
| SET_MAX_Y
| SET_MIN_Y
| SET_MAX_D_Y
| SET_MIN_D_Y
| SET_IS_MIN_DOT_DRAGGING
| SET_IS_MAX_DOT_DRAGGING;
export function AutoHeightOverlayUIStateReducer(
state: AutoHeightLimitsUIState,
action: AutoHeightLimitsUIAction,
) {
if (action.type === "SET_IS_MAX_DOT_DRAGGING") {
return {
...state,
isMaxDotDragging: action.payload.isMaxDotDragging,
};
}
if (action.type === "SET_IS_MIN_DOT_DRAGGING") {
return {
...state,
isMinDotDragging: action.payload.isMinDotDragging,
};
}
if (action.type === "SET_MAX_Y") {
return {
...state,
maxY: action.payload.maxY,
};
}
if (action.type === "SET_MIN_Y") {
return {
...state,
minY: action.payload.minY,
};
}
if (action.type === "SET_MAX_D_Y") {
return {
...state,
maxdY: action.payload.maxdY,
};
}
if (action.type === "SET_MIN_D_Y") {
return {
...state,
mindY: action.payload.mindY,
};
}
return state;
}
interface CreateInitialAutoHeightUIStateProps {
maxDynamicHeight: number;
minDynamicHeight: number;
}
export function createInitialAutoHeightUIState({
maxDynamicHeight,
minDynamicHeight,
}: CreateInitialAutoHeightUIStateProps) {
return {
isMinDotDragging: false,
isMaxDotDragging: false,
maxY: maxDynamicHeight * GridDefaults.DEFAULT_GRID_ROW_HEIGHT, // the actual value
maxdY: 0, // the difference during dragging
minY: minDynamicHeight * GridDefaults.DEFAULT_GRID_ROW_HEIGHT, // the actual value
mindY: 0, // the difference during dragging
};
}