* Feature: Canvas layer enhancements(DIP) * feedback fixes * fixing build * dip * dip * dip * fixing build * dip * dev fixes * dip * Fixing top bottom resize handles * dip * reposition widget name on top edges. * dip * dip * dip * dip * renaming selectedWidget to lastSelectedWidget * code clean up * Fixing list widget as per grid scale. * Fixing existing specs. * Adding migration test cases. * dip * FIxing proppane in modal. * fixing modal z-indedx. * fix for modal name. * dip * dip * dip * adding test cases for hotkeys. * dip * dip * fixing build * Trying some performance improvements for jests. * 17 mins with runinband lets try without it. * minor bug fixes. * code clean up * save migrated app on fetch. * fixing few cypress tests * fixing cypress tests * fixing cypress tests. * fixing cypress * updated DSL * Addressing code review comments. * test fails * dip * eslint fixes. * fixing debugger cypress tests. * updating latest page version. * updating migration changes to cypress dsl's. * updating chart data fixes for cypress tests. Co-authored-by: Apple <nandan@thinkify.io>
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import {
|
|
useShowPropertyPane,
|
|
useWidgetSelection,
|
|
} from "utils/hooks/dragResizeHooks";
|
|
import {
|
|
getCurrentWidgetId,
|
|
getIsPropertyPaneVisible,
|
|
} from "selectors/propertyPaneSelectors";
|
|
import { useSelector } from "store";
|
|
import { AppState } from "reducers";
|
|
import { APP_MODE } from "reducers/entityReducers/appReducer";
|
|
import { getAppMode } from "selectors/applicationSelectors";
|
|
|
|
export const useClickOpenPropPane = () => {
|
|
const showPropertyPane = useShowPropertyPane();
|
|
const { selectWidget } = useWidgetSelection();
|
|
const isPropPaneVisible = useSelector(getIsPropertyPaneVisible);
|
|
const selectedWidgetId = useSelector(getCurrentWidgetId);
|
|
const focusedWidget = useSelector(
|
|
(state: AppState) => state.ui.widgetDragResize.focusedWidget,
|
|
);
|
|
// This state tells us whether a `ResizableComponent` is resizing
|
|
const isResizing = useSelector(
|
|
(state: AppState) => state.ui.widgetDragResize.isResizing,
|
|
);
|
|
const appMode = useSelector(getAppMode);
|
|
|
|
// This state tells us whether a `DraggableComponent` is dragging
|
|
const isDragging = useSelector(
|
|
(state: AppState) => state.ui.widgetDragResize.isDragging,
|
|
);
|
|
const openPropertyPane = (e: any, targetWidgetId: string) => {
|
|
// ignore click captures if the component was resizing or dragging coz it is handled internally in draggable component
|
|
if (
|
|
isResizing ||
|
|
isDragging ||
|
|
appMode !== APP_MODE.EDIT ||
|
|
targetWidgetId !== focusedWidget
|
|
)
|
|
return;
|
|
if (
|
|
(!isPropPaneVisible && selectedWidgetId === focusedWidget) ||
|
|
selectedWidgetId !== focusedWidget
|
|
) {
|
|
const isMultiSelect = e.metaKey || e.ctrlKey;
|
|
selectWidget(focusedWidget, isMultiSelect);
|
|
showPropertyPane(focusedWidget, undefined, true);
|
|
if (isMultiSelect) {
|
|
e.stopPropagation();
|
|
}
|
|
}
|
|
};
|
|
return openPropertyPane;
|
|
};
|