2024-08-06 14:52:22 +00:00
|
|
|
import type { AppState } from "ee/reducers";
|
2023-10-06 10:07:43 +00:00
|
|
|
import { createSelector } from "reselect";
|
|
|
|
|
import { getIsAppSettingsPaneWithNavigationTabOpen } from "./appSettingsPaneSelectors";
|
2025-01-05 10:21:23 +00:00
|
|
|
import { snipingModeSelector } from "./editorSelectors";
|
2024-03-13 06:23:49 +00:00
|
|
|
import { getWidgetSelectionBlock } from "./ui";
|
2025-01-05 10:21:23 +00:00
|
|
|
import { selectCombinedPreviewMode } from "./gitModSelectors";
|
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,
|
2025-01-05 10:21:23 +00:00
|
|
|
selectCombinedPreviewMode,
|
2023-10-06 10:07:43 +00:00
|
|
|
snipingModeSelector,
|
|
|
|
|
getIsAppSettingsPaneWithNavigationTabOpen,
|
2024-03-13 06:23:49 +00:00
|
|
|
getWidgetSelectionBlock,
|
2023-10-06 10:07:43 +00:00
|
|
|
(
|
|
|
|
|
isResizing,
|
|
|
|
|
isDragging,
|
|
|
|
|
isDraggingDisabled,
|
|
|
|
|
isPreviewMode,
|
|
|
|
|
isSnipingMode,
|
|
|
|
|
isAppSettingsPaneWithNavigationTabOpen,
|
2024-03-13 06:23:49 +00:00
|
|
|
widgetSelectionIsBlocked,
|
2023-10-06 10:07:43 +00:00
|
|
|
) => {
|
|
|
|
|
return (
|
|
|
|
|
!isResizing &&
|
|
|
|
|
!isDragging &&
|
|
|
|
|
!isDraggingDisabled &&
|
|
|
|
|
!isSnipingMode &&
|
|
|
|
|
!isPreviewMode &&
|
2024-03-13 06:23:49 +00:00
|
|
|
!isAppSettingsPaneWithNavigationTabOpen &&
|
|
|
|
|
!widgetSelectionIsBlocked
|
2023-10-06 10:07:43 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|