2023-10-06 10:07:43 +00:00
|
|
|
import type { AppState } from "@appsmith/reducers";
|
|
|
|
|
import { createSelector } from "reselect";
|
|
|
|
|
import { getIsAppSettingsPaneWithNavigationTabOpen } from "./appSettingsPaneSelectors";
|
2023-11-03 17:13:36 +00:00
|
|
|
import {
|
|
|
|
|
combinedPreviewModeSelector,
|
|
|
|
|
snipingModeSelector,
|
|
|
|
|
} from "./editorSelectors";
|
2023-10-06 10:07:43 +00:00
|
|
|
|
|
|
|
|
export const getIsDragging = (state: AppState) =>
|
|
|
|
|
state.ui.widgetDragResize.isDragging;
|
|
|
|
|
|
|
|
|
|
export const getIsResizing = (state: AppState) =>
|
|
|
|
|
state.ui.widgetDragResize.isResizing;
|
|
|
|
|
|
|
|
|
|
export const getIsDraggingDisabledInEditor = (state: AppState) =>
|
|
|
|
|
state.ui.widgetDragResize.isDraggingDisabled;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* getShouldAllowDrag is a Selector that indicates if the widget could be dragged on canvas based on different states
|
|
|
|
|
*/
|
|
|
|
|
export const getShouldAllowDrag = createSelector(
|
|
|
|
|
getIsResizing,
|
|
|
|
|
getIsDragging,
|
|
|
|
|
getIsDraggingDisabledInEditor,
|
2023-11-03 17:13:36 +00:00
|
|
|
combinedPreviewModeSelector,
|
2023-10-06 10:07:43 +00:00
|
|
|
snipingModeSelector,
|
|
|
|
|
getIsAppSettingsPaneWithNavigationTabOpen,
|
|
|
|
|
(
|
|
|
|
|
isResizing,
|
|
|
|
|
isDragging,
|
|
|
|
|
isDraggingDisabled,
|
|
|
|
|
isPreviewMode,
|
|
|
|
|
isSnipingMode,
|
|
|
|
|
isAppSettingsPaneWithNavigationTabOpen,
|
|
|
|
|
) => {
|
|
|
|
|
return (
|
|
|
|
|
!isResizing &&
|
|
|
|
|
!isDragging &&
|
|
|
|
|
!isDraggingDisabled &&
|
|
|
|
|
!isSnipingMode &&
|
|
|
|
|
!isPreviewMode &&
|
|
|
|
|
!isAppSettingsPaneWithNavigationTabOpen
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|