* 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>
163 lines
5.3 KiB
TypeScript
163 lines
5.3 KiB
TypeScript
import equal from "fast-deep-equal/es6";
|
|
import React from "react";
|
|
|
|
import BaseWidget, { WidgetProps } from "./BaseWidget";
|
|
import {
|
|
MAIN_CONTAINER_WIDGET_ID,
|
|
RenderModes,
|
|
} from "constants/WidgetConstants";
|
|
import {
|
|
getWidgetEvalValues,
|
|
getIsWidgetLoading,
|
|
} from "selectors/dataTreeSelectors";
|
|
import {
|
|
getMainCanvasProps,
|
|
computeMainContainerWidget,
|
|
getChildWidgets,
|
|
getRenderMode,
|
|
previewModeSelector,
|
|
} from "selectors/editorSelectors";
|
|
import { AppState } from "@appsmith/reducers";
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
import { getWidget } from "sagas/selectors";
|
|
import {
|
|
createCanvasWidget,
|
|
createLoadingWidget,
|
|
} from "utils/widgetRenderUtils";
|
|
import { ReduxActionTypes } from "ce/constants/ReduxActionConstants";
|
|
import { checkContainersForAutoHeightAction } from "actions/autoHeightActions";
|
|
|
|
const WIDGETS_WITH_CHILD_WIDGETS = ["LIST_WIDGET", "FORM_WIDGET"];
|
|
|
|
function withWidgetProps(WrappedWidget: typeof BaseWidget) {
|
|
function WrappedPropsComponent(
|
|
props: WidgetProps & { skipWidgetPropsHydration?: boolean },
|
|
) {
|
|
const { children, skipWidgetPropsHydration, type, widgetId } = props;
|
|
const isPreviewMode = useSelector(previewModeSelector);
|
|
|
|
const canvasWidget = useSelector((state: AppState) =>
|
|
getWidget(state, widgetId),
|
|
);
|
|
const mainCanvasProps = useSelector((state: AppState) =>
|
|
getMainCanvasProps(state),
|
|
);
|
|
const renderMode = useSelector(getRenderMode);
|
|
const evaluatedWidget = useSelector((state: AppState) =>
|
|
getWidgetEvalValues(state, canvasWidget?.widgetName),
|
|
);
|
|
const isLoading = useSelector((state: AppState) =>
|
|
getIsWidgetLoading(state, canvasWidget?.widgetName),
|
|
);
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const childWidgets = useSelector((state: AppState) => {
|
|
if (!WIDGETS_WITH_CHILD_WIDGETS.includes(type)) return undefined;
|
|
return getChildWidgets(state, widgetId);
|
|
}, equal);
|
|
|
|
let widgetProps: WidgetProps = {} as WidgetProps;
|
|
|
|
if (!skipWidgetPropsHydration) {
|
|
const canvasWidgetProps = (() => {
|
|
if (widgetId === MAIN_CONTAINER_WIDGET_ID) {
|
|
return computeMainContainerWidget(canvasWidget, mainCanvasProps);
|
|
}
|
|
|
|
return evaluatedWidget
|
|
? createCanvasWidget(canvasWidget, evaluatedWidget)
|
|
: createLoadingWidget(canvasWidget);
|
|
})();
|
|
|
|
widgetProps = { ...canvasWidgetProps };
|
|
|
|
/**
|
|
* MODAL_WIDGET by default is to be hidden unless the isVisible property is found.
|
|
* If the isVisible property is undefined and the widget is MODAL_WIDGET then isVisible
|
|
* is set to false
|
|
* If the isVisible property is undefined and the widget is not MODAL_WIDGET then isVisible
|
|
* is set to true
|
|
*/
|
|
widgetProps.isVisible =
|
|
canvasWidgetProps.isVisible ??
|
|
canvasWidgetProps.type !== "MODAL_WIDGET";
|
|
|
|
if (
|
|
props.type === "CANVAS_WIDGET" &&
|
|
widgetId !== MAIN_CONTAINER_WIDGET_ID
|
|
) {
|
|
const isListWidgetCanvas =
|
|
props.noPad && props.dropDisabled && props.openParentPropertyPane;
|
|
|
|
widgetProps.rightColumn = props.rightColumn;
|
|
if (widgetProps.bottomRow === undefined || isListWidgetCanvas) {
|
|
widgetProps.bottomRow = props.bottomRow;
|
|
widgetProps.minHeight = props.minHeight;
|
|
}
|
|
widgetProps.shouldScrollContents = props.shouldScrollContents;
|
|
widgetProps.canExtend = props.canExtend;
|
|
widgetProps.parentId = props.parentId;
|
|
} else if (widgetId !== MAIN_CONTAINER_WIDGET_ID) {
|
|
widgetProps.parentColumnSpace = props.parentColumnSpace;
|
|
widgetProps.parentRowSpace = props.parentRowSpace;
|
|
widgetProps.parentId = props.parentId;
|
|
|
|
// Form Widget Props
|
|
widgetProps.onReset = props.onReset;
|
|
if ("isFormValid" in props) widgetProps.isFormValid = props.isFormValid;
|
|
}
|
|
|
|
widgetProps.children = children;
|
|
|
|
widgetProps.isLoading = isLoading;
|
|
widgetProps.childWidgets = childWidgets;
|
|
}
|
|
|
|
//merging with original props
|
|
widgetProps = { ...props, ...widgetProps, renderMode };
|
|
|
|
// isVisible prop defines whether to render a detached widget
|
|
if (widgetProps.detachFromLayout && !widgetProps.isVisible) {
|
|
return null;
|
|
}
|
|
|
|
const shouldCollapseWidgetInViewOrPreviewMode =
|
|
!widgetProps.isVisible &&
|
|
(renderMode === RenderModes.PAGE || isPreviewMode);
|
|
|
|
const shouldResetCollapsedContainerHeightInViewOrPreviewMode =
|
|
widgetProps.isVisible && widgetProps.topRow === widgetProps.bottomRow;
|
|
|
|
const shouldResetCollapsedContainerHeightInCanvasMode =
|
|
widgetProps.topRow === widgetProps.bottomRow &&
|
|
renderMode === RenderModes.CANVAS &&
|
|
!isPreviewMode;
|
|
|
|
// We don't render invisible widgets in view mode
|
|
if (shouldCollapseWidgetInViewOrPreviewMode) {
|
|
if (widgetProps.bottomRow !== widgetProps.topRow) {
|
|
dispatch({
|
|
type: ReduxActionTypes.UPDATE_WIDGET_AUTO_HEIGHT,
|
|
payload: {
|
|
widgetId: props.widgetId,
|
|
height: 0,
|
|
},
|
|
});
|
|
}
|
|
return null;
|
|
} else if (
|
|
shouldResetCollapsedContainerHeightInViewOrPreviewMode ||
|
|
shouldResetCollapsedContainerHeightInCanvasMode
|
|
) {
|
|
dispatch(checkContainersForAutoHeightAction());
|
|
}
|
|
|
|
return <WrappedWidget {...widgetProps} />;
|
|
}
|
|
|
|
return WrappedPropsComponent;
|
|
}
|
|
|
|
export default withWidgetProps;
|