From 7b79d139f3bea2e2d38c7ca43a906418f765e543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Grocholewski?= <m.grocholewski@atcomp.pl> Date: Fri, 17 Jan 2025 08:37:43 +0100 Subject: [PATCH 1/2] feat(map): remove raster rendering --- ...rImageObjectEditFactoryModal.component.tsx | 2 +- .../NavBar/NavBar.component.tsx | 14 -- src/components/Map/Map.component.tsx | 14 +- .../MapDrawEditActions.component.tsx | 4 +- .../MapLoader/MapLoader.component.test.tsx | 25 +-- .../Map/MapLoader/MapLoader.component.tsx | 4 +- .../Map/MapViewer/MapViewer.constants.ts | 202 ++++++++++++++++++ .../Map/MapViewer/MapViewer.types.ts | 15 ++ .../MapViewerVector.constants.ts | 201 ----------------- .../MapViewerVector/MapViewerVector.types.ts | 24 --- .../listeners/useOlMapVectorListeners.test.ts | 50 ----- .../listeners/useOlMapVectorListeners.ts | 100 --------- .../utils/config/useOlMapVectorLayers.test.ts | 85 -------- .../utils/config/useOlMapVectorLayers.ts | 21 -- .../useOlMapAdditionalLayers.test.ts | 2 +- .../useOlMapAdditionalLayers.ts | 24 +-- .../mapCardLayer/useOlMapCardLayer.test.ts | 0 .../config/mapCardLayer/useOlMapCardLayer.ts | 0 .../processLayer}/processModelElements.ts | 15 +- .../useOlMapProcessLayer.test.ts} | 4 +- .../processLayer/useOlMapProcessLayer.ts} | 26 +-- .../utils/config/useOlMapCommonLayers.test.ts | 93 -------- .../utils/config/useOlMapCommonLayers.ts | 16 -- .../utils/config/useOlMapLayers.test.ts | 28 ++- .../MapViewer/utils/config/useOlMapLayers.ts | 35 ++- .../mapSingleClick/handleReactionResults.ts | 2 +- .../mouseClick/clickHandleReaction.test.ts | 2 +- .../mouseClick/clickHandleReaction.ts | 2 +- .../getModelElementsIdsFromReaction.test.ts | 0 .../getModelElementsIdsFromReaction.ts | 0 .../leftClickHandleAlias.test.ts | 2 +- .../mouseLeftClick/leftClickHandleAlias.ts | 0 .../mouseLeftClick/onMapLeftClick.test.ts | 6 +- .../mouseLeftClick/onMapLeftClick.ts | 6 +- .../mouseRightClick/onMapRightClick.test.ts | 4 +- .../mouseRightClick/onMapRightClick.ts | 6 +- .../rightClickHandleAlias.test.ts | 2 +- .../mouseRightClick/rightClickHandleAlias.ts | 0 .../utils/listeners/useOlMapListeners.test.ts | 20 +- .../utils/listeners/useOlMapListeners.ts | 108 ++++------ .../shapes/coords/findLargestExtent.test.ts | 2 +- .../utils/shapes/coords/findLargestExtent.ts | 0 .../shapes/coords/getBezierCurve.test.ts | 0 .../utils/shapes/coords/getBezierCurve.ts | 0 .../coords/getBoundingBoxFromExtent.test.ts | 2 +- .../shapes/coords/getBoundingBoxFromExtent.ts | 2 +- .../utils/shapes/coords/getCenter.test.ts | 2 +- .../utils/shapes/coords/getCenter.ts | 0 .../utils/shapes/coords/getCoordsX.test.ts | 0 .../utils/shapes/coords/getCoordsX.ts | 0 .../utils/shapes/coords/getCoordsY.test.ts | 0 .../utils/shapes/coords/getCoordsY.ts | 0 .../shapes/coords/getCurveCoords.test.ts | 4 +- .../utils/shapes/coords/getCurveCoords.ts | 4 +- .../shapes/coords/getDividedExtents.test.ts | 2 +- .../utils/shapes/coords/getDividedExtents.ts | 0 .../shapes/coords/getEllipseCoords.test.ts | 4 +- .../utils/shapes/coords/getEllipseCoords.ts | 4 +- .../shapes/coords/getLineSegments.test.ts | 2 +- .../utils/shapes/coords/getLineSegments.ts | 0 .../shapes/coords/getPolygonCoords.test.ts | 8 +- .../utils/shapes/coords/getPolygonCoords.ts | 8 +- .../utils/shapes/coords/getRotation.test.ts | 2 +- .../utils/shapes/coords/getRotation.ts | 0 .../utils/shapes/elements/BaseMultiPolygon.ts | 19 +- .../utils/shapes/elements/Compartment.ts | 15 +- .../shapes/elements/CompartmentCircle.test.ts | 25 +-- .../shapes/elements/CompartmentCircle.ts | 11 +- .../elements/CompartmentPathway.test.ts | 25 +-- .../shapes/elements/CompartmentPathway.ts | 17 +- .../shapes/elements/CompartmentSquare.test.ts | 23 +- .../shapes/elements/CompartmentSquare.ts | 11 +- .../utils/shapes/elements/Glyph/Glyph.test.ts | 4 +- .../utils/shapes/elements/Glyph/Glyph.ts | 11 +- .../shapes/elements/Glyph/updateGlyph.ts | 0 .../utils/shapes/elements/MapElement.test.ts | 23 +- .../utils/shapes/elements/MapElement.ts | 23 +- .../shapes/elements/getArrowFeature.test.ts | 8 +- .../utils/shapes/elements/getArrowFeature.ts | 10 +- .../shapes/elements/getShapePolygon.test.ts | 6 +- .../utils/shapes/elements/getShapePolygon.ts | 6 +- .../elements/handleSemanticView.test.ts | 6 +- .../shapes/elements/handleSemanticView.ts | 8 +- .../elements/isFeatureInCompartment.test.ts | 0 .../shapes/elements/isFeatureInCompartment.ts | 0 .../elements/removeElementFromLayer.test.ts | 0 .../shapes/elements/removeElementFromLayer.ts | 0 .../utils/shapes/layer/Layer.test.ts | 17 +- .../utils/shapes/layer/Layer.ts | 21 +- .../layer/getDrawImageInteraction.test.ts | 2 +- .../shapes/layer/getDrawImageInteraction.ts | 2 +- .../getTransformImageInteraction.test.ts | 4 +- .../layer/getTransformImageInteraction.ts | 2 +- .../utils/shapes/overlay/LineOverlay.test.ts | 8 +- .../utils/shapes/overlay/LineOverlay.ts | 2 +- .../shapes/overlay/MarkerOverlay.test.ts | 8 +- .../utils/shapes/overlay/MarkerOverlay.ts | 2 +- .../overlay/areOverlayOrdersNotEqual.ts | 0 .../calculateOverlayDimensions.test.ts | 0 .../overlay/calculateOverlayDimensions.ts | 0 .../findMatchingSubmapLinkRectangle.test.ts | 0 .../findMatchingSubmapLinkRectangle.ts | 0 .../utils/shapes/overlay/getOverlays.test.ts | 0 .../utils/shapes/overlay/getOverlays.ts | 4 +- .../overlay/groupOverlayEntities.test.ts | 0 .../shapes/overlay/groupOverlayEntities.ts | 4 +- .../processOverlayGroupedElements.test.ts | 4 +- .../overlay/processOverlayGroupedElements.ts | 6 +- .../overlay/sortElementOverlayByColor.test.ts | 0 .../overlay/sortElementOverlayByColor.ts | 0 .../utils/shapes/reaction/Reaction.test.ts | 4 +- .../utils/shapes/reaction/Reaction.ts | 20 +- .../utils/shapes/style/getCoverStyles.test.ts | 8 +- .../utils/shapes/style/getCoverStyles.ts | 6 +- .../utils/shapes/style/getFill.test.ts | 0 .../utils/shapes/style/getFill.ts | 0 .../style/getScaledElementStyle.test.ts | 2 +- .../shapes/style/getScaledElementStyle.ts | 2 +- .../shapes/style/getScaledStrokeStyle.test.ts | 0 .../shapes/style/getScaledStrokeStyle.ts | 0 .../utils/shapes/style/getStroke.test.ts | 0 .../utils/shapes/style/getStroke.ts | 0 .../utils/shapes/style/getStyle.test.ts | 2 +- .../utils/shapes/style/getStyle.ts | 11 +- .../utils/shapes/style/rgbToHex.test.ts | 0 .../utils/shapes/style/rgbToHex.ts | 0 .../utils/shapes/text/Text.test.ts | 10 +- .../utils/shapes/text/Text.ts | 13 +- .../utils/shapes/text/getTextCoords.test.ts | 2 +- .../utils/shapes/text/getTextCoords.ts | 5 +- .../utils/shapes/text/getTextStyle.test.ts | 2 +- .../utils/shapes/text/getTextStyle.ts | 2 +- .../text/getWrappedTextWithFontSize.test.ts | 2 +- .../shapes/text/getWrappedTextWithFontSize.ts | 0 .../Map/MapViewer/utils/useOlMap.ts | 47 +--- src/models/mocks/modelsMock.ts | 1 - src/models/modelSchema.ts | 1 - .../fetchReactionsAndGetBioEntitiesIds.ts | 2 +- src/redux/layers/layers.reducers.ts | 3 + src/redux/models/models.reducers.ts | 13 +- src/redux/models/models.selectors.ts | 5 - src/redux/models/models.slice.ts | 8 +- 142 files changed, 592 insertions(+), 1126 deletions(-) delete mode 100644 src/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants.ts delete mode 100644 src/components/Map/MapViewer/MapViewerVector/MapViewerVector.types.ts delete mode 100644 src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.test.ts delete mode 100644 src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.ts delete mode 100644 src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.test.ts delete mode 100644 src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.ts rename src/components/Map/MapViewer/{MapViewerVector => }/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts (92%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/config/additionalLayers/useOlMapAdditionalLayers.ts (89%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/config/mapCardLayer/useOlMapCardLayer.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/config/mapCardLayer/useOlMapCardLayer.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector/utils/config/reactionsLayer => utils/config/processLayer}/processModelElements.ts (87%) rename src/components/Map/MapViewer/{MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.test.ts => utils/config/processLayer/useOlMapProcessLayer.test.ts} (79%) rename src/components/Map/MapViewer/{MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts => utils/config/processLayer/useOlMapProcessLayer.ts} (87%) delete mode 100644 src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.test.ts delete mode 100644 src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.ts rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/clickHandleReaction.test.ts (97%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/clickHandleReaction.ts (96%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/getModelElementsIdsFromReaction.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/getModelElementsIdsFromReaction.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts (96%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts (94%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts (95%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts (95%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/mouseRightClick/onMapRightClick.ts (94%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts (94%) rename src/components/Map/MapViewer/{MapViewerVector => utils}/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/findLargestExtent.test.ts (76%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/findLargestExtent.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getBezierCurve.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getBezierCurve.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getBoundingBoxFromExtent.test.ts (92%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getBoundingBoxFromExtent.ts (96%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getCenter.test.ts (81%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getCenter.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getCoordsX.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getCoordsX.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getCoordsY.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getCoordsY.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getCurveCoords.test.ts (90%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getCurveCoords.ts (85%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getDividedExtents.test.ts (94%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getDividedExtents.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getEllipseCoords.test.ts (89%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getEllipseCoords.ts (89%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getLineSegments.test.ts (97%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getLineSegments.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getPolygonCoords.test.ts (88%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getPolygonCoords.ts (76%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getRotation.test.ts (83%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/coords/getRotation.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/BaseMultiPolygon.ts (91%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/Compartment.ts (89%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/CompartmentCircle.test.ts (78%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/CompartmentCircle.ts (87%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/CompartmentPathway.test.ts (78%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/CompartmentPathway.ts (83%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/CompartmentSquare.test.ts (79%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/CompartmentSquare.ts (87%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/Glyph/Glyph.test.ts (93%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/Glyph/Glyph.ts (95%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/Glyph/updateGlyph.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/MapElement.test.ts (80%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/MapElement.ts (91%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/getArrowFeature.test.ts (89%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/getArrowFeature.ts (80%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/getShapePolygon.test.ts (94%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/getShapePolygon.ts (78%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/handleSemanticView.test.ts (89%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/handleSemanticView.ts (86%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/isFeatureInCompartment.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/isFeatureInCompartment.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/removeElementFromLayer.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/elements/removeElementFromLayer.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/layer/Layer.test.ts (84%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/layer/Layer.ts (92%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/layer/getDrawImageInteraction.test.ts (96%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/layer/getDrawImageInteraction.ts (97%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/layer/getTransformImageInteraction.test.ts (92%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/layer/getTransformImageInteraction.ts (98%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/LineOverlay.test.ts (78%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/LineOverlay.ts (96%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/MarkerOverlay.test.ts (79%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/MarkerOverlay.ts (96%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/areOverlayOrdersNotEqual.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/calculateOverlayDimensions.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/calculateOverlayDimensions.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/findMatchingSubmapLinkRectangle.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/findMatchingSubmapLinkRectangle.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/getOverlays.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/getOverlays.ts (83%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/groupOverlayEntities.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/groupOverlayEntities.ts (88%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/processOverlayGroupedElements.test.ts (92%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/processOverlayGroupedElements.ts (87%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/sortElementOverlayByColor.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/overlay/sortElementOverlayByColor.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/reaction/Reaction.test.ts (94%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/reaction/Reaction.ts (92%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getCoverStyles.test.ts (87%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getCoverStyles.ts (86%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getFill.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getFill.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getScaledElementStyle.test.ts (92%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getScaledElementStyle.ts (76%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getScaledStrokeStyle.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getScaledStrokeStyle.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getStroke.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getStroke.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getStyle.test.ts (94%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/getStyle.ts (65%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/rgbToHex.test.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/style/rgbToHex.ts (100%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/text/Text.test.ts (80%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/text/Text.ts (84%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/text/getTextCoords.test.ts (85%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/text/getTextCoords.ts (89%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/text/getTextStyle.test.ts (88%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/text/getTextStyle.ts (95%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/text/getWrappedTextWithFontSize.test.ts (95%) rename src/components/Map/MapViewer/{MapViewerVector => }/utils/shapes/text/getWrappedTextWithFontSize.ts (100%) diff --git a/src/components/FunctionalArea/Modal/LayerImageObjectModal/LayerImageObjectEditFactoryModal.component.tsx b/src/components/FunctionalArea/Modal/LayerImageObjectModal/LayerImageObjectEditFactoryModal.component.tsx index 3e8d27b6..655bb8d9 100644 --- a/src/components/FunctionalArea/Modal/LayerImageObjectModal/LayerImageObjectEditFactoryModal.component.tsx +++ b/src/components/FunctionalArea/Modal/LayerImageObjectModal/LayerImageObjectEditFactoryModal.component.tsx @@ -14,7 +14,7 @@ import { showToast } from '@/utils/showToast'; import { closeModal } from '@/redux/modal/modal.slice'; import { SerializedError } from '@reduxjs/toolkit'; import { useMapInstance } from '@/utils/context/mapInstanceContext'; -import updateGlyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/updateGlyph'; +import updateGlyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/updateGlyph'; import { mapEditToolsSetLayerObject } from '@/redux/mapEditTools/mapEditTools.slice'; export const LayerImageObjectEditFactoryModal: React.FC = () => { diff --git a/src/components/FunctionalArea/NavBar/NavBar.component.tsx b/src/components/FunctionalArea/NavBar/NavBar.component.tsx index edd14170..eafb96e3 100644 --- a/src/components/FunctionalArea/NavBar/NavBar.component.tsx +++ b/src/components/FunctionalArea/NavBar/NavBar.component.tsx @@ -11,16 +11,11 @@ import { store } from '@/redux/store'; import Image from 'next/image'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { projectIdSelector } from '@/redux/project/project.selectors'; -import { Switch } from '@/shared/Switch'; -import { currentModelIdSelector, vectorRenderingSelector } from '@/redux/models/models.selectors'; -import { setModelVectorRendering } from '@/redux/models/models.slice'; export const NavBar = (): JSX.Element => { const dispatch = useAppDispatch(); const projectId = useAppSelector(projectIdSelector); - const vectorRendering = useAppSelector(vectorRenderingSelector); - const currentModelId = useAppSelector(currentModelIdSelector); const toggleDrawerInfo = (): void => { if (store.getState().drawer.isOpen && store.getState().drawer.drawerName === 'project-info') { @@ -91,15 +86,6 @@ export const NavBar = (): JSX.Element => { <IconButton icon="legend" onClick={toggleDrawerLegend} title="Legend" /> </div> </div> - <div className="flex flex-col items-center gap-[10px] text-center text-[12px]"> - <span>Vector rendering</span> - <Switch - isChecked={vectorRendering} - onToggle={value => - dispatch(setModelVectorRendering({ vectorRendering: value, mapId: currentModelId })) - } - /> - </div> <div className="flex flex-col items-center gap-[20px]" data-testid="nav-logos-and-powered-by"> <a href="https://www.uni.lu/en/" target="_blank"> <Image diff --git a/src/components/Map/Map.component.tsx b/src/components/Map/Map.component.tsx index 0a57b1fb..df0e5eac 100644 --- a/src/components/Map/Map.component.tsx +++ b/src/components/Map/Map.component.tsx @@ -6,16 +6,13 @@ import { MapLoader } from '@/components/Map/MapLoader/MapLoader.component'; import { MapVectorBackgroundSelector } from '@/components/Map/MapVectorBackgroundSelector/MapVectorBackgroundSelector.component'; import { MapActiveLayerSelector } from '@/components/Map/MapActiveLayerSelector/MapActiveLayerSelector.component'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { vectorRenderingSelector } from '@/redux/models/models.selectors'; import { MapAdditionalLogos } from '@/components/Map/MapAdditionalLogos'; import { MapDrawActions } from '@/components/Map/MapDrawActions/MapDrawActions.component'; import { layersActiveLayerSelector } from '@/redux/layers/layers.selectors'; import { MapAdditionalActions } from './MapAdditionalActions'; -import { MapAdditionalOptions } from './MapAdditionalOptions'; import { PluginsDrawer } from './PluginsDrawer'; export const Map = (): JSX.Element => { - const vectorRendering = useAppSelector(vectorRenderingSelector); const activeLayer = useAppSelector(layersActiveLayerSelector); return ( @@ -24,14 +21,9 @@ export const Map = (): JSX.Element => { data-testid="map-container" > <MapViewer /> - {!vectorRendering && <MapAdditionalOptions />} - {vectorRendering && ( - <> - <MapVectorBackgroundSelector /> - <MapActiveLayerSelector /> - {activeLayer && <MapDrawActions />} - </> - )} + <MapVectorBackgroundSelector /> + <MapActiveLayerSelector /> + {activeLayer && <MapDrawActions />} <Drawer /> <PluginsDrawer /> <Legend /> diff --git a/src/components/Map/MapDrawActions/MapDrawEditActions.component.tsx b/src/components/Map/MapDrawActions/MapDrawEditActions.component.tsx index 1782e00e..01ebfff1 100644 --- a/src/components/Map/MapDrawActions/MapDrawEditActions.component.tsx +++ b/src/components/Map/MapDrawActions/MapDrawEditActions.component.tsx @@ -10,12 +10,12 @@ import { layersActiveLayerSelector } from '@/redux/layers/layers.selectors'; import { layerDeleteImage, layerUpdateImage } from '@/redux/layers/layers.slice'; import { useMapInstance } from '@/utils/context/mapInstanceContext'; import { mapEditToolsSetLayerObject } from '@/redux/mapEditTools/mapEditTools.slice'; -import updateGlyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/updateGlyph'; +import updateGlyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/updateGlyph'; import QuestionModal from '@/components/FunctionalArea/Modal/QuestionModal/QustionModal.component'; import { useState } from 'react'; import { showToast } from '@/utils/showToast'; import { SerializedError } from '@reduxjs/toolkit'; -import removeElementFromLayer from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer'; +import removeElementFromLayer from '@/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer'; type MapDrawEditActionsComponentProps = { toggleMapEditAction: () => void; diff --git a/src/components/Map/MapLoader/MapLoader.component.test.tsx b/src/components/Map/MapLoader/MapLoader.component.test.tsx index eb35db6b..7f8fb00b 100644 --- a/src/components/Map/MapLoader/MapLoader.component.test.tsx +++ b/src/components/Map/MapLoader/MapLoader.component.test.tsx @@ -9,7 +9,6 @@ import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { newReactionsLoadingSelector } from '@/redux/newReactions/newReactions.selectors'; import { modelElementsLoadingSelector } from '@/redux/modelElements/modelElements.selector'; import { isDrawerOpenSelector } from '@/redux/drawer/drawer.selectors'; -import { vectorRenderingSelector } from '@/redux/models/models.selectors'; import { arrowTypesLoadingSelector, bioShapesLoadingSelector, @@ -50,7 +49,6 @@ describe('MapLoader', () => { const selectorMap = new Map<SelectorFunction, string | boolean>([ [newReactionsLoadingSelector, 'succeeded'], [modelElementsLoadingSelector, 'succeeded'], - [vectorRenderingSelector, true], [bioShapesLoadingSelector, 'succeeded'], [lineTypesLoadingSelector, 'succeeded'], [arrowTypesLoadingSelector, 'succeeded'], @@ -65,12 +63,11 @@ describe('MapLoader', () => { expect(screen.queryByTestId('loading-indicator')).not.toBeInTheDocument(); }); - it('should render the LoadingIndicator when vectorRendering is true and data is loading', () => { + it('should render the LoadingIndicator when data is loading', () => { mockUseAppSelector.mockImplementation(selector => { const selectorMap = new Map<SelectorFunction, string | boolean>([ [newReactionsLoadingSelector, 'pending'], [modelElementsLoadingSelector, 'succeeded'], - [vectorRenderingSelector, true], [bioShapesLoadingSelector, 'succeeded'], [lineTypesLoadingSelector, 'succeeded'], [arrowTypesLoadingSelector, 'succeeded'], @@ -84,24 +81,4 @@ describe('MapLoader', () => { expect(screen.queryByTestId('loading-indicator')).toBeInTheDocument(); }); - - it('should not render the LoadingIndicator when vectorRendering is false even when data is loading', () => { - mockUseAppSelector.mockImplementation(selector => { - const selectorMap = new Map<SelectorFunction, string | boolean>([ - [newReactionsLoadingSelector, 'pending'], - [modelElementsLoadingSelector, 'succeeded'], - [vectorRenderingSelector, false], - [bioShapesLoadingSelector, 'succeeded'], - [lineTypesLoadingSelector, 'succeeded'], - [arrowTypesLoadingSelector, 'succeeded'], - [layersLoadingSelector, 'succeeded'], - [isDrawerOpenSelector, false], - ]); - - return selectorMap.get(selector) ?? false; - }); - renderComponent(); - - expect(screen.queryByTestId('loading-indicator')).not.toBeInTheDocument(); - }); }); diff --git a/src/components/Map/MapLoader/MapLoader.component.tsx b/src/components/Map/MapLoader/MapLoader.component.tsx index fc457e0b..a521a7f5 100644 --- a/src/components/Map/MapLoader/MapLoader.component.tsx +++ b/src/components/Map/MapLoader/MapLoader.component.tsx @@ -2,7 +2,6 @@ import { LoadingIndicator } from '@/shared/LoadingIndicator'; import { useMemo } from 'react'; import { newReactionsLoadingSelector } from '@/redux/newReactions/newReactions.selectors'; import { modelElementsLoadingSelector } from '@/redux/modelElements/modelElements.selector'; -import { vectorRenderingSelector } from '@/redux/models/models.selectors'; import { arrowTypesLoadingSelector, bioShapesLoadingSelector, @@ -16,7 +15,6 @@ import { useAppSelector } from '@/redux/hooks/useAppSelector'; export const MapLoader = (): JSX.Element => { const reactionsFetching = useAppSelector(newReactionsLoadingSelector); const modelElementsFetching = useAppSelector(modelElementsLoadingSelector); - const vectorRendering = useAppSelector(vectorRenderingSelector); const bioShapesFetching = useAppSelector(bioShapesLoadingSelector); const lineTypesFetching = useAppSelector(lineTypesLoadingSelector); const arrowTypesFetching = useAppSelector(arrowTypesLoadingSelector); @@ -44,7 +42,7 @@ export const MapLoader = (): JSX.Element => { return ( <div className={`map-loader transition-all duration-500 ${isDrawerOpen ? 'move-right' : ''}`}> - {vectorRendering && showLoader && <LoadingIndicator width={48} height={48} />} + {showLoader && <LoadingIndicator width={48} height={48} />} </div> ); }; diff --git a/src/components/Map/MapViewer/MapViewer.constants.ts b/src/components/Map/MapViewer/MapViewer.constants.ts index 41924be9..2d047265 100644 --- a/src/components/Map/MapViewer/MapViewer.constants.ts +++ b/src/components/Map/MapViewer/MapViewer.constants.ts @@ -1 +1,203 @@ +import { Color, ShapeRelAbs, ShapeRelAbsBezierPoint } from '@/types/models'; + export const MAP_VIEWER_ROLE = 'map-viewer'; + +export const VECTOR_MAP_LAYER_TYPE = 'vectorMapLayer'; + +export const COMPLEX_SBO_TERMS = ['SBO:0000253', 'SBO:0000297', 'SBO:0000289']; + +export const TEXT_CUTOFF_SCALE = 0.34; +export const OUTLINE_CUTOFF_SCALE = 0.18; +export const COMPLEX_CONTENTS_CUTOFF_SCALE = 0.215; +export const REACTION_ELEMENT_CUTOFF_SCALE = 0.125; + +export const WHITE_COLOR: Color = { + alpha: 255, + rgb: 16777215, +}; + +export const BLACK_COLOR: Color = { + alpha: 255, + rgb: -16777216, +}; + +export const TRANSPARENT_COLOR: Color = { + alpha: 0, + rgb: 0, +}; + +export const REACTION_ELEMENT_TYPES = { + OPERATOR: 'OPERATOR', + SQUARE: 'SQUARE', + LINE: 'LINE', + ARROW: 'ARROW', +}; + +export const MAP_ELEMENT_TYPES = { + TEXT: 'TEXT', + MODIFICATION: 'MODIFICATION', + ACTIVITY_BORDER: 'ACTIVITY_BORDER', + ENTITY: 'ENTITY', + OVERLAY: 'OVERLAY', + COMPARTMENT: 'COMPARTMENT', +}; + +export const LAYER_ELEMENT_TYPES = { + TEXT: 'TEXT', + OVAL: 'OVAL', + RECT: 'RECT', + LINE: 'LINE', + ARROW: 'ARROW', +}; + +export const COMPARTMENT_SQUARE_POINTS: Array<ShapeRelAbs | ShapeRelAbsBezierPoint> = [ + { + type: 'REL_ABS_POINT', + absoluteX: 10.0, + absoluteY: 0.0, + relativeX: 0.0, + relativeY: 0.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_POINT', + absoluteX: -10.0, + absoluteY: 0.0, + relativeX: 100.0, + relativeY: 0.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_BEZIER_POINT', + absoluteX1: 0.0, + absoluteY1: 10.0, + relativeX1: 100.0, + relativeY1: 0.0, + relativeHeightForX1: null, + relativeWidthForY1: null, + absoluteX2: -5.0, + absoluteY2: 0.0, + relativeX2: 100.0, + relativeY2: 0.0, + relativeHeightForX2: null, + relativeWidthForY2: null, + absoluteX3: 0.0, + absoluteY3: 5.0, + relativeX3: 100.0, + relativeY3: 0.0, + relativeHeightForX3: null, + relativeWidthForY3: null, + }, + { + type: 'REL_ABS_POINT', + absoluteX: 0.0, + absoluteY: -10.0, + relativeX: 100.0, + relativeY: 100.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_BEZIER_POINT', + absoluteX1: -10.0, + absoluteY1: 0.0, + relativeX1: 100.0, + relativeY1: 100.0, + relativeHeightForX1: null, + relativeWidthForY1: null, + absoluteX2: 0.0, + absoluteY2: -5.0, + relativeX2: 100.0, + relativeY2: 100.0, + relativeHeightForX2: null, + relativeWidthForY2: null, + absoluteX3: -5.0, + absoluteY3: 0.0, + relativeX3: 100.0, + relativeY3: 100.0, + relativeHeightForX3: null, + relativeWidthForY3: null, + }, + { + type: 'REL_ABS_POINT', + absoluteX: 10.0, + absoluteY: 0.0, + relativeX: 0.0, + relativeY: 100.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_BEZIER_POINT', + absoluteX1: 0.0, + absoluteY1: -10.0, + relativeX1: 0.0, + relativeY1: 100.0, + relativeHeightForX1: null, + relativeWidthForY1: null, + absoluteX2: 5.0, + absoluteY2: 0.0, + relativeX2: 0.0, + relativeY2: 100.0, + relativeHeightForX2: null, + relativeWidthForY2: null, + absoluteX3: 0.0, + absoluteY3: -5.0, + relativeX3: 0.0, + relativeY3: 100.0, + relativeHeightForX3: null, + relativeWidthForY3: null, + }, + { + type: 'REL_ABS_POINT', + absoluteX: 0.0, + absoluteY: 10.0, + relativeX: 0.0, + relativeY: 0.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_BEZIER_POINT', + absoluteX1: 10.0, + absoluteY1: 0.0, + relativeX1: 0.0, + relativeY1: 0.0, + relativeHeightForX1: null, + relativeWidthForY1: null, + absoluteX2: 0.0, + absoluteY2: 5.0, + relativeX2: 0.0, + relativeY2: 0.0, + relativeHeightForX2: null, + relativeWidthForY2: null, + absoluteX3: 5.0, + absoluteY3: 0.0, + relativeX3: 0.0, + relativeY3: 0.0, + relativeHeightForX3: null, + relativeWidthForY3: null, + }, +]; + +export const COMPARTMENT_CIRCLE_CENTER: ShapeRelAbs = { + type: 'REL_ABS_POINT', + absoluteX: 0.0, + absoluteY: 0.0, + relativeX: 50.0, + relativeY: 50.0, + relativeHeightForX: null, + relativeWidthForY: null, +}; + +export const COMPARTMENT_CIRCLE_RADIUS: ShapeRelAbs = { + type: 'REL_ABS_RADIUS', + absoluteX: 0.0, + absoluteY: 0.0, + relativeX: 50.0, + relativeY: 50.0, + relativeHeightForX: null, + relativeWidthForY: null, +}; diff --git a/src/components/Map/MapViewer/MapViewer.types.ts b/src/components/Map/MapViewer/MapViewer.types.ts index f6750e5c..f10c9070 100644 --- a/src/components/Map/MapViewer/MapViewer.types.ts +++ b/src/components/Map/MapViewer/MapViewer.types.ts @@ -1,7 +1,22 @@ import View from 'ol/View'; import BaseLayer from 'ol/layer/Base'; +import { OverlayBioEntityRender } from '@/types/OLrendering'; export type MapConfig = { view: View; layers: BaseLayer[]; }; + +export type VerticalAlign = 'TOP' | 'MIDDLE' | 'BOTTOM'; +export type HorizontalAlign = 'LEFT' | 'RIGHT' | 'CENTER' | 'END' | 'START'; + +export type OverlayBioEntityGroupedElementsType = { + [id: string]: Array<OverlayBioEntityRender & { amount: number }>; +}; + +export type BoundingBox = { + x: number; + y: number; + width: number; + height: number; +}; diff --git a/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants.ts b/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants.ts deleted file mode 100644 index 614d3dcf..00000000 --- a/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants.ts +++ /dev/null @@ -1,201 +0,0 @@ -import { Color, ShapeRelAbs, ShapeRelAbsBezierPoint } from '@/types/models'; - -export const VECTOR_MAP_LAYER_TYPE = 'vectorMapLayer'; - -export const COMPLEX_SBO_TERMS = ['SBO:0000253', 'SBO:0000297', 'SBO:0000289']; - -export const TEXT_CUTOFF_SCALE = 0.34; -export const OUTLINE_CUTOFF_SCALE = 0.18; -export const COMPLEX_CONTENTS_CUTOFF_SCALE = 0.215; -export const REACTION_ELEMENT_CUTOFF_SCALE = 0.125; - -export const WHITE_COLOR: Color = { - alpha: 255, - rgb: 16777215, -}; - -export const BLACK_COLOR: Color = { - alpha: 255, - rgb: -16777216, -}; - -export const TRANSPARENT_COLOR: Color = { - alpha: 0, - rgb: 0, -}; - -export const REACTION_ELEMENT_TYPES = { - OPERATOR: 'OPERATOR', - SQUARE: 'SQUARE', - LINE: 'LINE', - ARROW: 'ARROW', -}; - -export const MAP_ELEMENT_TYPES = { - TEXT: 'TEXT', - MODIFICATION: 'MODIFICATION', - ACTIVITY_BORDER: 'ACTIVITY_BORDER', - ENTITY: 'ENTITY', - OVERLAY: 'OVERLAY', - COMPARTMENT: 'COMPARTMENT', -}; - -export const LAYER_ELEMENT_TYPES = { - TEXT: 'TEXT', - OVAL: 'OVAL', - RECT: 'RECT', - LINE: 'LINE', - ARROW: 'ARROW', -}; - -export const COMPARTMENT_SQUARE_POINTS: Array<ShapeRelAbs | ShapeRelAbsBezierPoint> = [ - { - type: 'REL_ABS_POINT', - absoluteX: 10.0, - absoluteY: 0.0, - relativeX: 0.0, - relativeY: 0.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_POINT', - absoluteX: -10.0, - absoluteY: 0.0, - relativeX: 100.0, - relativeY: 0.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_BEZIER_POINT', - absoluteX1: 0.0, - absoluteY1: 10.0, - relativeX1: 100.0, - relativeY1: 0.0, - relativeHeightForX1: null, - relativeWidthForY1: null, - absoluteX2: -5.0, - absoluteY2: 0.0, - relativeX2: 100.0, - relativeY2: 0.0, - relativeHeightForX2: null, - relativeWidthForY2: null, - absoluteX3: 0.0, - absoluteY3: 5.0, - relativeX3: 100.0, - relativeY3: 0.0, - relativeHeightForX3: null, - relativeWidthForY3: null, - }, - { - type: 'REL_ABS_POINT', - absoluteX: 0.0, - absoluteY: -10.0, - relativeX: 100.0, - relativeY: 100.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_BEZIER_POINT', - absoluteX1: -10.0, - absoluteY1: 0.0, - relativeX1: 100.0, - relativeY1: 100.0, - relativeHeightForX1: null, - relativeWidthForY1: null, - absoluteX2: 0.0, - absoluteY2: -5.0, - relativeX2: 100.0, - relativeY2: 100.0, - relativeHeightForX2: null, - relativeWidthForY2: null, - absoluteX3: -5.0, - absoluteY3: 0.0, - relativeX3: 100.0, - relativeY3: 100.0, - relativeHeightForX3: null, - relativeWidthForY3: null, - }, - { - type: 'REL_ABS_POINT', - absoluteX: 10.0, - absoluteY: 0.0, - relativeX: 0.0, - relativeY: 100.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_BEZIER_POINT', - absoluteX1: 0.0, - absoluteY1: -10.0, - relativeX1: 0.0, - relativeY1: 100.0, - relativeHeightForX1: null, - relativeWidthForY1: null, - absoluteX2: 5.0, - absoluteY2: 0.0, - relativeX2: 0.0, - relativeY2: 100.0, - relativeHeightForX2: null, - relativeWidthForY2: null, - absoluteX3: 0.0, - absoluteY3: -5.0, - relativeX3: 0.0, - relativeY3: 100.0, - relativeHeightForX3: null, - relativeWidthForY3: null, - }, - { - type: 'REL_ABS_POINT', - absoluteX: 0.0, - absoluteY: 10.0, - relativeX: 0.0, - relativeY: 0.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_BEZIER_POINT', - absoluteX1: 10.0, - absoluteY1: 0.0, - relativeX1: 0.0, - relativeY1: 0.0, - relativeHeightForX1: null, - relativeWidthForY1: null, - absoluteX2: 0.0, - absoluteY2: 5.0, - relativeX2: 0.0, - relativeY2: 0.0, - relativeHeightForX2: null, - relativeWidthForY2: null, - absoluteX3: 5.0, - absoluteY3: 0.0, - relativeX3: 0.0, - relativeY3: 0.0, - relativeHeightForX3: null, - relativeWidthForY3: null, - }, -]; - -export const COMPARTMENT_CIRCLE_CENTER: ShapeRelAbs = { - type: 'REL_ABS_POINT', - absoluteX: 0.0, - absoluteY: 0.0, - relativeX: 50.0, - relativeY: 50.0, - relativeHeightForX: null, - relativeWidthForY: null, -}; - -export const COMPARTMENT_CIRCLE_RADIUS: ShapeRelAbs = { - type: 'REL_ABS_RADIUS', - absoluteX: 0.0, - absoluteY: 0.0, - relativeX: 50.0, - relativeY: 50.0, - relativeHeightForX: null, - relativeWidthForY: null, -}; diff --git a/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.types.ts b/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.types.ts deleted file mode 100644 index 709336b1..00000000 --- a/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.types.ts +++ /dev/null @@ -1,24 +0,0 @@ -import View from 'ol/View'; -import BaseLayer from 'ol/layer/Base'; -import { OverlayBioEntityRender } from '@/types/OLrendering'; - -export type MapConfig = { - view: View; - layers: BaseLayer[]; -}; - -export type VerticalAlign = 'TOP' | 'MIDDLE' | 'BOTTOM'; -export type HorizontalAlign = 'LEFT' | 'RIGHT' | 'CENTER' | 'END' | 'START'; - -export type ScaleFunction = (resolution: number) => number; - -export type OverlayBioEntityGroupedElementsType = { - [id: string]: Array<OverlayBioEntityRender & { amount: number }>; -}; - -export type BoundingBox = { - x: number; - y: number; - width: number; - height: number; -}; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.test.ts b/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.test.ts deleted file mode 100644 index 2821fe91..00000000 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable @typescript-eslint/explicit-function-return-type */ -import { renderHook } from '@testing-library/react'; -import { View } from 'ol'; -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; -import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; -import { useOlMapVectorListeners } from '@/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners'; -import { onMapLeftClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; - -jest.mock('./mouseClick/mouseLeftClick/onMapLeftClick', () => ({ - __esModule: true, - onMapLeftClick: jest.fn(), -})); - -jest.mock('use-debounce', () => { - return { - useDebounce: () => {}, - useDebouncedCallback: () => {}, - }; -}); - -describe('useOlMapVectorListeners - util', () => { - const { Wrapper } = getReduxWrapperWithStore({ - map: { - data: { ...initialMapDataFixture }, - loading: 'succeeded', - error: { message: '', name: '' }, - openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, - }, - }); - - beforeEach(() => { - jest.clearAllMocks(); - }); - - describe('on left click event', () => { - it('should run onMapLeftClick event', () => { - const CALLED_ONCE = 1; - const view = new View(); - - renderHook(() => useOlMapVectorListeners({ mapInstance: undefined }), { - wrapper: Wrapper, - }); - view.dispatchEvent('singleclick'); - - expect(onMapLeftClick).toBeCalledTimes(CALLED_ONCE); - }); - }); -}); diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.ts b/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.ts deleted file mode 100644 index 444cf47b..00000000 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { OPTIONS } from '@/constants/map'; -import { resultDrawerOpen } from '@/redux/drawer/drawer.selectors'; -import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; -import { mapDataSizeSelector } from '@/redux/map/map.selectors'; -import { currentModelIdSelector, vectorRenderingSelector } from '@/redux/models/models.selectors'; -import { MapInstance } from '@/types/map'; -import { unByKey } from 'ol/Observable'; -import { useEffect, useRef } from 'react'; -import { useSelector } from 'react-redux'; -import { useDebouncedCallback } from 'use-debounce'; -import { allCommentsSelectorOfCurrentMap } from '@/redux/comment/comment.selectors'; -import { onMapLeftClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; -import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { Coordinate } from 'ol/coordinate'; -import { Pixel } from 'ol/pixel'; -import { onMapRightClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick'; -import { modelElementsForCurrentModelSelector } from '@/redux/modelElements/modelElements.selector'; -import { newReactionsForCurrentModelSelector } from '@/redux/newReactions/newReactions.selectors'; - -interface UseOlMapVectorListenersInput { - mapInstance: MapInstance; -} - -export const useOlMapVectorListeners = ({ mapInstance }: UseOlMapVectorListenersInput): void => { - const mapSize = useSelector(mapDataSizeSelector); - const modelId = useSelector(currentModelIdSelector); - const isResultDrawerOpen = useSelector(resultDrawerOpen); - const modelElementsForCurrentModel = useSelector(modelElementsForCurrentModelSelector); - const newReactionsForCurrentModel = useSelector(newReactionsForCurrentModelSelector); - const dispatch = useAppDispatch(); - const coordinate = useRef<Coordinate>([]); - const pixel = useRef<Pixel>([]); - - const comments = useSelector(allCommentsSelectorOfCurrentMap); - const vectorRendering = useAppSelector(vectorRenderingSelector); - - const handleMapLeftClick = useDebouncedCallback( - onMapLeftClick( - mapSize, - modelId, - dispatch, - isResultDrawerOpen, - comments, - modelElementsForCurrentModel || [], - newReactionsForCurrentModel, - ), - OPTIONS.clickPersistTime, - { leading: false }, - ); - - const handleRightClick = useDebouncedCallback( - onMapRightClick( - mapSize, - modelId, - dispatch, - modelElementsForCurrentModel || [], - newReactionsForCurrentModel, - ), - OPTIONS.clickPersistTime, - { - leading: false, - }, - ); - - useEffect(() => { - if (!mapInstance || !vectorRendering) { - return; - } - - const key = mapInstance.on('singleclick', event => - handleMapLeftClick({ coordinate: event.coordinate, pixel: event.pixel }, mapInstance), - ); - - // eslint-disable-next-line consistent-return - return () => unByKey(key); - }, [mapInstance, handleMapLeftClick, vectorRendering]); - - useEffect(() => { - if (!mapInstance || !vectorRendering) { - return; - } - - const rightClickEvent = (e: MouseEvent): Promise<void> | undefined => { - e.preventDefault(); - - coordinate.current = mapInstance.getEventCoordinate(e); - pixel.current = mapInstance.getEventPixel(e); - - return handleRightClick( - { coordinate: coordinate.current, pixel: pixel.current }, - mapInstance, - ); - }; - - mapInstance.getViewport().addEventListener('contextmenu', rightClickEvent); - - // eslint-disable-next-line consistent-return - return () => mapInstance.getViewport().removeEventListener('contextmenu', rightClickEvent); - }, [mapInstance, handleRightClick, vectorRendering]); -}; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.test.ts b/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.test.ts deleted file mode 100644 index 9ec7e614..00000000 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.test.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { MAP_DATA_INITIAL_STATE, OPENED_MAPS_INITIAL_STATE } from '@/redux/map/map.constants'; -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; -import { renderHook } from '@testing-library/react'; -import BaseLayer from 'ol/layer/Base'; -import VectorLayer from 'ol/layer/Vector'; -import React from 'react'; -import { useOlMap } from '@/components/Map/MapViewer/utils/useOlMap'; -import { useOlMapVectorLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; - -const useRefValue = { - current: null, -}; - -Object.defineProperty(useRefValue, 'current', { - get: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), - set: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), -}); - -jest.spyOn(React, 'useRef').mockReturnValue(useRefValue); - -describe('useOlMapLayers - util', () => { - const getRenderedHookResults = (): BaseLayer[] => { - const { Wrapper } = getReduxWrapperWithStore({ - map: { - data: { - ...MAP_DATA_INITIAL_STATE, - size: { - width: 256, - height: 256, - tileSize: 256, - minZoom: 1, - maxZoom: 1, - }, - position: { - initial: { - x: 256, - y: 256, - }, - last: { - x: 256, - y: 256, - }, - }, - }, - loading: 'idle', - error: { - name: '', - message: '', - }, - openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, - }, - }); - const dummyElement = document.createElement('div'); - const { result: hohResult } = renderHook(() => useOlMap({ target: dummyElement }), { - wrapper: Wrapper, - }); - - const { result } = renderHook( - () => useOlMapVectorLayers({ mapInstance: hohResult.current.mapInstance }), - { - wrapper: Wrapper, - }, - ); - return result.current; - }; - - it('should return valid VectorLayer instance [1]', () => { - const result = getRenderedHookResults(); - expect(result[0]).toBeInstanceOf(VectorLayer); - expect(result[0].getSourceState()).toBe('ready'); - }); -}); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.ts b/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.ts deleted file mode 100644 index 253c3a38..00000000 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { MapInstance } from '@/types/map'; -import { useOlMapAdditionalLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers'; -import { useMemo } from 'react'; -import { useOlMapCardLayer } from '@/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer'; -import { useOlMapReactionsLayer } from './reactionsLayer/useOlMapReactionsLayer'; -import { MapConfig } from '../../MapViewerVector.types'; - -interface UseOlMapLayersInput { - mapInstance: MapInstance; -} - -export const useOlMapVectorLayers = ({ mapInstance }: UseOlMapLayersInput): MapConfig['layers'] => { - const reactionsLayer = useOlMapReactionsLayer({ mapInstance }); - const additionalLayers = useOlMapAdditionalLayers(mapInstance); - const mapCardLayer = useOlMapCardLayer(); - - return useMemo(() => { - return [mapCardLayer, reactionsLayer, ...additionalLayers]; - }, [mapCardLayer, reactionsLayer, additionalLayers]); -}; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts rename to src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts index 68151ba0..eba9fde5 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts +++ b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts @@ -5,7 +5,7 @@ import VectorLayer from 'ol/layer/Vector'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; import { BACKGROUND_INITIAL_STATE_MOCK } from '@/redux/backgrounds/background.mock'; import { Map } from 'ol'; -import { useOlMapAdditionalLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers'; +import { useOlMapAdditionalLayers } from '@/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers'; describe('useOlMapAdditionalLayers - util', () => { it('should return VectorLayer', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.ts b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.ts rename to src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.ts index 01518c93..537df192 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.ts +++ b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.ts @@ -4,7 +4,7 @@ import VectorLayer from 'ol/layer/Vector'; import VectorSource from 'ol/source/Vector'; import { useEffect, useMemo, useState } from 'react'; import { useSelector } from 'react-redux'; -import { currentModelIdSelector, vectorRenderingSelector } from '@/redux/models/models.selectors'; +import { currentModelIdSelector } from '@/redux/models/models.selectors'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { getLayersForModel } from '@/redux/layers/layers.thunks'; import { @@ -17,16 +17,16 @@ import { usePointToProjection } from '@/utils/map/usePointToProjection'; import { MapInstance } from '@/types/map'; import { Geometry, LineString, MultiPolygon, Point } from 'ol/geom'; import Polygon from 'ol/geom/Polygon'; -import Layer from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer'; +import Layer from '@/components/Map/MapViewer/utils/shapes/layer/Layer'; import { arrowTypesSelector, lineTypesSelector } from '@/redux/shapes/shapes.selectors'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { mapDataSizeSelector } from '@/redux/map/map.selectors'; -import getDrawImageInteraction from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction'; +import getDrawImageInteraction from '@/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction'; import { LayerState } from '@/redux/layers/layers.types'; import { mapEditToolsActiveActionSelector } from '@/redux/mapEditTools/mapEditTools.selectors'; import { MAP_EDIT_ACTIONS } from '@/redux/mapEditTools/mapEditTools.constants'; import { Extent } from 'ol/extent'; -import getTransformImageInteraction from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction'; +import getTransformImageInteraction from '@/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction'; import { mapEditToolsSetLayerObject } from '@/redux/mapEditTools/mapEditTools.slice'; export const useOlMapAdditionalLayers = ( @@ -45,7 +45,6 @@ export const useOlMapAdditionalLayers = ( const layersLoading = useAppSelector(layersLoadingSelector); const layersVisibilityForCurrentModel = useAppSelector(layersVisibilityForCurrentModelSelector); const activeLayer = useAppSelector(layersActiveLayerSelector); - const vectorRendering = useAppSelector(vectorRenderingSelector); const [layersState, setLayersState] = useState<Array<LayerState>>([]); const [layersLoadingState, setLayersLoadingState] = useState(false); @@ -164,7 +163,7 @@ export const useOlMapAdditionalLayers = ( if (!transformInteraction) { return () => {}; } - if (!activeLayer || !vectorRendering || activeAction !== MAP_EDIT_ACTIONS.TRANSFORM_IMAGE) { + if (!activeLayer || activeAction !== MAP_EDIT_ACTIONS.TRANSFORM_IMAGE) { return () => {}; } mapInstance?.addInteraction(transformInteraction); @@ -172,25 +171,18 @@ export const useOlMapAdditionalLayers = ( dispatch(mapEditToolsSetLayerObject(null)); mapInstance?.removeInteraction(transformInteraction); }; - }, [activeAction, activeLayer, dispatch, mapInstance, transformInteraction, vectorRendering]); + }, [activeAction, activeLayer, dispatch, mapInstance, transformInteraction]); useEffect(() => { if (!drawImageInteraction) { return; } mapInstance?.removeInteraction(drawImageInteraction); - if (!activeLayer || !vectorRendering || activeAction !== MAP_EDIT_ACTIONS.DRAW_IMAGE) { + if (!activeLayer || activeAction !== MAP_EDIT_ACTIONS.DRAW_IMAGE) { return; } mapInstance?.addInteraction(drawImageInteraction); - }, [ - activeAction, - activeLayer, - currentModelId, - drawImageInteraction, - mapInstance, - vectorRendering, - ]); + }, [activeAction, activeLayer, currentModelId, drawImageInteraction, mapInstance]); return vectorLayers; }; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer.test.ts b/src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer.test.ts rename to src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer.ts b/src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer.ts rename to src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements.ts b/src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements.ts rename to src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts index d832a64b..25aa2078 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements.ts +++ b/src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts @@ -1,13 +1,5 @@ import { ModelElement } from '@/types/models'; -import MapElement from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement'; -import CompartmentCircle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle'; -import CompartmentSquare from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare'; -import CompartmentPathway from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway'; -import Glyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { MapInstance } from '@/types/map'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { BioShapesDict, LineTypeDict } from '@/redux/shapes/shapes.types'; @@ -16,6 +8,11 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import Glyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph'; +import CompartmentPathway from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway'; +import CompartmentSquare from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare'; +import CompartmentCircle from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle'; +import MapElement from '@/components/Map/MapViewer/utils/shapes/elements/MapElement'; export default function processModelElements( modelElements: Array<ModelElement>, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.test.ts b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts similarity index 79% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.test.ts rename to src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts index b54a29b4..c8e961ed 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.test.ts +++ b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts @@ -4,7 +4,7 @@ import VectorLayer from 'ol/layer/Vector'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; import { BACKGROUND_INITIAL_STATE_MOCK } from '@/redux/backgrounds/background.mock'; import { Map } from 'ol'; -import { useOlMapReactionsLayer } from '@/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer'; +import { useOlMapProcessLayer } from '@/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer'; describe('useOlMapReactionsLayer - util', () => { it('should return VectorLayer', () => { @@ -15,7 +15,7 @@ describe('useOlMapReactionsLayer - util', () => { const dummyElement = document.createElement('div'); const mapInstance = new Map({ target: dummyElement }); - const { result } = renderHook(() => useOlMapReactionsLayer({ mapInstance }), { + const { result } = renderHook(() => useOlMapProcessLayer({ mapInstance }), { wrapper: Wrapper, }); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts rename to src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts index fd83ac6f..09d5b04e 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts +++ b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts @@ -4,7 +4,6 @@ import VectorLayer from 'ol/layer/Vector'; import VectorSource from 'ol/source/Vector'; import { useEffect, useMemo, useState } from 'react'; import { usePointToProjection } from '@/utils/map/usePointToProjection'; -import MapElement from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement'; import { useSelector } from 'react-redux'; import { arrowTypesSelector, @@ -19,17 +18,12 @@ import { import { currentModelIdSelector } from '@/redux/models/models.selectors'; import { getModelElementsForModel } from '@/redux/modelElements/modelElements.thunks'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; -import CompartmentSquare from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare'; -import CompartmentCircle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle'; -import Glyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph'; -import CompartmentPathway from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway'; -import Reaction from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction'; import { newReactionsForCurrentModelSelector, newReactionsLoadingSelector, } from '@/redux/newReactions/newReactions.selectors'; import { getNewReactionsForModel } from '@/redux/newReactions/newReactions.thunks'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; import { getOverlayOrderSelector, overlayBioEntitiesForCurrentModelSelector, @@ -37,21 +31,27 @@ import { import { groupBy } from '@/utils/array/groupBy'; import { useGetOverlayColor } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import getOverlays from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays'; -import LineOverlay from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay'; import { markersSufraceOfCurrentMapDataSelector } from '@/redux/markers/markers.selectors'; import { parseSurfaceMarkersToBioEntityRender } from '@/components/Map/MapViewer/utils/config/overlaysLayer/parseSurfaceMarkersToBioEntityRender'; -import MarkerOverlay from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay'; -import processModelElements from '@/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements'; +import processModelElements from '@/components/Map/MapViewer/utils/config/processLayer/processModelElements'; import useDebouncedValue from '@/utils/useDebouncedValue'; import { mapBackgroundTypeSelector, mapDataSizeSelector } from '@/redux/map/map.selectors'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { setMapBackgroundType } from '@/redux/map/map.slice'; import { ZOOM_RESCALING_FACTOR } from '@/constants/map'; import { OverlayOrder } from '@/redux/overlayBioEntity/overlayBioEntity.utils'; -import areOverlayOrdersNotEqual from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/areOverlayOrdersNotEqual'; +import MarkerOverlay from '@/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay'; +import LineOverlay from '@/components/Map/MapViewer/utils/shapes/overlay/LineOverlay'; +import getOverlays from '@/components/Map/MapViewer/utils/shapes/overlay/getOverlays'; +import Reaction from '@/components/Map/MapViewer/utils/shapes/reaction/Reaction'; +import CompartmentPathway from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway'; +import Glyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph'; +import CompartmentCircle from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle'; +import CompartmentSquare from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare'; +import MapElement from '@/components/Map/MapViewer/utils/shapes/elements/MapElement'; +import areOverlayOrdersNotEqual from '@/components/Map/MapViewer/utils/shapes/overlay/areOverlayOrdersNotEqual'; -export const useOlMapReactionsLayer = ({ +export const useOlMapProcessLayer = ({ mapInstance, }: { mapInstance: MapInstance; diff --git a/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.test.ts b/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.test.ts deleted file mode 100644 index b3117b1f..00000000 --- a/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.test.ts +++ /dev/null @@ -1,93 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { MAP_DATA_INITIAL_STATE, OPENED_MAPS_INITIAL_STATE } from '@/redux/map/map.constants'; -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; -import { renderHook } from '@testing-library/react'; -import BaseLayer from 'ol/layer/Base'; -import React from 'react'; -import VectorLayer from 'ol/layer/Vector'; -import { useOlMapCommonLayers } from '@/components/Map/MapViewer/utils/config/useOlMapCommonLayers'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; - -const useRefValue = { - current: null, -}; - -Object.defineProperty(useRefValue, 'current', { - get: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), - set: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), -}); - -jest.spyOn(React, 'useRef').mockReturnValue(useRefValue); - -describe('useOlMapCommonLayers - util', () => { - const getRenderedHookResults = (): BaseLayer[] => { - const { Wrapper } = getReduxWrapperWithStore({ - map: { - data: { - ...MAP_DATA_INITIAL_STATE, - size: { - width: 256, - height: 256, - tileSize: 256, - minZoom: 1, - maxZoom: 1, - }, - position: { - initial: { - x: 256, - y: 256, - }, - last: { - x: 256, - y: 256, - }, - }, - }, - loading: 'idle', - error: { - name: '', - message: '', - }, - openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, - }, - }); - - const { result } = renderHook(() => useOlMapCommonLayers(), { - wrapper: Wrapper, - }); - - return result.current; - }; - - it('should return valid VectorLayer instance [1]', () => { - const result = getRenderedHookResults(); - - expect(result[0]).toBeInstanceOf(VectorLayer); - expect(result[0].getSourceState()).toBe('ready'); - }); - - it('should return valid VectorLayer instance [2]', () => { - const result = getRenderedHookResults(); - - expect(result[1]).toBeInstanceOf(VectorLayer); - expect(result[1].getSourceState()).toBe('ready'); - }); - - it('should return valid VectorLayer instance [3]', () => { - const result = getRenderedHookResults(); - - expect(result[2]).toBeInstanceOf(VectorLayer); - expect(result[2].getSourceState()).toBe('ready'); - }); -}); diff --git a/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.ts b/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.ts deleted file mode 100644 index ad70201b..00000000 --- a/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { useOlMapPinsLayer } from '@/components/Map/MapViewer/utils/config/pinsLayer/useOlMapPinsLayer'; -import { useOlMapReactionsLayer } from '@/components/Map/MapViewer/utils/config/reactionsLayer/useOlMapReactionsLayer'; -import { useOlMapCommentsLayer } from '@/components/Map/MapViewer/utils/config/commentsLayer/useOlMapCommentsLayer'; -import { useMemo } from 'react'; -import { MapConfig } from '../../MapViewer.types'; - -export const useOlMapCommonLayers = (): MapConfig['layers'] => { - const pinsLayer = useOlMapPinsLayer(); - const reactionsLayer = useOlMapReactionsLayer(); - const commentsLayer = useOlMapCommentsLayer(); - - return useMemo(() => { - return [pinsLayer, reactionsLayer, commentsLayer]; - }, [pinsLayer, reactionsLayer, commentsLayer]); -}; diff --git a/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts b/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts index b4bfec60..3fe8e861 100644 --- a/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts +++ b/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts @@ -3,11 +3,11 @@ import { MAP_DATA_INITIAL_STATE, OPENED_MAPS_INITIAL_STATE } from '@/redux/map/m import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { renderHook } from '@testing-library/react'; import BaseLayer from 'ol/layer/Base'; -import TileLayer from 'ol/layer/Tile'; -import React from 'react'; import VectorLayer from 'ol/layer/Vector'; +import React from 'react'; +import { useOlMap } from '@/components/Map/MapViewer/utils/useOlMap'; +import { useOlMapLayers } from '@/components/Map/MapViewer/utils/config/useOlMapLayers'; import MapBackgroundsEnum from '@/redux/map/map.enums'; -import { useOlMapLayers } from './useOlMapLayers'; const useRefValue = { current: null, @@ -63,25 +63,23 @@ describe('useOlMapLayers - util', () => { backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); - - const { result } = renderHook(() => useOlMapLayers(), { + const dummyElement = document.createElement('div'); + const { result: hohResult } = renderHook(() => useOlMap({ target: dummyElement }), { wrapper: Wrapper, }); + const { result } = renderHook( + () => useOlMapLayers({ mapInstance: hohResult.current.mapInstance }), + { + wrapper: Wrapper, + }, + ); return result.current; }; - it('should return valid TileLayer instance [1]', () => { + it('should return valid VectorLayer instance [1]', () => { const result = getRenderedHookResults(); - - expect(result[0]).toBeInstanceOf(TileLayer); + expect(result[0]).toBeInstanceOf(VectorLayer); expect(result[0].getSourceState()).toBe('ready'); }); - - it('should return valid VectorLayer instance [2]', () => { - const result = getRenderedHookResults(); - - expect(result[1]).toBeInstanceOf(VectorLayer); - expect(result[1].getSourceState()).toBe('ready'); - }); }); diff --git a/src/components/Map/MapViewer/utils/config/useOlMapLayers.ts b/src/components/Map/MapViewer/utils/config/useOlMapLayers.ts index 10169c98..ed7dc2ff 100644 --- a/src/components/Map/MapViewer/utils/config/useOlMapLayers.ts +++ b/src/components/Map/MapViewer/utils/config/useOlMapLayers.ts @@ -1,11 +1,34 @@ /* eslint-disable no-magic-numbers */ -import { useOlMapOverlaysLayer } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useOlMapOverlaysLayer'; +import { MapInstance } from '@/types/map'; +import { useOlMapAdditionalLayers } from '@/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers'; +import { useMemo } from 'react'; +import { useOlMapCardLayer } from '@/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer'; +import { useOlMapPinsLayer } from '@/components/Map/MapViewer/utils/config/pinsLayer/useOlMapPinsLayer'; +import { useOlMapReactionsLayer } from '@/components/Map/MapViewer/utils/config/reactionsLayer/useOlMapReactionsLayer'; +import { useOlMapCommentsLayer } from '@/components/Map/MapViewer/utils/config/commentsLayer/useOlMapCommentsLayer'; import { MapConfig } from '../../MapViewer.types'; -import { useOlMapTileLayer } from './useOlMapTileLayer'; +import { useOlMapProcessLayer } from './processLayer/useOlMapProcessLayer'; -export const useOlMapLayers = (): MapConfig['layers'] => { - const overlaysLayer = useOlMapOverlaysLayer(); - const tileLayer = useOlMapTileLayer(); +interface UseOlMapLayersInput { + mapInstance: MapInstance; +} - return [tileLayer, overlaysLayer]; +export const useOlMapLayers = ({ mapInstance }: UseOlMapLayersInput): MapConfig['layers'] => { + const processLayer = useOlMapProcessLayer({ mapInstance }); + const additionalLayers = useOlMapAdditionalLayers(mapInstance); + const mapCardLayer = useOlMapCardLayer(); + const pinsLayer = useOlMapPinsLayer(); + const reactionsLayer = useOlMapReactionsLayer(); + const commentsLayer = useOlMapCommentsLayer(); + + return useMemo(() => { + return [ + mapCardLayer, + processLayer, + pinsLayer, + reactionsLayer, + commentsLayer, + ...additionalLayers, + ]; + }, [mapCardLayer, processLayer, pinsLayer, reactionsLayer, commentsLayer, additionalLayers]); }; diff --git a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts index 963fc428..5631573e 100644 --- a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts +++ b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts @@ -11,7 +11,7 @@ import { apiPath } from '@/redux/apiPath'; import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; import { getMultiBioEntityByIds } from '@/redux/bioEntity/thunks/getMultiBioEntity'; import { newReactionSchema } from '@/models/newReactionSchema'; -import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction'; +import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction'; import { handleReactionSearchClickFailure } from './handleReactionSearchClickFailure'; import { findClosestReactionPoint } from './findClosestReactionPoint'; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.test.ts similarity index 97% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.test.ts index 47b21acd..d809149e 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.test.ts @@ -6,7 +6,7 @@ import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse'; import { apiPath } from '@/redux/apiPath'; import { HttpStatusCode } from 'axios'; import { bioEntityFixture } from '@/models/fixtures/bioEntityFixture'; -import { clickHandleReaction } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction'; +import { clickHandleReaction } from '@/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction'; import { newReactionFixture } from '@/models/fixtures/newReactionFixture'; const mockedAxiosClient = mockNetworkNewAPIResponse(); diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.ts index f9cbc6ac..2cd86bfa 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.ts @@ -8,7 +8,7 @@ import { setMultipleBioEntityContents } from '@/redux/bioEntity/bioEntity.slice' import { addNumbersToEntityNumberData } from '@/redux/entityNumber/entityNumber.slice'; import { setReactions } from '@/redux/reactions/reactions.slice'; import { mapReactionToBioEntity } from '@/utils/bioEntity/mapReactionToBioEntity'; -import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction'; +import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction'; import { mapModelElementToBioEntity } from '@/utils/bioEntity/mapModelElementToBioEntity'; /* prettier-ignore */ diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts index 46ca1e40..df86f0a2 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import { leftClickHandleAlias } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias'; +import { leftClickHandleAlias } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias'; import { openBioEntityDrawerById, selectTab } from '@/redux/drawer/drawer.slice'; import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; import { searchFitBounds } from '@/services/pluginsManager/map/triggerSearch/searchFitBounds'; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts index 11211b8b..2ef85495 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts @@ -5,17 +5,17 @@ import { resetReactionsData } from '@/redux/reactions/reactions.slice'; import { clearBioEntities } from '@/redux/bioEntity/bioEntity.slice'; import { handleFeaturesClick } from '@/components/Map/MapViewer/utils/listeners/mapSingleClick/handleFeaturesClick'; import Map from 'ol/Map'; -import { onMapLeftClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; +import { onMapLeftClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; import { Comment } from '@/types/models'; import SimpleGeometry from 'ol/geom/SimpleGeometry'; import { Feature } from 'ol'; import { FEATURE_TYPE } from '@/constants/features'; import VectorLayer from 'ol/layer/Vector'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; import * as leftClickHandleAlias from './leftClickHandleAlias'; import * as clickHandleReaction from '../clickHandleReaction'; -jest.mock('../../../../utils/listeners/mapSingleClick/handleFeaturesClick', () => ({ +jest.mock('../../mapSingleClick/handleFeaturesClick', () => ({ handleFeaturesClick: jest.fn(), })); jest.mock('./leftClickHandleAlias', () => ({ diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts index d9a8031c..fdca7e96 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts @@ -9,13 +9,13 @@ import { latLngToPoint } from '@/utils/map/latLngToPoint'; import { FeatureLike } from 'ol/Feature'; import { closeDrawer } from '@/redux/drawer/drawer.slice'; import { clearBioEntities } from '@/redux/bioEntity/bioEntity.slice'; -import { leftClickHandleAlias } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias'; +import { leftClickHandleAlias } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias'; import { handleFeaturesClick } from '@/components/Map/MapViewer/utils/listeners/mapSingleClick/handleFeaturesClick'; import { resetReactionsData } from '@/redux/reactions/reactions.slice'; import { handleDataReset } from '@/components/Map/MapViewer/utils/listeners/mapSingleClick/handleDataReset'; import { FEATURE_TYPE } from '@/constants/features'; -import { clickHandleReaction } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { clickHandleReaction } from '@/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; function isFeatureFilledCompartment(feature: FeatureLike): boolean { return feature.get('type') === FEATURE_TYPE.COMPARTMENT && feature.get('filled'); diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts index 4f9a3ade..fa6a3f17 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts @@ -1,7 +1,7 @@ /* eslint-disable no-magic-numbers */ import { updateLastRightClick } from '@/redux/map/map.slice'; import Map from 'ol/Map'; -import { onMapRightClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick'; +import { onMapRightClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick'; import { Layer } from 'ol/layer'; import { openContextMenu } from '@/redux/contextMenu/contextMenu.slice'; import { Source } from 'ol/source'; @@ -11,7 +11,7 @@ import { Feature } from 'ol'; import { FEATURE_TYPE } from '@/constants/features'; import { modelElementFixture } from '@/models/fixtures/modelElementFixture'; import { newReactionFixture } from '@/models/fixtures/newReactionFixture'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; import * as rightClickHandleAlias from './rightClickHandleAlias'; import * as clickHandleReaction from '../clickHandleReaction'; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.ts index 74e10fc2..9773b48e 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.ts @@ -11,9 +11,9 @@ import VectorLayer from 'ol/layer/Vector'; import VectorSource from 'ol/source/Vector'; import { openContextMenu } from '@/redux/contextMenu/contextMenu.slice'; import { ModelElement, NewReaction } from '@/types/models'; -import { rightClickHandleAlias } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias'; -import { clickHandleReaction } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { rightClickHandleAlias } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias'; +import { clickHandleReaction } from '@/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; /* prettier-ignore */ export const onMapRightClick = diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts index 2b936519..ae53b95c 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import { rightClickHandleAlias } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias'; +import { rightClickHandleAlias } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias'; import { modelElementFixture } from '@/models/fixtures/modelElementFixture'; import { setBioEntityContents } from '@/redux/bioEntity/bioEntity.slice'; import { addNumbersToEntityNumberData } from '@/redux/entityNumber/entityNumber.slice'; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.ts diff --git a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts index 94a53559..328c827b 100644 --- a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts @@ -4,18 +4,18 @@ import { View } from 'ol'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; import MapBackgroundsEnum from '@/redux/map/map.enums'; -import * as singleClickListener from './mapSingleClick/onMapSingleClick'; -import * as positionListener from './onMapPositionChange'; -import { useOlMapListeners } from './useOlMapListeners'; +import * as positionListener from '@/components/Map/MapViewer/utils/listeners/onMapPositionChange'; +import { useOlMapListeners } from '@/components/Map/MapViewer/utils/listeners/useOlMapListeners'; +import { onMapLeftClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; jest.mock('./onMapPositionChange', () => ({ __esModule: true, onMapPositionChange: jest.fn(), })); -jest.mock('./mapSingleClick/onMapSingleClick', () => ({ +jest.mock('./mouseClick/mouseLeftClick/onMapLeftClick', () => ({ __esModule: true, - onMapSingleClick: jest.fn(), + onMapLeftClick: jest.fn(), })); jest.mock('use-debounce', () => { @@ -52,15 +52,17 @@ describe('useOlMapListeners - util', () => { }); }); - describe('on singleclick view event', () => { - it('should run onMapPositionChange event', () => { + describe('on left click event', () => { + it('should run onMapLeftClick event', () => { const CALLED_ONCE = 1; const view = new View(); - renderHook(() => useOlMapListeners({ view, mapInstance: undefined }), { wrapper: Wrapper }); + renderHook(() => useOlMapListeners({ view, mapInstance: undefined }), { + wrapper: Wrapper, + }); view.dispatchEvent('singleclick'); - expect(singleClickListener.onMapSingleClick).toBeCalledTimes(CALLED_ONCE); + expect(onMapLeftClick).toBeCalledTimes(CALLED_ONCE); }); }); }); diff --git a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.ts b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.ts index e7df6b03..f2952ea6 100644 --- a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.ts +++ b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.ts @@ -1,38 +1,24 @@ -import { DEFAULT_ZOOM, OPTIONS } from '@/constants/map'; -import { searchDistanceValSelector } from '@/redux/configuration/configuration.selectors'; +import { OPTIONS } from '@/constants/map'; import { resultDrawerOpen } from '@/redux/drawer/drawer.selectors'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; -import { - mapDataLastZoomValue, - mapDataMaxZoomValue, - mapDataSizeSelector, -} from '@/redux/map/map.selectors'; -import { - currentModelSelector, - currentModelIdSelector, - vectorRenderingSelector, -} from '@/redux/models/models.selectors'; +import { mapDataSizeSelector } from '@/redux/map/map.selectors'; +import { currentModelIdSelector } from '@/redux/models/models.selectors'; import { MapInstance } from '@/types/map'; -import { View } from 'ol'; import { unByKey } from 'ol/Observable'; -import { Coordinate } from 'ol/coordinate'; -import { Pixel } from 'ol/pixel'; import { useEffect, useRef } from 'react'; import { useSelector } from 'react-redux'; import { useDebouncedCallback } from 'use-debounce'; import { allCommentsSelectorOfCurrentMap } from '@/redux/comment/comment.selectors'; -import { currentBackgroundSelector } from '@/redux/backgrounds/background.selectors'; -import { - PATHWAYS_AND_COMPARTMENTS_BACKGROUND, - SEMANTIC_BACKGROUND, -} from '@/redux/backgrounds/backgrounds.constants'; -import { TWO } from '@/constants/common'; -import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { onMapRightClick } from './mapRightClick/onMapRightClick'; -import { onMapSingleClick } from './mapSingleClick/onMapSingleClick'; -import { onMapPositionChange } from './onMapPositionChange'; -import { onPointerMove } from './onPointerMove'; -import { useHandlePinIconClick } from './pinIconClick/useHandlePinIconClick'; +import { onMapLeftClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; +import { Coordinate } from 'ol/coordinate'; +import { Pixel } from 'ol/pixel'; +import { onMapRightClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick'; +import { modelElementsForCurrentModelSelector } from '@/redux/modelElements/modelElements.selector'; +import { newReactionsForCurrentModelSelector } from '@/redux/newReactions/newReactions.selectors'; +import { useHandlePinIconClick } from '@/components/Map/MapViewer/utils/listeners/pinIconClick/useHandlePinIconClick'; +import { onMapPositionChange } from '@/components/Map/MapViewer/utils/listeners/onMapPositionChange'; +import { onPointerMove } from '@/components/Map/MapViewer/utils/listeners/onPointerMove'; +import { View } from 'ol'; interface UseOlMapListenersInput { view: View; @@ -41,36 +27,17 @@ interface UseOlMapListenersInput { export const useOlMapListeners = ({ view, mapInstance }: UseOlMapListenersInput): void => { const mapSize = useSelector(mapDataSizeSelector); - const model = useSelector(currentModelSelector); const modelId = useSelector(currentModelIdSelector); - const modelMinZoom = model?.minZoom || TWO; - const lastZoom = useSelector(mapDataLastZoomValue) || TWO; - const background = useSelector(currentBackgroundSelector); - const searchDistance = useSelector(searchDistanceValSelector); - const maxZoom = useSelector(mapDataMaxZoomValue); const isResultDrawerOpen = useSelector(resultDrawerOpen); + const modelElementsForCurrentModel = useSelector(modelElementsForCurrentModelSelector); + const newReactionsForCurrentModel = useSelector(newReactionsForCurrentModelSelector); + const dispatch = useAppDispatch(); const coordinate = useRef<Coordinate>([]); const pixel = useRef<Pixel>([]); - const dispatch = useAppDispatch(); const comments = useSelector(allCommentsSelectorOfCurrentMap); - const vectorRendering = useAppSelector(vectorRenderingSelector); - useHandlePinIconClick(); - const handleRightClick = useDebouncedCallback( - onMapRightClick( - mapSize, - modelId, - dispatch, - background?.name === SEMANTIC_BACKGROUND || - background?.name === PATHWAYS_AND_COMPARTMENTS_BACKGROUND, - lastZoom - modelMinZoom, - ), - OPTIONS.clickPersistTime, - { - leading: false, - }, - ); + useHandlePinIconClick(); const handleChangeCenter = useDebouncedCallback( onMapPositionChange(mapSize, dispatch), @@ -78,24 +45,34 @@ export const useOlMapListeners = ({ view, mapInstance }: UseOlMapListenersInput) { leading: false }, ); - const handleMapSingleClick = useDebouncedCallback( - onMapSingleClick( + const handleMapLeftClick = useDebouncedCallback( + onMapLeftClick( mapSize, modelId, dispatch, - searchDistance, - maxZoom, - lastZoom || DEFAULT_ZOOM, isResultDrawerOpen, comments, - background?.name === SEMANTIC_BACKGROUND || - background?.name === PATHWAYS_AND_COMPARTMENTS_BACKGROUND, - lastZoom - modelMinZoom, + modelElementsForCurrentModel || [], + newReactionsForCurrentModel, ), OPTIONS.clickPersistTime, { leading: false }, ); + const handleRightClick = useDebouncedCallback( + onMapRightClick( + mapSize, + modelId, + dispatch, + modelElementsForCurrentModel || [], + newReactionsForCurrentModel, + ), + OPTIONS.clickPersistTime, + { + leading: false, + }, + ); + useEffect(() => { const key = view.on('change:center', handleChangeCenter); return () => unByKey(key); @@ -113,20 +90,20 @@ export const useOlMapListeners = ({ view, mapInstance }: UseOlMapListenersInput) }, [mapInstance]); useEffect(() => { - if (!mapInstance || vectorRendering) { + if (!mapInstance) { return; } const key = mapInstance.on('singleclick', event => - handleMapSingleClick({ coordinate: event.coordinate, pixel: event.pixel }, mapInstance), + handleMapLeftClick({ coordinate: event.coordinate, pixel: event.pixel }, mapInstance), ); // eslint-disable-next-line consistent-return return () => unByKey(key); - }, [mapInstance, handleMapSingleClick, vectorRendering]); + }, [mapInstance, handleMapLeftClick]); useEffect(() => { - if (!mapInstance || vectorRendering) { + if (!mapInstance) { return; } @@ -136,12 +113,15 @@ export const useOlMapListeners = ({ view, mapInstance }: UseOlMapListenersInput) coordinate.current = mapInstance.getEventCoordinate(e); pixel.current = mapInstance.getEventPixel(e); - return handleRightClick(coordinate.current, pixel.current); + return handleRightClick( + { coordinate: coordinate.current, pixel: pixel.current }, + mapInstance, + ); }; mapInstance.getViewport().addEventListener('contextmenu', rightClickEvent); // eslint-disable-next-line consistent-return return () => mapInstance.getViewport().removeEventListener('contextmenu', rightClickEvent); - }, [mapInstance, handleRightClick, vectorRendering]); + }, [mapInstance, handleRightClick]); }; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.test.ts similarity index 76% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.test.ts index 2a41ebad..2bd23b66 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ -import findLargestExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent'; +import findLargestExtent from '@/components/Map/MapViewer/utils/shapes/coords/findLargestExtent'; import { Extent } from 'ol/extent'; describe('findLargestExtent', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.ts b/src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.ts rename to src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getBezierCurve.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getBezierCurve.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve.ts b/src/components/Map/MapViewer/utils/shapes/coords/getBezierCurve.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getBezierCurve.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.test.ts index 532c485d..7c44ef3e 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Extent } from 'ol/extent'; -import getBoundingBoxFromExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent'; +import getBoundingBoxFromExtent from '@/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent'; describe('getBoundingBoxFromExtent', () => { it('should return a bounding box for extent', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.ts b/src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.ts index efab1e2d..7201ee00 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.ts @@ -3,7 +3,7 @@ import { MapSize } from '@/redux/map/map.types'; import { toLonLat } from 'ol/proj'; import { latLngToPoint } from '@/utils/map/latLngToPoint'; import { Extent } from 'ol/extent'; -import { BoundingBox } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { BoundingBox } from '@/components/Map/MapViewer/MapViewer.types'; export default function getBoundingBoxFromExtent(extent: Extent, mapSize: MapSize): BoundingBox { const [startLng, startLat] = toLonLat([extent[0], extent[3]]); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCenter.test.ts similarity index 81% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCenter.test.ts index 6373f63b..83defeab 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getCenter.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Coordinate } from 'ol/coordinate'; -import getCenter from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter'; +import getCenter from '@/components/Map/MapViewer/utils/shapes/coords/getCenter'; describe('getCenter', () => { it('should return a center for coordinates', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCenter.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCenter.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCoordsX.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCoordsX.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCoordsX.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCoordsX.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCoordsY.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCoordsY.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCoordsY.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCoordsY.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.test.ts similarity index 90% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.test.ts index adf5685f..1c824de0 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { ShapeRelAbsBezierPoint } from '@/types/models'; import getCurveCoords from './getCurveCoords'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.ts similarity index 85% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.ts index 8cd0f0ec..e75d72f2 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.ts @@ -1,7 +1,7 @@ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { Coordinate } from 'ol/coordinate'; -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; import { ShapeRelAbsBezierPoint } from '@/types/models'; export default function getCurveCoords({ diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.test.ts index ea4a9f89..302b8f11 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Extent } from 'ol/extent'; -import getDividedExtents from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents'; +import getDividedExtents from '@/components/Map/MapViewer/utils/shapes/coords/getDividedExtents'; describe('getDividedExtents', () => { it('should return original extents if there is no intersection with dividingExtent', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.ts b/src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.test.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.test.ts index 515eabf4..8c4fd4dc 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { ShapeRelAbs } from '@/types/models'; import getEllipseCoords from './getEllipseCoords'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.ts b/src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.ts index c617ffaf..bd72dd21 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; import { Coordinate } from 'ol/coordinate'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { ShapeRelAbs } from '@/types/models'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.test.ts similarity index 97% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.test.ts index ec6d5a70..9ce67a91 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Line } from '@/types/models'; -import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import getLineSegments from './getLineSegments'; describe('getLineSegments', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.ts b/src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.test.ts similarity index 88% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.test.ts index ed84c661..6060feff 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.test.ts @@ -1,8 +1,8 @@ /* eslint-disable no-magic-numbers */ -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; -import getCurveCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords'; -import getBezierCurve from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; +import getCurveCoords from '@/components/Map/MapViewer/utils/shapes/coords/getCurveCoords'; +import getBezierCurve from '@/components/Map/MapViewer/utils/shapes/coords/getBezierCurve'; import { ShapeRelAbs, ShapeRelAbsBezierPoint } from '@/types/models'; import getPolygonCoords from './getPolygonCoords'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.ts b/src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.ts similarity index 76% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.ts index d00816b5..db3f1b7c 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.ts @@ -1,10 +1,10 @@ /* eslint-disable no-magic-numbers */ import { Coordinate } from 'ol/coordinate'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getBezierCurve from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve'; -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; -import getCurveCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords'; +import getBezierCurve from '@/components/Map/MapViewer/utils/shapes/coords/getBezierCurve'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; +import getCurveCoords from '@/components/Map/MapViewer/utils/shapes/coords/getCurveCoords'; import { ShapeRelAbs, ShapeRelAbsBezierPoint } from '@/types/models'; export default function getPolygonCoords({ diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getRotation.test.ts similarity index 83% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getRotation.test.ts index 363add1a..0e26ba92 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getRotation.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getRotation from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation'; +import getRotation from '@/components/Map/MapViewer/utils/shapes/coords/getRotation'; import { Coordinate } from 'ol/coordinate'; const testCases: Array<[Coordinate, Coordinate, number]> = [ diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.ts b/src/components/Map/MapViewer/utils/shapes/coords/getRotation.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getRotation.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon.ts b/src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts similarity index 91% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon.ts rename to src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts index dd541d11..23277551 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts @@ -4,14 +4,8 @@ import { Stroke, Style } from 'ol/style'; import Feature, { FeatureLike } from 'ol/Feature'; import { MultiPolygon } from 'ol/geom'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { MapInstance } from '@/types/map'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; import { Color } from '@/types/models'; import { COMPLEX_CONTENTS_CUTOFF_SCALE, @@ -19,13 +13,16 @@ import { MAP_ELEMENT_TYPES, OUTLINE_CUTOFF_SCALE, TEXT_CUTOFF_SCALE, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MapSize } from '@/redux/map/map.types'; -import getCoverStyles from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles'; -import handleSemanticView from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView'; -import getScaledStrokeStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getCoverStyles from '@/components/Map/MapViewer/utils/shapes/style/getCoverStyles'; +import handleSemanticView from '@/components/Map/MapViewer/utils/shapes/elements/handleSemanticView'; +import getScaledStrokeStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle'; export interface BaseMapElementProps { type: string; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment.ts b/src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment.ts rename to src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts index 75c519ef..10802411 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts @@ -1,24 +1,21 @@ /* eslint-disable no-magic-numbers */ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; -import BaseMultiPolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { Coordinate } from 'ol/coordinate'; import Polygon from 'ol/geom/Polygon'; import { Stroke, Style } from 'ol/style'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; import { MapInstance } from '@/types/map'; import { Color } from '@/types/models'; import { MAP_ELEMENT_TYPES, TRANSPARENT_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import BaseMultiPolygon from '@/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon'; export interface CompartmentProps { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts similarity index 78% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts index 7c5956c6..eb94b525 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts @@ -2,24 +2,21 @@ import { Feature, Map } from 'ol'; import { Fill, Stroke, Style, Text } from 'ol/style'; import { Polygon, MultiPolygon } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import CompartmentCircle, { - CompartmentCircleProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import CompartmentCircle, { + CompartmentCircleProps, +} from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('../text/getTextStyle'); jest.mock('../text/getTextCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts index 94a65df8..78915ae4 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts @@ -1,21 +1,18 @@ /* eslint-disable no-magic-numbers */ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { MapInstance } from '@/types/map'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { BLACK_COLOR, COMPARTMENT_CIRCLE_CENTER, COMPARTMENT_CIRCLE_RADIUS, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; -import Compartment from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { Color } from '@/types/models'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import Compartment from '@/components/Map/MapViewer/utils/shapes/elements/Compartment'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; export type CompartmentCircleProps = { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts similarity index 78% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts index 00c1931b..05e1801e 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts @@ -2,24 +2,21 @@ import { Feature, Map } from 'ol'; import { Fill, Stroke, Style, Text } from 'ol/style'; import { Polygon, MultiPolygon } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import CompartmentPathway, { - CompartmentPathwayProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import CompartmentPathway, { + CompartmentPathwayProps, +} from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('../text/getTextStyle'); jest.mock('../text/getTextCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts similarity index 83% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts index eef5c0f7..94034677 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts @@ -1,26 +1,23 @@ /* eslint-disable no-magic-numbers */ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { MapInstance } from '@/types/map'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { BLACK_COLOR, MAP_ELEMENT_TYPES, TRANSPARENT_COLOR, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import Polygon from 'ol/geom/Polygon'; -import BaseMultiPolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; import { Color } from '@/types/models'; import VectorSource from 'ol/source/Vector'; import { Style } from 'ol/style'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import { MapSize } from '@/redux/map/map.types'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; +import BaseMultiPolygon from '@/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; export type CompartmentPathwayProps = { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts similarity index 79% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts index 53fff2ff..acf2471c 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts @@ -2,23 +2,20 @@ import { Feature, Map } from 'ol'; import { Fill, Stroke, Style, Text } from 'ol/style'; import { MultiPolygon } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import CompartmentSquare, { - CompartmentSquareProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare'; -import getPolygonCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import CompartmentSquare, { + CompartmentSquareProps, +} from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare'; +import getPolygonCoords from '@/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('../text/getTextStyle'); jest.mock('../text/getTextCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts index 8f033df3..34f95693 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts @@ -1,20 +1,17 @@ /* eslint-disable no-magic-numbers */ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { MapInstance } from '@/types/map'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { BLACK_COLOR, COMPARTMENT_SQUARE_POINTS, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getPolygonCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords'; -import Compartment from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { Color } from '@/types/models'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import Compartment from '@/components/Map/MapViewer/utils/shapes/elements/Compartment'; +import getPolygonCoords from '@/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords'; export type CompartmentSquareProps = { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.test.ts similarity index 93% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.test.ts index ff2a0ac2..2680f7ef 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.test.ts @@ -2,9 +2,7 @@ import { Feature, Map, View } from 'ol'; import { Style } from 'ol/style'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import Glyph, { - GlyphProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph'; +import Glyph, { GlyphProps } from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph'; import { MapInstance } from '@/types/map'; import Polygon from 'ol/geom/Polygon'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.ts b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.ts rename to src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.ts index a0676acd..1da2b4fb 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.ts @@ -11,13 +11,13 @@ import Polygon from 'ol/geom/Polygon'; import { Point } from 'ol/geom'; import { Coordinate } from 'ol/coordinate'; import { FEATURE_TYPE } from '@/constants/features'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; -import { WHITE_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import getScaledElementStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle'; -import getBoundingBoxFromExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent'; +import { WHITE_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { MapSize } from '@/redux/map/map.types'; import { LayerImage } from '@/types/models'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import getScaledElementStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle'; +import getBoundingBoxFromExtent from '@/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent'; export type GlyphProps = { elementId: number; @@ -249,6 +249,7 @@ export default class Glyph { }), zIndex: this.zIndex, }); + this.feature.changed(); }; img.src = `${BASE_NEW_API_URL}${apiPath.getGlyphImage(this.glyphId)}`; } diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/updateGlyph.ts b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/updateGlyph.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/updateGlyph.ts rename to src/components/Map/MapViewer/utils/shapes/elements/Glyph/updateGlyph.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts similarity index 80% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts index 9dbf5336..744c6529 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts @@ -2,24 +2,21 @@ import { Feature, Map } from 'ol'; import { Fill, Stroke, Style, Text } from 'ol/style'; import { Polygon, MultiPolygon } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; -import MapElement, { - MapElementProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { shapesFixture } from '@/models/fixtures/shapesFixture'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import MapElement, { + MapElementProps, +} from '@/components/Map/MapViewer/utils/shapes/elements/MapElement'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('../text/getTextStyle'); jest.mock('../text/getTextCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts similarity index 91% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts rename to src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts index 38b6b16d..ead1dd13 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts @@ -1,28 +1,17 @@ /* eslint-disable no-magic-numbers */ import { Style } from 'ol/style'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; import Polygon from 'ol/geom/Polygon'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import { Color, Modification, Shape } from '@/types/models'; import { MapInstance } from '@/types/map'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { BLACK_COLOR, COMPLEX_SBO_TERMS, MAP_ELEMENT_TYPES, TRANSPARENT_COLOR, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import BaseMultiPolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { BioShapesDict, LineTypeDict } from '@/redux/shapes/shapes.types'; import { FEATURE_TYPE } from '@/constants/features'; import { OverlayBioEntityRender } from '@/types/OLrendering'; @@ -32,6 +21,14 @@ import { OverlayOrder } from '@/redux/overlayBioEntity/overlayBioEntity.utils'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import BaseMultiPolygon from '@/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; export type MapElementProps = { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.test.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.test.ts index 71a6ce39..970241b9 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.test.ts @@ -2,11 +2,11 @@ import { Feature } from 'ol'; import { Fill, Stroke, Style } from 'ol/style'; import { Polygon, MultiPolygon } from 'ol/geom'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; -import getArrowFeature from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature'; -import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { ArrowTypeDict } from '@/redux/shapes/shapes.types'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getArrowFeature from '@/components/Map/MapViewer/utils/shapes/elements/getArrowFeature'; jest.mock('../style/getStyle'); jest.mock('./getShapePolygon'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.ts b/src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.ts similarity index 80% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.ts rename to src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.ts index c8f46d9d..0ccc40a2 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.ts @@ -1,16 +1,16 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; import { Feature } from 'ol'; import { MultiPolygon } from 'ol/geom'; import { Arrow, Color } from '@/types/models'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; import Polygon from 'ol/geom/Polygon'; -import { WHITE_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { WHITE_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { ArrowTypeDict } from '@/redux/shapes/shapes.types'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; export default function getArrowFeature({ arrowTypes, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.test.ts index 0074f57b..5254b54e 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.test.ts @@ -1,9 +1,9 @@ /* eslint-disable no-magic-numbers */ -import getPolygonCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; +import getPolygonCoords from '@/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; import Polygon from 'ol/geom/Polygon'; import { Shape } from '@/types/models'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; jest.mock('../coords/getPolygonCoords'); jest.mock('../coords/getEllipseCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.ts b/src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.ts similarity index 78% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.ts rename to src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.ts index 7e2f7a59..a2082fe3 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.ts @@ -1,11 +1,11 @@ /* eslint-disable no-magic-numbers */ import Polygon from 'ol/geom/Polygon'; import { Coordinate } from 'ol/coordinate'; -import getPolygonCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; +import getPolygonCoords from '@/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; import { Shape } from '@/types/models'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getCenter from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter'; +import getCenter from '@/components/Map/MapViewer/utils/shapes/coords/getCenter'; export default function getShapePolygon({ shape, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.test.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.test.ts index f6360b51..c2d9e620 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.test.ts @@ -1,9 +1,9 @@ /* eslint-disable no-magic-numbers */ import Feature from 'ol/Feature'; import VectorSource from 'ol/source/Vector'; -import getDividedExtents from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents'; -import findLargestExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent'; -import handleSemanticView from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView'; +import getDividedExtents from '@/components/Map/MapViewer/utils/shapes/coords/getDividedExtents'; +import findLargestExtent from '@/components/Map/MapViewer/utils/shapes/coords/findLargestExtent'; +import handleSemanticView from '@/components/Map/MapViewer/utils/shapes/elements/handleSemanticView'; import Geometry from 'ol/geom/Geometry'; import { fromExtent } from 'ol/geom/Polygon'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.ts b/src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.ts similarity index 86% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.ts rename to src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.ts index 71c32e6f..cd5aa1f4 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.ts @@ -1,14 +1,14 @@ /* eslint-disable no-magic-numbers */ -import getDividedExtents from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents'; -import findLargestExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent'; import Feature from 'ol/Feature'; import VectorSource from 'ol/source/Vector'; import { Extent } from 'ol/extent'; import { COMPLEX_SBO_TERMS, MAP_ELEMENT_TYPES, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import isFeatureInCompartment from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment'; +} from '@/components/Map/MapViewer/MapViewer.constants'; +import findLargestExtent from '@/components/Map/MapViewer/utils/shapes/coords/findLargestExtent'; +import getDividedExtents from '@/components/Map/MapViewer/utils/shapes/coords/getDividedExtents'; +import isFeatureInCompartment from '@/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment'; export default function handleSemanticView({ vectorSource, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment.ts b/src/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment.ts rename to src/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer.ts b/src/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer.ts rename to src/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.test.ts b/src/components/Map/MapViewer/utils/shapes/layer/Layer.test.ts similarity index 84% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.test.ts rename to src/components/Map/MapViewer/utils/shapes/layer/Layer.test.ts index 9da93414..d9f3c022 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/Layer.test.ts @@ -1,20 +1,15 @@ /* eslint-disable no-magic-numbers */ import { Map } from 'ol'; import { Stroke, Style, Text } from 'ol/style'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; -import Layer, { - LayerProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import VectorLayer from 'ol/layer/Vector'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; +import Layer, { LayerProps } from '@/components/Map/MapViewer/utils/shapes/layer/Layer'; jest.mock('../text/getTextCoords'); jest.mock('../text/getTextStyle'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.ts b/src/components/Map/MapViewer/utils/shapes/layer/Layer.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.ts rename to src/components/Map/MapViewer/utils/shapes/layer/Layer.ts index 84c3f317..282e25e4 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/Layer.ts @@ -4,18 +4,10 @@ import { MapInstance } from '@/types/map'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { Feature } from 'ol'; import { LineString, MultiPolygon, Point } from 'ol/geom'; -import Text from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text'; import Polygon from 'ol/geom/Polygon'; import VectorSource from 'ol/source/Vector'; import VectorLayer from 'ol/layer/Vector'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; -import getRotation from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation'; -import getArrowFeature from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { FeatureLike } from 'ol/Feature'; import Style from 'ol/style/Style'; import { ArrowTypeDict, LineTypeDict } from '@/redux/shapes/shapes.types'; @@ -23,11 +15,16 @@ import { LAYER_ELEMENT_TYPES, REACTION_ELEMENT_CUTOFF_SCALE, TRANSPARENT_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getScaledElementStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { Stroke } from 'ol/style'; -import Glyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph'; import { MapSize } from '@/redux/map/map.types'; +import getScaledElementStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle'; +import Glyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph'; +import getArrowFeature from '@/components/Map/MapViewer/utils/shapes/elements/getArrowFeature'; +import getRotation from '@/components/Map/MapViewer/utils/shapes/coords/getRotation'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; +import Text from '@/components/Map/MapViewer/utils/shapes/text/Text'; export interface LayerProps { texts: Array<LayerText>; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.test.ts b/src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.test.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.test.ts rename to src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.test.ts index e0c9fb44..2e9e3f88 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.test.ts @@ -12,7 +12,7 @@ import { DEFAULT_TILE_SIZE } from '@/constants/map'; import { Map } from 'ol'; import getDrawImageInteraction from './getDrawImageInteraction'; -jest.mock('../../../../../../../utils/map/latLngToPoint', () => ({ +jest.mock('../../../../../../utils/map/latLngToPoint', () => ({ latLngToPoint: jest.fn(latLng => ({ x: latLng[0], y: latLng[1] })), })); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.ts b/src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.ts similarity index 97% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.ts rename to src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.ts index 35bd90a5..8c37bf36 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.ts @@ -7,7 +7,7 @@ import { AppDispatch } from '@/redux/store'; import { Coordinate } from 'ol/coordinate'; import { openLayerImageObjectFactoryModal } from '@/redux/modal/modal.slice'; import { Extent } from 'ol/extent'; -import getBoundingBoxFromExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent'; +import getBoundingBoxFromExtent from '@/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent'; export default function getDrawImageInteraction( mapSize: MapSize, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.test.ts b/src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.test.ts rename to src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.test.ts index 92a891c8..718037ff 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.test.ts @@ -8,11 +8,11 @@ import { import { ModalState } from '@/redux/modal/modal.types'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; import { Collection, Feature } from 'ol'; -import getTransformImageInteraction from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction'; +import getTransformImageInteraction from '@/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction'; import Transform from 'ol-ext/interaction/Transform'; import { Geometry } from 'ol/geom'; -jest.mock('../../../../../../../utils/map/latLngToPoint', () => ({ +jest.mock('../../../../../../utils/map/latLngToPoint', () => ({ latLngToPoint: jest.fn(latLng => ({ x: latLng[0], y: latLng[1] })), })); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.ts b/src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.ts similarity index 98% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.ts rename to src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.ts index eecc3665..596205e6 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.ts @@ -7,7 +7,7 @@ import { Collection, Feature } from 'ol'; import BaseEvent from 'ol/events/Event'; import { updateLayerImageObject } from '@/redux/layers/layers.thunks'; import { layerUpdateImage } from '@/redux/layers/layers.slice'; -import getBoundingBoxFromExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent'; +import getBoundingBoxFromExtent from '@/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent'; import { MapSize } from '@/redux/map/map.types'; import { Extent } from 'ol/extent'; import { mapEditToolsSetLayerObject } from '@/redux/mapEditTools/mapEditTools.slice'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.test.ts similarity index 78% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.test.ts index 4efbc9d6..0888de5c 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.test.ts @@ -1,13 +1,13 @@ /* eslint-disable no-magic-numbers */ import { Feature, Map } from 'ol'; import { Stroke, Style } from 'ol/style'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; import View from 'ol/View'; import LineOverlay, { LineOverlayProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay'; +} from '@/components/Map/MapViewer/utils/shapes/overlay/LineOverlay'; import { Coordinate } from 'ol/coordinate'; jest.mock('../style/getStroke'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.ts b/src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.ts index b6d8eecb..adf9beb8 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.ts @@ -2,7 +2,7 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { LineString } from 'ol/geom'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; import { Feature } from 'ol'; import { FeatureLike } from 'ol/Feature'; import Style from 'ol/style/Style'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.test.ts similarity index 79% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.test.ts index 4fe3c4aa..19bc84b6 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.test.ts @@ -1,14 +1,14 @@ /* eslint-disable no-magic-numbers */ import { Feature, Map } from 'ol'; import { Stroke, Style } from 'ol/style'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; import View from 'ol/View'; import { Coordinate } from 'ol/coordinate'; import MarkerOverlay, { MarkerOverlayProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay'; +} from '@/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay'; jest.mock('../style/getStroke'); jest.mock('../style/getFill'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.ts b/src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.ts index a0336335..e963d768 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.ts @@ -1,7 +1,7 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; import { Feature } from 'ol'; import { FeatureLike } from 'ol/Feature'; import Style from 'ol/style/Style'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/areOverlayOrdersNotEqual.ts b/src/components/Map/MapViewer/utils/shapes/overlay/areOverlayOrdersNotEqual.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/areOverlayOrdersNotEqual.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/areOverlayOrdersNotEqual.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions.ts b/src/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle.ts b/src/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.ts b/src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.ts similarity index 83% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.ts index 8cc7c004..687e2e67 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.ts @@ -1,7 +1,7 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; -import groupOverlayEntities from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities'; -import processOverlayGroupedElements from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements'; +import groupOverlayEntities from '@/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities'; +import processOverlayGroupedElements from '@/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements'; export default function getOverlays( groupedOverlays: Record<string, Array<OverlayBioEntityRender>>, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.ts b/src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.ts similarity index 88% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.ts index 984574cf..f9a63e9e 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.ts @@ -1,6 +1,6 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; -import findMatchingSubmapLinkRectangle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle'; -import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewer.types'; +import findMatchingSubmapLinkRectangle from '@/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle'; export default function groupOverlayEntities( overlayBioEntities: Array<OverlayBioEntityRender>, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.test.ts index 680002ea..c3a094e2 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.test.ts @@ -1,8 +1,8 @@ /* eslint-disable no-magic-numbers */ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; -import processOverlayGroupedElements from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements'; -import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewer.types'; +import processOverlayGroupedElements from '@/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements'; describe('processOverlayGroupedElements', () => { it('should correctly process overlay grouped elements and add to entityOverlays', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.ts b/src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.ts index 7e2a9b43..48ecc167 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.ts @@ -1,9 +1,9 @@ /* eslint-disable no-magic-numbers */ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; -import sortElementOverlayByColor from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor'; -import calculateOverlayDimensions from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions'; -import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewer.types'; +import sortElementOverlayByColor from '@/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor'; +import calculateOverlayDimensions from '@/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions'; export default function processOverlayGroupedElements( groupedElements: OverlayBioEntityGroupedElementsType, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor.ts b/src/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts b/src/components/Map/MapViewer/utils/shapes/reaction/Reaction.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts rename to src/components/Map/MapViewer/utils/shapes/reaction/Reaction.test.ts index 0e6dce24..4125a801 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/reaction/Reaction.test.ts @@ -1,8 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Feature, Map } from 'ol'; -import Reaction, { - ReactionProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction'; +import Reaction, { ReactionProps } from '@/components/Map/MapViewer/utils/shapes/reaction/Reaction'; import { newReactionFixture } from '@/models/fixtures/newReactionFixture'; import { lineTypesFixture } from '@/models/fixtures/lineTypesFixture'; import { arrowTypesFixture } from '@/models/fixtures/arrowTypesFixture'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts b/src/components/Map/MapViewer/utils/shapes/reaction/Reaction.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts rename to src/components/Map/MapViewer/utils/shapes/reaction/Reaction.ts index ccefcd64..a2e786fc 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts +++ b/src/components/Map/MapViewer/utils/shapes/reaction/Reaction.ts @@ -3,7 +3,6 @@ import { Line, Operator, ReactionProduct, Shape } from '@/types/models'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { Feature } from 'ol'; import { Circle, LineString, MultiLineString, MultiPolygon } from 'ol/geom'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; import Polygon from 'ol/geom/Polygon'; import Style from 'ol/style/Style'; import { @@ -11,21 +10,22 @@ import { REACTION_ELEMENT_TYPES, TEXT_CUTOFF_SCALE, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { FeatureLike } from 'ol/Feature'; import { MapInstance } from '@/types/map'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import { ArrowTypeDict, LineTypeDict } from '@/redux/shapes/shapes.types'; import { FEATURE_TYPE } from '@/constants/features'; -import getScaledElementStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle'; import VectorSource from 'ol/source/Vector'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; import { Stroke } from 'ol/style'; -import getLineSegments from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments'; -import getRotation from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation'; -import getArrowFeature from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; +import getScaledElementStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getLineSegments from '@/components/Map/MapViewer/utils/shapes/coords/getLineSegments'; +import getRotation from '@/components/Map/MapViewer/utils/shapes/coords/getRotation'; +import getArrowFeature from '@/components/Map/MapViewer/utils/shapes/elements/getArrowFeature'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; export interface ReactionProps { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.test.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.test.ts index 8178ab4a..a8ea5c82 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.test.ts @@ -1,15 +1,15 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; import { Extent } from 'ol/extent'; -import getWrappedTextWithFontSize from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; +import getWrappedTextWithFontSize from '@/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; import { latLngToPoint } from '@/utils/map/latLngToPoint'; -import getCoverStyles from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles'; +import getCoverStyles from '@/components/Map/MapViewer/utils/shapes/style/getCoverStyles'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; jest.mock('../text/getWrappedTextWithFontSize'); jest.mock('../text/getTextStyle'); -jest.mock('../../../../../../../utils/map/latLngToPoint'); +jest.mock('../../../../../../utils/map/latLngToPoint'); describe('getCoverStyles', () => { it('should return cover and text styles based on the provided parameters', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.ts b/src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.ts similarity index 86% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.ts rename to src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.ts index 78f2ef6b..83ad9a71 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.ts @@ -3,12 +3,12 @@ import Style from 'ol/style/Style'; import { Extent, getCenter } from 'ol/extent'; import { toLonLat } from 'ol/proj'; import { latLngToPoint } from '@/utils/map/latLngToPoint'; -import getWrappedTextWithFontSize from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize'; +import getWrappedTextWithFontSize from '@/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize'; import { Point } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; import { MapSize } from '@/redux/map/map.types'; import { Stroke } from 'ol/style'; -import getScaledStrokeStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle'; +import getScaledStrokeStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle'; export default function getCoverStyles({ coverStyle, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getFill.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getFill.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill.ts b/src/components/Map/MapViewer/utils/shapes/style/getFill.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill.ts rename to src/components/Map/MapViewer/utils/shapes/style/getFill.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.test.ts index 5c22d994..bd36a7d8 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.test.ts @@ -1,7 +1,7 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; import { Stroke, Text } from 'ol/style'; -import getScaledStrokeStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle'; +import getScaledStrokeStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle'; import getScaledElementStyle from './getScaledElementStyle'; jest.mock('./getScaledStrokeStyle'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.ts b/src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.ts similarity index 76% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.ts rename to src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.ts index a91c0309..5f2eaa40 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.ts @@ -1,7 +1,7 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; import { Stroke } from 'ol/style'; -import getScaledStrokeStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle'; +import getScaledStrokeStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle'; export default function getScaledElementStyle( style: Style, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle.ts b/src/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle.ts rename to src/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getStroke.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getStroke.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke.ts b/src/components/Map/MapViewer/utils/shapes/style/getStroke.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke.ts rename to src/components/Map/MapViewer/utils/shapes/style/getStroke.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getStyle.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getStyle.test.ts index e46f9ef0..974b9272 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getStyle.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; import Style from 'ol/style/Style'; import Polygon from 'ol/geom/Polygon'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.ts b/src/components/Map/MapViewer/utils/shapes/style/getStyle.ts similarity index 65% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.ts rename to src/components/Map/MapViewer/utils/shapes/style/getStyle.ts index 96083434..9e121e1a 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getStyle.ts @@ -1,14 +1,11 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; import { Geometry } from 'ol/geom'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; -import { - BLACK_COLOR, - WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; +import { BLACK_COLOR, WHITE_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { Color } from '@/types/models'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; export default function getStyle({ geometry, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex.test.ts b/src/components/Map/MapViewer/utils/shapes/style/rgbToHex.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/rgbToHex.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex.ts b/src/components/Map/MapViewer/utils/shapes/style/rgbToHex.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex.ts rename to src/components/Map/MapViewer/utils/shapes/style/rgbToHex.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.test.ts b/src/components/Map/MapViewer/utils/shapes/text/Text.test.ts similarity index 80% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.test.ts rename to src/components/Map/MapViewer/utils/shapes/text/Text.test.ts index 68b8d9f8..d40cf459 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/Text.test.ts @@ -1,12 +1,12 @@ /* eslint-disable no-magic-numbers */ import { Map } from 'ol'; import { Style } from 'ol/style'; -import Text, { TextProps } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; +import Text, { TextProps } from '@/components/Map/MapViewer/utils/shapes/text/Text'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('./getTextCoords'); jest.mock('./getTextStyle'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.ts b/src/components/Map/MapViewer/utils/shapes/text/Text.ts similarity index 84% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.ts rename to src/components/Map/MapViewer/utils/shapes/text/Text.ts index 27b8ec6f..c853b369 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/Text.ts @@ -1,19 +1,16 @@ /* eslint-disable no-magic-numbers */ -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import Style from 'ol/style/Style'; import { Point } from 'ol/geom'; import { Feature } from 'ol'; import { FeatureLike } from 'ol/Feature'; import { MapInstance } from '@/types/map'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; import { Color } from '@/types/models'; -import { TEXT_CUTOFF_SCALE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { TEXT_CUTOFF_SCALE } from '@/components/Map/MapViewer/MapViewer.constants'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; export interface TextProps { x: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.test.ts b/src/components/Map/MapViewer/utils/shapes/text/getTextCoords.test.ts similarity index 85% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.test.ts rename to src/components/Map/MapViewer/utils/shapes/text/getTextCoords.test.ts index 6121a92d..a48c180a 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getTextCoords.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; describe('getTextCoords', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.ts b/src/components/Map/MapViewer/utils/shapes/text/getTextCoords.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.ts rename to src/components/Map/MapViewer/utils/shapes/text/getTextCoords.ts index 3dcbb8fa..e3224fc9 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getTextCoords.ts @@ -1,8 +1,5 @@ /* eslint-disable no-magic-numbers */ -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { Coordinate } from 'ol/coordinate'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.test.ts b/src/components/Map/MapViewer/utils/shapes/text/getTextStyle.test.ts similarity index 88% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.test.ts rename to src/components/Map/MapViewer/utils/shapes/text/getTextStyle.test.ts index d16623b5..3d6fc5f4 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getTextStyle.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; import Style from 'ol/style/Style'; describe('getTextStyle', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.ts b/src/components/Map/MapViewer/utils/shapes/text/getTextStyle.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.ts rename to src/components/Map/MapViewer/utils/shapes/text/getTextStyle.ts index 4858fb21..6558ab9a 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getTextStyle.ts @@ -1,6 +1,6 @@ import { Fill, Text } from 'ol/style'; import Style from 'ol/style/Style'; -import { HorizontalAlign } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign } from '@/components/Map/MapViewer/MapViewer.types'; export default function getTextStyle({ text, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.test.ts b/src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.test.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.test.ts rename to src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.test.ts index 2cfaa243..eba60616 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getWrappedTextWithFontSize from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize'; +import getWrappedTextWithFontSize from '@/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize'; describe('getWrappedTextWithFontSize', () => { it('should return a wrapped text and font size for this text when maxWidth is limited and maxHeight is unlimited', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.ts b/src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.ts rename to src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.ts diff --git a/src/components/Map/MapViewer/utils/useOlMap.ts b/src/components/Map/MapViewer/utils/useOlMap.ts index 68ec65bd..6e372dc3 100644 --- a/src/components/Map/MapViewer/utils/useOlMap.ts +++ b/src/components/Map/MapViewer/utils/useOlMap.ts @@ -2,15 +2,9 @@ import { MapInstance } from '@/types/map'; import { useMapInstance } from '@/utils/context/mapInstanceContext'; import Map from 'ol/Map'; import { Zoom } from 'ol/control'; -import React, { MutableRefObject, useEffect, useMemo } from 'react'; -import { useOlMapVectorLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers'; -import LayerGroup from 'ol/layer/Group'; -import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { vectorRenderingSelector } from '@/redux/models/models.selectors'; +import React, { MutableRefObject, useEffect } from 'react'; +import { useOlMapLayers } from '@/components/Map/MapViewer/utils/config/useOlMapLayers'; import { defaults, MouseWheelZoom } from 'ol/interaction'; -import { useOlMapVectorListeners } from '@/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners'; -import { useOlMapCommonLayers } from '@/components/Map/MapViewer/utils/config/useOlMapCommonLayers'; -import { useOlMapLayers } from './config/useOlMapLayers'; import { useOlMapView } from './config/useOlMapView'; import { useOlMapListeners } from './listeners/useOlMapListeners'; @@ -25,34 +19,13 @@ interface UseOlMapOutput { type UseOlMap = (input?: UseOlMapInput) => UseOlMapOutput; export const useOlMap: UseOlMap = ({ target } = {}) => { - const vectorRendering = useAppSelector(vectorRenderingSelector); const mapRef = React.useRef<null | HTMLDivElement>(null); const { mapInstance, handleSetMapInstance } = useMapInstance(); const view = useOlMapView({ mapInstance }); - const rasterLayers = useOlMapLayers(); - const rasterLayersGroup = useMemo(() => { - return new LayerGroup({ - layers: rasterLayers, - }); - }, [rasterLayers]); - - const vectorLayers = useOlMapVectorLayers({ mapInstance }); - const vectorLayersGroup = useMemo(() => { - return new LayerGroup({ - layers: vectorLayers, - }); - }, [vectorLayers]); - - const commonLayers = useOlMapCommonLayers(); - const commonLayersGroup = useMemo(() => { - return new LayerGroup({ - layers: commonLayers, - }); - }, [commonLayers]); + const mapLayers = useOlMapLayers({ mapInstance }); useOlMapListeners({ view, mapInstance }); - useOlMapVectorListeners({ mapInstance }); useEffect(() => { // checking if innerHTML is empty due to possibility of target element cloning by OpenLayers map instance @@ -86,18 +59,8 @@ export const useOlMap: UseOlMap = ({ target } = {}) => { if (!mapInstance) { return; } - mapInstance.setLayers([vectorLayersGroup, rasterLayersGroup, commonLayersGroup]); - }, [mapInstance, rasterLayersGroup, vectorLayersGroup, commonLayersGroup]); - - useEffect(() => { - if (vectorRendering) { - rasterLayersGroup.setVisible(false); - vectorLayersGroup.setVisible(true); - } else { - vectorLayersGroup.setVisible(false); - rasterLayersGroup.setVisible(true); - } - }, [rasterLayersGroup, vectorLayersGroup, vectorRendering]); + mapInstance.setLayers(mapLayers); + }, [mapInstance, mapLayers]); return { mapRef, diff --git a/src/models/mocks/modelsMock.ts b/src/models/mocks/modelsMock.ts index 85e29299..5c14d13a 100644 --- a/src/models/mocks/modelsMock.ts +++ b/src/models/mocks/modelsMock.ts @@ -475,7 +475,6 @@ export const CORE_PD_MODEL_MOCK: MapModel = { modificationDates: [], minZoom: 2, maxZoom: 9, - vectorRendering: true, }; export const MODEL_WITH_DESCRIPTION: MapModel = { diff --git a/src/models/modelSchema.ts b/src/models/modelSchema.ts index feb8817b..392cda85 100644 --- a/src/models/modelSchema.ts +++ b/src/models/modelSchema.ts @@ -29,7 +29,6 @@ export const mapModelSchema = z.object({ references: z.array(referenceSchema), creationDate: z.string().nullable(), modificationDates: z.array(z.string()), - vectorRendering: z.boolean().optional(), }); export const mapModelsSchema = pageableSchema(mapModelSchema); diff --git a/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts b/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts index cae4025d..a29317ed 100644 --- a/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts +++ b/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts @@ -5,7 +5,7 @@ import { modelsNameMapSelector } from '@/redux/models/models.selectors'; import { getReactionsByIds } from '@/redux/reactions/reactions.thunks'; import type { AppDispatch, store } from '@/redux/store'; import type { BioEntityContent, NewReaction } from '@/types/models'; -import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction'; +import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction'; interface Args { bioEntityContents: BioEntityContent[]; diff --git a/src/redux/layers/layers.reducers.ts b/src/redux/layers/layers.reducers.ts index 715611f1..58aa3a23 100644 --- a/src/redux/layers/layers.reducers.ts +++ b/src/redux/layers/layers.reducers.ts @@ -57,6 +57,9 @@ export const setActiveLayerReducer = ( action: PayloadAction<{ modelId: number; layerId: number | null }>, ): void => { const { modelId, layerId } = action.payload; + if (!state[modelId]) { + return; + } const { data } = state[modelId]; if (!data) { return; diff --git a/src/redux/models/models.reducers.ts b/src/redux/models/models.reducers.ts index 054b4c0b..eb653786 100644 --- a/src/redux/models/models.reducers.ts +++ b/src/redux/models/models.reducers.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import { ActionReducerMapBuilder, PayloadAction } from '@reduxjs/toolkit'; +import { ActionReducerMapBuilder } from '@reduxjs/toolkit'; import { getModels } from './models.thunks'; import { ModelsState } from './models.types'; @@ -16,14 +16,3 @@ export const getModelsReducer = (builder: ActionReducerMapBuilder<ModelsState>): // TODO to discuss manage state of failure }); }; - -export const setModelVectorRenderingReducer = ( - state: ModelsState, - action: PayloadAction<{ vectorRendering: boolean; mapId: number }>, -): void => { - const { payload } = action; - const modelIndex = state.data.findIndex(model => model.id === payload.mapId); - if (modelIndex !== -1) { - state.data[modelIndex].vectorRendering = payload.vectorRendering; - } -}; diff --git a/src/redux/models/models.selectors.ts b/src/redux/models/models.selectors.ts index 606aa70e..a26e8e94 100644 --- a/src/redux/models/models.selectors.ts +++ b/src/redux/models/models.selectors.ts @@ -63,8 +63,3 @@ export const mainMapModelDescriptionSelector = createSelector( mainMapModelSelector, model => model?.description, ); - -export const vectorRenderingSelector = createSelector( - currentModelSelector, - model => model?.vectorRendering || false, -); diff --git a/src/redux/models/models.slice.ts b/src/redux/models/models.slice.ts index 48cf8654..5c969f3e 100644 --- a/src/redux/models/models.slice.ts +++ b/src/redux/models/models.slice.ts @@ -1,6 +1,6 @@ import { ModelsState } from '@/redux/models/models.types'; import { createSlice } from '@reduxjs/toolkit'; -import { getModelsReducer, setModelVectorRenderingReducer } from './models.reducers'; +import { getModelsReducer } from './models.reducers'; const initialState: ModelsState = { data: [], @@ -11,14 +11,10 @@ const initialState: ModelsState = { export const modelsSlice = createSlice({ name: 'models', initialState, - reducers: { - setModelVectorRendering: setModelVectorRenderingReducer, - }, + reducers: {}, extraReducers: builder => { getModelsReducer(builder); }, }); -export const { setModelVectorRendering } = modelsSlice.actions; - export default modelsSlice.reducer; -- GitLab From 8d1cbb00fa002e86c0d77ef767b42b44df4bc657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Grocholewski?= <m.grocholewski@atcomp.pl> Date: Mon, 20 Jan 2025 11:09:40 +0100 Subject: [PATCH 2/2] feat(vector-map): remove communication with backend about backgrounds --- .../MapNavigation.component.test.tsx | 8 -- .../utils/useOverviewImageLinkActions.test.ts | 9 -- .../ElementLink.component.test.tsx | 2 - .../TopBar/TopBar.component.test.tsx | 7 -- .../AssociatedSubmap.component.test.tsx | 3 - .../ExportCompound.component.tsx | 12 +- .../OverlayListItem.component.test.tsx | 19 +--- .../hooks/useEmptyBackground.test.ts | 43 -------- .../hooks/useEmptyBackground.ts | 22 ---- .../Drawer/OverlaysDrawer/hooks/useOverlay.ts | 6 +- .../BioEntitiesSubmapItem.component.test.tsx | 3 - .../PinsListItem.component.test.tsx | 4 - .../DownloadSubmap.component.test.tsx | 10 -- .../utils/useGetSubmapDownloadUrl.test.ts | 10 -- .../utils/useGetSubmapDownloadUrl.ts | 9 +- .../SubmapsDrawer/SubmapsDrawer.test.tsx | 3 - .../MapAdditionalActions.component.test.tsx | 2 - .../utils/useAdditionalActions.test.ts | 2 - .../BackgroundsSelector.component.test.tsx | 104 ------------------ .../BackgroundsSelector.component.tsx | 86 --------------- .../BackgroundsSelector/index.ts | 1 - .../MapAdditionalOptions.component.test.tsx | 29 ----- .../MapAdditionalOptions.component.tsx | 10 -- .../Map/MapAdditionalOptions/index.ts | 1 - .../MapVectorBackgroundSelector.component.tsx | 12 +- .../MapViewer/MapViewer.component.test.tsx | 2 - .../useOlMapAdditionalLayers.test.ts | 2 - .../mapCardLayer/useOlMapCardLayer.test.ts | 2 - .../processLayer/processModelElements.ts | 6 +- .../processLayer/useOlMapProcessLayer.test.ts | 2 - .../processLayer/useOlMapProcessLayer.ts | 16 +-- .../utils/config/useOlMapLayers.test.ts | 2 - .../utils/config/useOlMapTileLayer.test.ts | 79 ------------- .../utils/config/useOlMapTileLayer.ts | 66 ----------- .../utils/config/useOlMapView.test.ts | 8 -- .../utils/listeners/useOlMapListeners.test.ts | 2 - .../utils/shapes/elements/BaseMultiPolygon.ts | 10 +- .../utils/shapes/elements/Compartment.ts | 6 +- .../shapes/elements/CompartmentCircle.test.ts | 2 +- .../shapes/elements/CompartmentCircle.ts | 6 +- .../elements/CompartmentPathway.test.ts | 2 +- .../shapes/elements/CompartmentPathway.ts | 6 +- .../shapes/elements/CompartmentSquare.test.ts | 2 +- .../shapes/elements/CompartmentSquare.ts | 6 +- .../utils/shapes/elements/MapElement.test.ts | 2 +- .../utils/shapes/elements/MapElement.ts | 6 +- .../Map/MapViewer/utils/useOlMap.test.ts | 2 - src/constants/backgrounds.ts | 1 - src/models/fixtures/backgroundsFixture.ts | 10 -- src/models/mapBackground.ts | 21 ---- src/redux/apiPath.ts | 2 - src/redux/backgrounds/background.mock.ts | 60 ---------- src/redux/backgrounds/background.selectors.ts | 56 ---------- .../backgrounds/backgrounds.constants.ts | 3 - .../backgrounds/backgrounds.reducers.test.ts | 86 --------------- src/redux/backgrounds/backgrounds.reducers.ts | 19 ---- src/redux/backgrounds/backgrounds.slice.ts | 20 ---- src/redux/backgrounds/backgrounds.thunks.ts | 27 ----- src/redux/backgrounds/backgrounds.types.ts | 4 - src/redux/map/map.constants.ts | 3 +- src/redux/map/map.fixtures.ts | 4 +- src/redux/map/map.reducers.ts | 10 +- src/redux/map/map.selectors.ts | 2 +- src/redux/map/map.slice.ts | 3 - src/redux/map/map.thunks.test.ts | 20 ++-- src/redux/map/map.thunks.ts | 21 +--- src/redux/map/map.types.ts | 4 +- .../checkIfIsMapUpdateActionValid.test.ts | 2 - .../map/middleware/map.middleware.test.ts | 2 - src/redux/map/middleware/map.middleware.ts | 5 +- .../overlayBioEntity.thunk.ts | 7 -- src/redux/root/init.selectors.ts | 4 - src/redux/root/init.thunks.ts | 2 - src/redux/root/root.fixtures.ts | 2 - src/redux/store.ts | 2 - .../pluginsManager/map/data/getBounds.test.ts | 2 - .../map/fitBounds/fitBounds.test.ts | 3 - .../pluginsManager/map/openMap.test.ts | 4 - .../setBackgroundtoEmptyIfAvailable.test.ts | 52 --------- .../setBackgroundtoEmptyIfAvailable.ts | 12 -- .../showDataOverlay/showDataOverlay.test.ts | 43 -------- .../showDataOverlay/showDataOverlay.ts | 5 +- .../map/position/getCenter.test.ts | 2 - .../map/triggerSearch/triggerSearch.test.ts | 2 - .../pluginsManager/map/zoom/getZoom.test.ts | 3 - .../pluginsManager/map/zoom/setZoom.test.ts | 2 - src/types/mapLayers.ts | 15 --- src/types/models.ts | 2 - .../initialize/useInitializeStore.test.ts | 18 +-- src/utils/initialize/useInitializeStore.ts | 3 +- src/utils/map/getUpdatedMapData.ts | 7 +- src/utils/map/useSetBounds.test.ts | 3 - .../useReduxBusQueryManager.test.ts | 3 - 93 files changed, 84 insertions(+), 1153 deletions(-) delete mode 100644 src/components/Map/Drawer/OverlaysDrawer/hooks/useEmptyBackground.test.ts delete mode 100644 src/components/Map/Drawer/OverlaysDrawer/hooks/useEmptyBackground.ts delete mode 100644 src/components/Map/MapAdditionalOptions/BackgroundsSelector/BackgroundsSelector.component.test.tsx delete mode 100644 src/components/Map/MapAdditionalOptions/BackgroundsSelector/BackgroundsSelector.component.tsx delete mode 100644 src/components/Map/MapAdditionalOptions/BackgroundsSelector/index.ts delete mode 100644 src/components/Map/MapAdditionalOptions/MapAdditionalOptions.component.test.tsx delete mode 100644 src/components/Map/MapAdditionalOptions/MapAdditionalOptions.component.tsx delete mode 100644 src/components/Map/MapAdditionalOptions/index.ts delete mode 100644 src/components/Map/MapViewer/utils/config/useOlMapTileLayer.test.ts delete mode 100644 src/components/Map/MapViewer/utils/config/useOlMapTileLayer.ts delete mode 100644 src/constants/backgrounds.ts delete mode 100644 src/models/fixtures/backgroundsFixture.ts delete mode 100644 src/models/mapBackground.ts delete mode 100644 src/redux/backgrounds/background.mock.ts delete mode 100644 src/redux/backgrounds/background.selectors.ts delete mode 100644 src/redux/backgrounds/backgrounds.constants.ts delete mode 100644 src/redux/backgrounds/backgrounds.reducers.test.ts delete mode 100644 src/redux/backgrounds/backgrounds.reducers.ts delete mode 100644 src/redux/backgrounds/backgrounds.slice.ts delete mode 100644 src/redux/backgrounds/backgrounds.thunks.ts delete mode 100644 src/redux/backgrounds/backgrounds.types.ts delete mode 100644 src/services/pluginsManager/map/overlays/showDataOverlay/setBackgroundtoEmptyIfAvailable.test.ts delete mode 100644 src/services/pluginsManager/map/overlays/showDataOverlay/setBackgroundtoEmptyIfAvailable.ts delete mode 100644 src/types/mapLayers.ts diff --git a/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx b/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx index e1839e66..22c43bc9 100644 --- a/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx +++ b/src/components/FunctionalArea/MapNavigation/MapNavigation.component.test.tsx @@ -9,7 +9,6 @@ import { } from '@/utils/testing/getReduxWrapperWithStore'; import { act, render, screen, within } from '@testing-library/react'; import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { Project } from '@/types/models'; import { projectFixture } from '@/models/fixtures/projectFixture'; import { ProjectState } from '@/redux/project/project.types'; @@ -75,7 +74,6 @@ describe('MapNavigation - component', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); @@ -96,7 +94,6 @@ describe('MapNavigation - component', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); @@ -123,7 +120,6 @@ describe('MapNavigation - component', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); @@ -155,7 +151,6 @@ describe('MapNavigation - component', () => { modelId: HISTAMINE_MAP_ID, }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, loading: 'succeeded', error: { message: '', name: '' }, }, @@ -203,7 +198,6 @@ describe('MapNavigation - component', () => { modelId: HISTAMINE_MAP_ID, }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, loading: 'succeeded', error: { message: '', name: '' }, }, @@ -231,7 +225,6 @@ describe('MapNavigation - component', () => { modelId: HISTAMINE_MAP_ID, }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, loading: 'succeeded', error: { message: '', name: '' }, }, @@ -257,7 +250,6 @@ describe('MapNavigation - component', () => { modelId: HISTAMINE_MAP_ID, }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, loading: 'succeeded', error: { message: '', name: '' }, }, diff --git a/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.test.ts b/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.test.ts index 33e0afd0..4cf7330e 100644 --- a/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.test.ts +++ b/src/components/FunctionalArea/Modal/OverviewImagesModal/utils/useOverviewImageLinkActions.test.ts @@ -17,7 +17,6 @@ import { OverviewImageLink } from '@/types/models'; import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreActionsListener'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { renderHook } from '@testing-library/react'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MAIN_MAP_ID } from '@/constants/mocks'; import { FIRST_ARRAY_ELEMENT, @@ -61,7 +60,6 @@ describe('useOverviewImageLinkActions - hook', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); @@ -112,7 +110,6 @@ describe('useOverviewImageLinkActions - hook', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); @@ -170,7 +167,6 @@ describe('useOverviewImageLinkActions - hook', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { data: MODELS_MOCK_SHORT, @@ -249,7 +245,6 @@ describe('useOverviewImageLinkActions - hook', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { data: MODELS_MOCK_SHORT, @@ -354,7 +349,6 @@ describe('useOverviewImageLinkActions - hook', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { data: MODELS_MOCK_SHORT, @@ -412,7 +406,6 @@ describe('useOverviewImageLinkActions - hook', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { data: MODELS_MOCK_SHORT, @@ -474,7 +467,6 @@ describe('useOverviewImageLinkActions - hook', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { data: MODELS_MOCK_SHORT, @@ -538,7 +530,6 @@ describe('useOverviewImageLinkActions - hook', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { data: MODELS_MOCK_SHORT, diff --git a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/ElementsOnMapCell/ElementLink/ElementLink.component.test.tsx b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/ElementsOnMapCell/ElementLink/ElementLink.component.test.tsx index cdd2e42f..ea4fe1f6 100644 --- a/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/ElementsOnMapCell/ElementLink/ElementLink.component.test.tsx +++ b/src/components/FunctionalArea/Modal/PublicationsModal/PublicationsTable/ElementsOnMapCell/ElementLink/ElementLink.component.test.tsx @@ -14,7 +14,6 @@ import { import { render, screen, waitFor } from '@testing-library/react'; import { HttpStatusCode } from 'axios'; import { MockStoreEnhanced } from 'redux-mock-store'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { isReactionBioEntity } from '@/redux/reactions/isReactionBioentity'; import { ElementLink } from './ElementLink.component'; @@ -203,7 +202,6 @@ describe('ElementLink - component', () => { lastPosition: DEFAULT_POSITION, }, ], - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }, ); diff --git a/src/components/FunctionalArea/TopBar/TopBar.component.test.tsx b/src/components/FunctionalArea/TopBar/TopBar.component.test.tsx index f87cc56c..3f7463f3 100644 --- a/src/components/FunctionalArea/TopBar/TopBar.component.test.tsx +++ b/src/components/FunctionalArea/TopBar/TopBar.component.test.tsx @@ -10,10 +10,6 @@ import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreA import { PROJECT_STATE_INITIAL_MOCK } from '@/redux/project/project.mock'; import { projectFixture } from '@/models/fixtures/projectFixture'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; -import { - BACKGROUNDS_MOCK, - BACKGROUND_INITIAL_STATE_MOCK, -} from '@/redux/backgrounds/background.mock'; import { FIRST_ARRAY_ELEMENT } from '@/constants/common'; import { USER_INITIAL_STATE_MOCK } from '@/redux/user/user.mock'; import { SEARCH_STATE_INITIAL_MOCK } from '@/redux/search/search.mock'; @@ -103,7 +99,6 @@ describe('TopBar - component', () => { }, }, map: initialMapStateFixture, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, }); expect(screen.getByText('Browse overview images')).toBeInTheDocument(); }); @@ -121,7 +116,6 @@ describe('TopBar - component', () => { autocompleteSearch: AUTOCOMPLETE_INITIAL_STATE, autocompleteDrug: AUTOCOMPLETE_INITIAL_STATE, autocompleteChemical: AUTOCOMPLETE_INITIAL_STATE, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, }); const overviewImageButton = screen.getByText('Browse overview images'); @@ -149,7 +143,6 @@ describe('TopBar - component', () => { }, }, map: initialMapStateFixture, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, }); const overviewImageButton = screen.queryByText('Browse overview images'); diff --git a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx index 267ad439..84ff3087 100644 --- a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx +++ b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx @@ -18,7 +18,6 @@ import { getReduxWrapperWithStore, } from '@/utils/testing/getReduxWrapperWithStore'; import { act, render, screen } from '@testing-library/react'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import { AssociatedSubmap } from './AssociatedSubmap.component'; @@ -90,7 +89,6 @@ describe('AssociatedSubmap - component', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, bioEntity: { ...BIOENTITY_INITIAL_STATE_MOCK, @@ -150,7 +148,6 @@ describe('AssociatedSubmap - component', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, bioEntity: { ...BIOENTITY_INITIAL_STATE_MOCK, diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx index 906dd9ee..1a60d63d 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx @@ -1,5 +1,4 @@ import { FIRST_ARRAY_ELEMENT } from '@/constants/common'; -import { currentBackgroundSelector } from '@/redux/backgrounds/background.selectors'; import { downloadElements, downloadNetwork } from '@/redux/export/export.thunks'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; @@ -12,6 +11,7 @@ import { ReactNode, useCallback, useMemo, useState } from 'react'; import { activeOverlaysIdSelector } from '@/redux/overlayBioEntity/overlayBioEntity.selector'; import { DownloadCurrentView } from '@/components/Map/Drawer/ExportDrawer/ExportCompound/DownloadCurrentView/DownloadCurrentView.component'; import { getZoom } from '@/services/pluginsManager/map/zoom/getZoom'; +import { mapBackgroundSelector } from '@/redux/map/map.selectors'; import { CheckboxItem } from '../CheckboxFilter/CheckboxFilter.types'; import { Annotations } from './Annotations'; import { DownloadElements } from './DownloadElements/DownloadElements'; @@ -41,7 +41,7 @@ export const Export = ({ children }: ExportProps): JSX.Element => { const selectedModelId = useAppSelector(currentModelIdSelector); const currentModels = useAppSelector(modelsDataSelector); - const currentBackground = useAppSelector(currentBackgroundSelector); + const background = useAppSelector(mapBackgroundSelector); const overlays = useAppSelector(activeOverlaysIdSelector); const [annotations, setAnnotations] = useState<CheckboxItem[]>([]); const [includedCompartmentPathways, setIncludedCompartmentPathways] = useState<CheckboxItem[]>( @@ -82,7 +82,7 @@ export const Export = ({ children }: ExportProps): JSX.Element => { const model = currentModels.find(currentModel => currentModel.id === Number(modelId)); const url = getGraphicsDownloadUrl({ - backgroundId: currentBackground?.id, + backgroundId: background, modelId: models?.[FIRST_ARRAY_ELEMENT]?.id, handler: imageFormats?.[FIRST_ARRAY_ELEMENT]?.id, zoom: getModelExportZoom(imageSize.width, model), @@ -93,11 +93,11 @@ export const Export = ({ children }: ExportProps): JSX.Element => { if (url) { window.open(url); } - }, [models, imageFormats, currentBackground, currentModels, imageSize.width, overlays]); + }, [models, imageFormats, background, currentModels, imageSize.width, overlays]); const handleDownloadCurrentView = useCallback(async () => { const url = getGraphicsDownloadUrl({ - backgroundId: currentBackground?.id, + backgroundId: background, modelId: `${selectedModelId}`, handler: imageFormats?.[FIRST_ARRAY_ELEMENT]?.id, zoom: getZoom(), @@ -108,7 +108,7 @@ export const Export = ({ children }: ExportProps): JSX.Element => { if (url) { window.open(url); } - }, [selectedModelId, imageFormats, currentBackground, overlays]); + }, [selectedModelId, imageFormats, background, overlays]); const globalContextDataValue = useMemo( () => ({ diff --git a/src/components/Map/Drawer/OverlaysDrawer/GeneralOverlays/OverlayListItem/OverlayListItem.component.test.tsx b/src/components/Map/Drawer/OverlaysDrawer/GeneralOverlays/OverlayListItem/OverlayListItem.component.test.tsx index d1080df9..83ac53a3 100644 --- a/src/components/Map/Drawer/OverlaysDrawer/GeneralOverlays/OverlayListItem/OverlayListItem.component.test.tsx +++ b/src/components/Map/Drawer/OverlaysDrawer/GeneralOverlays/OverlayListItem/OverlayListItem.component.test.tsx @@ -4,10 +4,6 @@ import { InitialStoreState, getReduxWrapperWithStore, } from '@/utils/testing/getReduxWrapperWithStore'; -import { - BACKGROUNDS_MOCK, - BACKGROUND_INITIAL_STATE_MOCK, -} from '@/redux/backgrounds/background.mock'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse'; import { OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK } from '@/redux/overlayBioEntity/overlayBioEntity.mock'; @@ -19,11 +15,11 @@ import { MODELS_INITIAL_STATE_MOCK } from '@/redux/models/models.mock'; import { parseOverlayBioEntityToOlRenderingFormat } from '@/redux/overlayBioEntity/overlayBioEntity.utils'; import { BASE_API_URL } from '@/constants'; import { MAIN_MAP_ID } from '@/constants/mocks'; +import MapBackgroundsEnum from '@/redux/map/map.enums'; import { OverlayListItem } from './OverlayListItem.component'; const mockedAxiosNewClient = mockNetworkNewAPIResponse(); -const DEFAULT_BACKGROUND_ID = 0; -const EMPTY_BACKGROUND_ID = 15; +const DEFAULT_BACKGROUND_ID = 2; const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState); @@ -50,11 +46,10 @@ describe('OverlayListItem - component', () => { }); describe('view overlays', () => { - it('should trigger view overlays on view button click and switch background to Empty if available', async () => { + it('should trigger view overlays on view button click and switch background to Network', async () => { const OVERLAY_ID = 21; const { store } = renderComponent({ map: initialMapStateFixture, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, overlayBioEntity: OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK, models: { ...MODELS_INITIAL_STATE_MOCK, data: [CORE_PD_MODEL_MOCK] }, }); @@ -69,7 +64,7 @@ describe('OverlayListItem - component', () => { ViewButton.click(); }); - expect(store.getState().map.data.backgroundId).toBe(EMPTY_BACKGROUND_ID); + expect(store.getState().map.data.backgroundId).toBe(MapBackgroundsEnum.NETWORK); expect(store.getState().overlayBioEntity.data).toEqual({ [OVERLAY_ID]: { [MAIN_MAP_ID]: parseOverlayBioEntityToOlRenderingFormat( @@ -84,9 +79,8 @@ describe('OverlayListItem - component', () => { const { store } = renderComponent({ map: { ...initialMapStateFixture, - data: { ...initialMapStateFixture.data, backgroundId: EMPTY_BACKGROUND_ID }, + data: { ...initialMapStateFixture.data, backgroundId: MapBackgroundsEnum.NETWORK }, }, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, overlayBioEntity: { ...OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK, overlaysId: [OVERLAY_ID] }, models: { ...MODELS_INITIAL_STATE_MOCK, data: [CORE_PD_MODEL_MOCK] }, }); @@ -120,9 +114,8 @@ describe('OverlayListItem - component', () => { renderComponent({ map: { ...initialMapStateFixture, - data: { ...initialMapStateFixture.data, backgroundId: EMPTY_BACKGROUND_ID }, + data: { ...initialMapStateFixture.data, backgroundId: MapBackgroundsEnum.SEMANTIC }, }, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, overlayBioEntity: { ...OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK, overlaysId: [OVERLAY_ID] }, models: { ...MODELS_INITIAL_STATE_MOCK, data: [CORE_PD_MODEL_MOCK] }, }); diff --git a/src/components/Map/Drawer/OverlaysDrawer/hooks/useEmptyBackground.test.ts b/src/components/Map/Drawer/OverlaysDrawer/hooks/useEmptyBackground.test.ts deleted file mode 100644 index 9c58dfc3..00000000 --- a/src/components/Map/Drawer/OverlaysDrawer/hooks/useEmptyBackground.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; -import { initialMapStateFixture } from '@/redux/map/map.fixtures'; -import { - BACKGROUNDS_MOCK, - BACKGROUND_INITIAL_STATE_MOCK, -} from '@/redux/backgrounds/background.mock'; -import { renderHook } from '@testing-library/react'; -import { useEmptyBackground } from './useEmptyBackground'; - -const DEFAULT_BACKGROUND_ID = 0; -const EMPTY_BACKGROUND_ID = 15; - -describe('useEmptyBackground - hook', () => { - describe('returns setEmptyBackground function', () => { - it('should not set background to "Empty" if its not available', () => { - const { Wrapper, store } = getReduxWrapperWithStore({ - map: initialMapStateFixture, - backgrounds: BACKGROUND_INITIAL_STATE_MOCK, - }); - const { result } = renderHook(() => useEmptyBackground(), { wrapper: Wrapper }); - - expect(store.getState().map.data.backgroundId).toBe(DEFAULT_BACKGROUND_ID); - - result.current.setBackgroundtoEmptyIfAvailable(); - - expect(store.getState().map.data.backgroundId).toBe(DEFAULT_BACKGROUND_ID); - }); - - it('should set background to "Empty" if its available', () => { - const { Wrapper, store } = getReduxWrapperWithStore({ - map: initialMapStateFixture, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, - }); - const { result } = renderHook(() => useEmptyBackground(), { wrapper: Wrapper }); - - expect(store.getState().map.data.backgroundId).toBe(DEFAULT_BACKGROUND_ID); - - result.current.setBackgroundtoEmptyIfAvailable(); - - expect(store.getState().map.data.backgroundId).toBe(EMPTY_BACKGROUND_ID); - }); - }); -}); diff --git a/src/components/Map/Drawer/OverlaysDrawer/hooks/useEmptyBackground.ts b/src/components/Map/Drawer/OverlaysDrawer/hooks/useEmptyBackground.ts deleted file mode 100644 index 2536fa84..00000000 --- a/src/components/Map/Drawer/OverlaysDrawer/hooks/useEmptyBackground.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { useCallback } from 'react'; -import { emptyBackgroundIdSelector } from '@/redux/backgrounds/background.selectors'; -import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; -import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { setMapBackground } from '@/redux/map/map.slice'; - -type UseEmptyBackgroundReturn = { - setBackgroundtoEmptyIfAvailable: () => void; -}; - -export const useEmptyBackground = (): UseEmptyBackgroundReturn => { - const dispatch = useAppDispatch(); - const emptyBackgroundId = useAppSelector(emptyBackgroundIdSelector); - - const setBackgroundtoEmptyIfAvailable = useCallback(() => { - if (emptyBackgroundId) { - dispatch(setMapBackground(emptyBackgroundId)); - } - }, [dispatch, emptyBackgroundId]); - - return { setBackgroundtoEmptyIfAvailable }; -}; diff --git a/src/components/Map/Drawer/OverlaysDrawer/hooks/useOverlay.ts b/src/components/Map/Drawer/OverlaysDrawer/hooks/useOverlay.ts index 084877fd..bca5b9ad 100644 --- a/src/components/Map/Drawer/OverlaysDrawer/hooks/useOverlay.ts +++ b/src/components/Map/Drawer/OverlaysDrawer/hooks/useOverlay.ts @@ -14,7 +14,8 @@ import { addOverlayToOverlaysId, removeOverlayFromOverlaysId, } from '@/redux/overlayBioEntity/overlayBioEntity.slice'; -import { useEmptyBackground } from './useEmptyBackground'; +import { setMapBackground } from '@/redux/map/map.slice'; +import MapBackgroundsEnum from '@/redux/map/map.enums'; type UseOverlay = { toggleOverlay: () => void; @@ -27,7 +28,6 @@ export const useOverlay = (overlayId: number): UseOverlay => { const dispatch = useAppDispatch(); const isOverlayActive = useAppSelector(state => isOverlayActiveSelector(state, overlayId)); const isOverlayLoading = useAppSelector(state => isOverlayLoadingSelector(state, overlayId)); - const { setBackgroundtoEmptyIfAvailable } = useEmptyBackground(); const overlay = useAppSelector(state => overlaySelector(state, overlayId)); const areOverlayBioEntitiesLoaded = useAppSelector(state => areOverlayBioEntitiesLoadedSelector(state, overlayId), @@ -55,7 +55,7 @@ export const useOverlay = (overlayId: number): UseOverlay => { } else { await dispatch(getOverlayBioEntityForAllModels({ overlayId })); } - setBackgroundtoEmptyIfAvailable(); + dispatch(setMapBackground(MapBackgroundsEnum.NETWORK)); } dispatchPluginEvents(); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx index 62654f69..a93282db 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesSubmapItem/BioEntitiesSubmapItem.component.test.tsx @@ -13,7 +13,6 @@ import { openedMapsInitialValueFixture, openedMapsThreeSubmapsFixture, } from '@/redux/map/map.fixtures'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MAIN_MAP_ID } from '@/constants/mocks'; import { BioEntitiesSubmapItem } from './BioEntitiesSubmapItem.component'; @@ -100,7 +99,6 @@ describe('BioEntitiesSubmapItem - component', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); @@ -158,7 +156,6 @@ describe('BioEntitiesSubmapItem - component', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx index 23c0490f..0b9a5de5 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx @@ -11,7 +11,6 @@ import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/ma import { MODELS_DATA_MOCK_WITH_MAIN_MAP } from '@/redux/models/models.mock'; import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreActionsListener'; import { MockStoreEnhanced } from 'redux-mock-store'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MAIN_MAP_ID } from '@/constants/mocks'; import { PinTypeWithNone } from '../PinsList.types'; import { PinsListItem } from './PinsListItem.component'; @@ -39,7 +38,6 @@ const INITIAL_STORE_STATE: InitialStoreState = { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }; @@ -172,7 +170,6 @@ describe('PinsListItem - component ', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }, ); @@ -206,7 +203,6 @@ describe('PinsListItem - component ', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }, ); diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.test.tsx b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.test.tsx index 4789c9c5..b753634e 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.test.tsx +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/DownloadSubmap.component.test.tsx @@ -1,5 +1,4 @@ import { FIRST_ARRAY_ELEMENT } from '@/constants/common'; -import { backgroundsFixture } from '@/models/fixtures/backgroundsFixture'; import { configurationFixture } from '@/models/fixtures/configurationFixture'; import { modelsFixture } from '@/models/fixtures/modelsFixture'; import { @@ -44,15 +43,6 @@ const getState = (): RootState => ({ }, ], }, - backgrounds: { - ...INITIAL_STORE_STATE_MOCK.backgrounds, - data: [ - { - ...backgroundsFixture[FIRST_ARRAY_ELEMENT], - id: VALID_BACKGROUND_ID, - }, - ], - }, configuration: { ...INITIAL_STORE_STATE_MOCK.configuration, main: { diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.test.ts b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.test.ts index 8bb6e92d..8c078809 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.test.ts +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.test.ts @@ -1,6 +1,5 @@ import { BASE_API_URL, PROJECT_ID } from '@/constants'; import { FIRST_ARRAY_ELEMENT } from '@/constants/common'; -import { backgroundsFixture } from '@/models/fixtures/backgroundsFixture'; import { modelsFixture } from '@/models/fixtures/modelsFixture'; import { INITIAL_STORE_STATE_MOCK } from '@/redux/root/root.fixtures'; import { RootState } from '@/redux/store'; @@ -45,15 +44,6 @@ const getState = ({ }, ], }, - backgrounds: { - ...INITIAL_STORE_STATE_MOCK.backgrounds, - data: [ - { - ...backgroundsFixture[FIRST_ARRAY_ELEMENT], - id: VALID_BACKGROUND_ID, - }, - ], - }, }); describe('useGetSubmapDownloadUrl - hook', () => { diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.ts b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.ts index 397f7aad..5d05f263 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.ts +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapItem/DownloadSubmap/utils/useGetSubmapDownloadUrl.ts @@ -1,6 +1,5 @@ import { BASE_API_URL, PROJECT_ID } from '@/constants'; -import { currentBackgroundSelector } from '@/redux/backgrounds/background.selectors'; -import { mapDataSizeSelector } from '@/redux/map/map.selectors'; +import { mapBackgroundSelector, mapDataSizeSelector } from '@/redux/map/map.selectors'; import { currentModelSelector } from '@/redux/models/models.selectors'; import { useSelector } from 'react-redux'; @@ -8,11 +7,11 @@ export type GetSubmapDownloadUrl = ({ handler }: { handler: string }) => string; export const useGetSubmapDownloadUrl = (): GetSubmapDownloadUrl => { const model = useSelector(currentModelSelector); - const background = useSelector(currentBackgroundSelector); + const background = useSelector(mapBackgroundSelector); const mapSize = useSelector(mapDataSizeSelector); const getSubmapDownloadUrl: GetSubmapDownloadUrl = ({ handler }) => { - const allParamsValid = [model?.id, background?.id, mapSize.maxZoom, handler].reduce( + const allParamsValid = [model?.id, background, mapSize.maxZoom, handler].reduce( (a, b) => Boolean(a) && Boolean(b), true, ); @@ -20,7 +19,7 @@ export const useGetSubmapDownloadUrl = (): GetSubmapDownloadUrl => { return ''; } - return `${BASE_API_URL}/projects/${PROJECT_ID}/models/${model?.id}:downloadModel?backgroundOverlayId=${background?.id}&handlerClass=${handler}&zoomLevel=${mapSize.maxZoom}`; + return `${BASE_API_URL}/projects/${PROJECT_ID}/models/${model?.id}:downloadModel?backgroundOverlayId=${background}&handlerClass=${handler}&zoomLevel=${mapSize.maxZoom}`; }; return getSubmapDownloadUrl; diff --git a/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.test.tsx b/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.test.tsx index 492be6cb..d4a6e092 100644 --- a/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.test.tsx +++ b/src/components/Map/Drawer/SubmapsDrawer/SubmapsDrawer.test.tsx @@ -11,7 +11,6 @@ import { openedMapsInitialValueFixture, openedMapsThreeSubmapsFixture, } from '@/redux/map/map.fixtures'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import { SubmapsDrawer } from './SubmapsDrawer'; @@ -63,7 +62,6 @@ describe('SubmapsDrawer - component', () => { loading: 'succeeded', error: { name: '', message: '' }, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); @@ -109,7 +107,6 @@ describe('SubmapsDrawer - component', () => { openedMaps: openedMapsThreeSubmapsFixture, loading: 'succeeded', error: { name: '', message: '' }, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); diff --git a/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.test.tsx b/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.test.tsx index 5fe7353f..06bd09fe 100644 --- a/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.test.tsx +++ b/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.test.tsx @@ -11,7 +11,6 @@ import { import { act, render, screen } from '@testing-library/react'; import Map from 'ol/Map'; import { MockStoreEnhanced } from 'redux-mock-store'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MapAdditionalActions } from './MapAdditionalActions.component'; import { useVisibleBioEntitiesPolygonCoordinates } from './utils/useVisibleBioEntitiesPolygonCoordinates'; @@ -146,7 +145,6 @@ describe('MapAdditionalActions - component', () => { message: '', }, openedMaps: [], - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); diff --git a/src/components/Map/MapAdditionalActions/utils/useAdditionalActions.test.ts b/src/components/Map/MapAdditionalActions/utils/useAdditionalActions.test.ts index a65473f7..de9d56f1 100644 --- a/src/components/Map/MapAdditionalActions/utils/useAdditionalActions.test.ts +++ b/src/components/Map/MapAdditionalActions/utils/useAdditionalActions.test.ts @@ -8,7 +8,6 @@ import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreA import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { renderHook } from '@testing-library/react'; import Map from 'ol/Map'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { useAddtionalActions } from './useAdditionalActions'; import { useVisibleBioEntitiesPolygonCoordinates } from './useVisibleBioEntitiesPolygonCoordinates'; @@ -95,7 +94,6 @@ describe('useAddtionalActions - hook', () => { message: '', }, openedMaps: [], - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }, { diff --git a/src/components/Map/MapAdditionalOptions/BackgroundsSelector/BackgroundsSelector.component.test.tsx b/src/components/Map/MapAdditionalOptions/BackgroundsSelector/BackgroundsSelector.component.test.tsx deleted file mode 100644 index 8aaf2bd1..00000000 --- a/src/components/Map/MapAdditionalOptions/BackgroundsSelector/BackgroundsSelector.component.test.tsx +++ /dev/null @@ -1,104 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { StoreType } from '@/redux/store'; -import { render, screen } from '@testing-library/react'; -import { act } from 'react-dom/test-utils'; -import { initialMapDataFixture, initialMapStateFixture } from '@/redux/map/map.fixtures'; -import { - InitialStoreState, - getReduxWrapperWithStore, -} from '@/utils/testing/getReduxWrapperWithStore'; -import { - BACKGROUNDS_MOCK, - BACKGROUND_INITIAL_STATE_MOCK, -} from '@/redux/backgrounds/background.mock'; -import { BackgroundSelector } from './BackgroundsSelector.component'; - -const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { - const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState); - - return ( - render( - <Wrapper> - <BackgroundSelector /> - </Wrapper>, - ), - { - store, - } - ); -}; - -describe('BackgroundSelector - component', () => { - it('should initialy display default value', () => { - renderComponent(); - - const buttonName = screen.getByTestId('background-dropdown-button-name'); - - expect(buttonName.textContent).toBe('Background'); - }); - - it("should display selected value name when it's not main background", async () => { - renderComponent({ - map: initialMapStateFixture, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, - }); - - const buttonName = screen.getByTestId('background-dropdown-button-name'); - await act(() => { - buttonName.click(); - }); - expect(buttonName.textContent).toBe('Background'); - - const backgroundButton = screen.getByText('Network'); - await act(() => { - backgroundButton.click(); - }); - - expect(buttonName.textContent).toBe('Network'); - }); - - it('should change redux map state on selecting background', async () => { - const { store } = renderComponent({ - map: initialMapStateFixture, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, - }); - expect(store.getState().map.data.modelId).toBe(0); - - const buttonName = screen.getByTestId('background-dropdown-button-name'); - await act(() => { - buttonName.click(); - }); - - const backgroundButton = screen.getByText('Network'); - await act(() => { - backgroundButton.click(); - }); - - expect(store.getState().map.data.backgroundId).toBe(14); - }); - - describe('query params', () => { - it('should display default value when main background id is in query params', async () => { - await renderComponent({ - map: { ...initialMapStateFixture, data: { ...initialMapDataFixture, backgroundId: 13 } }, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, - }); - - const buttonName = screen.getByTestId('background-dropdown-button-name'); - expect(buttonName.textContent).toBe('Background'); - }); - it('should display correct background when background id is in query params', async () => { - await renderComponent({ - map: { ...initialMapStateFixture, data: { ...initialMapDataFixture, backgroundId: 15 } }, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, - }); - - const buttonName = screen.getByTestId('background-dropdown-button-name'); - expect(buttonName.textContent).toBe('Empty'); - }); - it.skip('should set backgroundid in query on selecting background', () => { - // TODO e2e - expect(true).toBe(false); - }); - }); -}); diff --git a/src/components/Map/MapAdditionalOptions/BackgroundsSelector/BackgroundsSelector.component.tsx b/src/components/Map/MapAdditionalOptions/BackgroundsSelector/BackgroundsSelector.component.tsx deleted file mode 100644 index 610cb371..00000000 --- a/src/components/Map/MapAdditionalOptions/BackgroundsSelector/BackgroundsSelector.component.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import { useSelect } from 'downshift'; -import { - backgroundsDataSelector, - currentBackgroundSelector, - mainBackgroundIdSelector, -} from '@/redux/backgrounds/background.selectors'; -import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { twMerge } from 'tailwind-merge'; -import { Icon } from '@/shared/Icon'; -import { MapBackground } from '@/types/models'; -import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; -import { setMapBackground } from '@/redux/map/map.slice'; - -const DEFAULT_TOGGLE_BUTTON_TEXT = 'Background'; - -export const BackgroundSelector = (): JSX.Element => { - const selectedBackground = useAppSelector(currentBackgroundSelector); - const dispatch = useAppDispatch(); - const backgrounds = useAppSelector(backgroundsDataSelector); - const mainBackgroundId = useAppSelector(mainBackgroundIdSelector); - - const onItemSelect = (background: MapBackground | undefined | null): void => { - if (background) { - dispatch(setMapBackground(background.id)); - } - }; - - const { isOpen, getToggleButtonProps, getMenuProps, highlightedIndex, getItemProps } = useSelect({ - items: backgrounds || [], - selectedItem: selectedBackground, - onSelectedItemChange: ({ selectedItem: newSelectedItem }) => onItemSelect(newSelectedItem), - }); - - const getToggleButtonName = (): string => { - const isSelectedBackgroundMainBackground = selectedBackground?.id === mainBackgroundId; - if (!selectedBackground || isSelectedBackgroundMainBackground) { - return DEFAULT_TOGGLE_BUTTON_TEXT; - } - return selectedBackground.name; - }; - - return ( - <div - data-testid="background-selector" - className={twMerge('rounded-t bg-white text-xs shadow-primary', !isOpen && 'rounded-b')} - > - <div className={twMerge('flex w-[135px] flex-col rounded-t py-2 pl-4 pr-3')}> - <div - className="flex cursor-pointer flex-row items-center justify-between bg-white" - {...getToggleButtonProps()} - > - <span data-testid="background-dropdown-button-name" className="font-medium"> - {getToggleButtonName()} - </span> - <Icon - name="chevron-down" - className={twMerge('arrow-button h-6 w-6 fill-primary-500', isOpen && 'rotate-180')} - /> - </div> - </div> - <ul - className={`absolute z-10 max-h-80 w-[135px] overflow-scroll rounded-b bg-white p-0 ${ - !isOpen && 'hidden' - }`} - {...getMenuProps()} - > - {isOpen && - backgrounds && - backgrounds.map((item, index) => ( - <li - className={twMerge( - 'border-t', - highlightedIndex === index && 'text-primary-500', - selectedBackground === item && 'font-bold', - 'flex flex-col px-4 py-2 shadow-sm', - )} - key={item.id} - {...getItemProps({ item, index })} - > - <span>{item.name}</span> - </li> - ))} - </ul> - </div> - ); -}; diff --git a/src/components/Map/MapAdditionalOptions/BackgroundsSelector/index.ts b/src/components/Map/MapAdditionalOptions/BackgroundsSelector/index.ts deleted file mode 100644 index 0b379515..00000000 --- a/src/components/Map/MapAdditionalOptions/BackgroundsSelector/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { BackgroundSelector } from './BackgroundsSelector.component'; diff --git a/src/components/Map/MapAdditionalOptions/MapAdditionalOptions.component.test.tsx b/src/components/Map/MapAdditionalOptions/MapAdditionalOptions.component.test.tsx deleted file mode 100644 index 5b877e38..00000000 --- a/src/components/Map/MapAdditionalOptions/MapAdditionalOptions.component.test.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { StoreType } from '@/redux/store'; -import { - InitialStoreState, - getReduxWrapperWithStore, -} from '@/utils/testing/getReduxWrapperWithStore'; -import { render, screen } from '@testing-library/react'; -import { MapAdditionalOptions } from './MapAdditionalOptions.component'; - -const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { - const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState); - - return ( - render( - <Wrapper> - <MapAdditionalOptions /> - </Wrapper>, - ), - { - store, - } - ); -}; - -describe('MapAdditionalOptions - component', () => { - it('should display background selector', () => { - renderComponent(); - expect(screen.getByTestId('background-selector')).toBeInTheDocument(); - }); -}); diff --git a/src/components/Map/MapAdditionalOptions/MapAdditionalOptions.component.tsx b/src/components/Map/MapAdditionalOptions/MapAdditionalOptions.component.tsx deleted file mode 100644 index ce96a907..00000000 --- a/src/components/Map/MapAdditionalOptions/MapAdditionalOptions.component.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { twMerge } from 'tailwind-merge'; -import { BackgroundSelector } from './BackgroundsSelector'; - -// top-[calc(64px+40px+24px)] -> TOP_BAR_HEIGHT+MAP_NAVIGATION_HEIGHT+DISTANCE_FROM_MAP_NAVIGATION - -export const MapAdditionalOptions = (): JSX.Element => ( - <div className={twMerge('absolute right-6 top-[calc(64px+40px+24px)] z-10 flex')}> - <BackgroundSelector /> - </div> -); diff --git a/src/components/Map/MapAdditionalOptions/index.ts b/src/components/Map/MapAdditionalOptions/index.ts deleted file mode 100644 index ff61a27a..00000000 --- a/src/components/Map/MapAdditionalOptions/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { MapAdditionalOptions } from './MapAdditionalOptions.component'; diff --git a/src/components/Map/MapVectorBackgroundSelector/MapVectorBackgroundSelector.component.tsx b/src/components/Map/MapVectorBackgroundSelector/MapVectorBackgroundSelector.component.tsx index 97463f27..caea44b9 100644 --- a/src/components/Map/MapVectorBackgroundSelector/MapVectorBackgroundSelector.component.tsx +++ b/src/components/Map/MapVectorBackgroundSelector/MapVectorBackgroundSelector.component.tsx @@ -1,24 +1,24 @@ import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { mapBackgroundTypeSelector } from '@/redux/map/map.selectors'; +import { mapBackgroundSelector } from '@/redux/map/map.selectors'; import { twMerge } from 'tailwind-merge'; import { MAP_BACKGROUND_TYPES } from '@/redux/map/map.constants'; -import { setMapBackgroundType } from '@/redux/map/map.slice'; +import { setMapBackground } from '@/redux/map/map.slice'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { Select } from '@/shared/Select'; export const MapVectorBackgroundSelector = (): JSX.Element => { const dispatch = useAppDispatch(); - const backgroundType = useAppSelector(mapBackgroundTypeSelector); + const backgroundId = useAppSelector(mapBackgroundSelector); - const handleChange = (selectedBackgroundType: string | number): void => { - dispatch(setMapBackgroundType(+selectedBackgroundType)); + const handleChange = (selectedBackgroundId: string | number): void => { + dispatch(setMapBackground(+selectedBackgroundId)); }; return ( <div className={twMerge('absolute right-6 top-[calc(64px+40px+24px)] z-10 flex')}> <Select options={MAP_BACKGROUND_TYPES} - selectedId={backgroundType} + selectedId={backgroundId} onChange={handleChange} width={140} /> diff --git a/src/components/Map/MapViewer/MapViewer.component.test.tsx b/src/components/Map/MapViewer/MapViewer.component.test.tsx index 23485420..ea37b540 100644 --- a/src/components/Map/MapViewer/MapViewer.component.test.tsx +++ b/src/components/Map/MapViewer/MapViewer.component.test.tsx @@ -1,7 +1,6 @@ import { render, screen } from '@testing-library/react'; import { StoreType } from '@/redux/store'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; -import { BACKGROUND_INITIAL_STATE_MOCK } from '@/redux/backgrounds/background.mock'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { MapViewer } from './MapViewer.component'; import { MAP_VIEWER_ROLE } from './MapViewer.constants'; @@ -9,7 +8,6 @@ import { MAP_VIEWER_ROLE } from './MapViewer.constants'; const renderComponent = (): { store: StoreType } => { const { Wrapper, store } = getReduxWrapperWithStore({ map: initialMapStateFixture, - backgrounds: BACKGROUND_INITIAL_STATE_MOCK, }); return ( diff --git a/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts index eba9fde5..a23de57b 100644 --- a/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts +++ b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts @@ -3,7 +3,6 @@ import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithSto import { renderHook } from '@testing-library/react'; import VectorLayer from 'ol/layer/Vector'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; -import { BACKGROUND_INITIAL_STATE_MOCK } from '@/redux/backgrounds/background.mock'; import { Map } from 'ol'; import { useOlMapAdditionalLayers } from '@/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers'; @@ -11,7 +10,6 @@ describe('useOlMapAdditionalLayers - util', () => { it('should return VectorLayer', () => { const { Wrapper } = getReduxWrapperWithStore({ map: initialMapStateFixture, - backgrounds: BACKGROUND_INITIAL_STATE_MOCK, }); const dummyElement = document.createElement('div'); diff --git a/src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.test.ts b/src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.test.ts index dd9a5220..bec6905d 100644 --- a/src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.test.ts +++ b/src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.test.ts @@ -5,7 +5,6 @@ import { renderHook } from '@testing-library/react'; import BaseLayer from 'ol/layer/Base'; import VectorLayer from 'ol/layer/Vector'; import React from 'react'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { useOlMapCardLayer } from './useOlMapCardLayer'; const useRefValue = { @@ -59,7 +58,6 @@ describe('useOlMapCardLayer - util', () => { message: '', }, openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); diff --git a/src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts b/src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts index 25aa2078..87c6d666 100644 --- a/src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts +++ b/src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts @@ -24,7 +24,7 @@ export default function processModelElements( vectorSource: VectorSource, mapInstance: MapInstance, pointToProjection: UsePointToProjectionResult, - mapBackgroundType: number, + backgroundId: number, mapSize: MapSize, ): Array<MapElement | CompartmentCircle | CompartmentSquare | CompartmentPathway | Glyph> { const overlaysVisible = Boolean(overlaysOrder.length); @@ -78,7 +78,7 @@ export default function processModelElements( pointToProjection, mapInstance, vectorSource, - mapBackgroundType, + backgroundId, mapSize, }; if (element.shape === 'OVAL_COMPARTMENT') { @@ -129,7 +129,7 @@ export default function processModelElements( overlaysOrder, overlaysVisible, getOverlayColor, - mapBackgroundType, + backgroundId, mapSize, }), ); diff --git a/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts index c8e961ed..c03a9e9f 100644 --- a/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts +++ b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts @@ -2,7 +2,6 @@ import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithSto import { renderHook } from '@testing-library/react'; import VectorLayer from 'ol/layer/Vector'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; -import { BACKGROUND_INITIAL_STATE_MOCK } from '@/redux/backgrounds/background.mock'; import { Map } from 'ol'; import { useOlMapProcessLayer } from '@/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer'; @@ -10,7 +9,6 @@ describe('useOlMapReactionsLayer - util', () => { it('should return VectorLayer', () => { const { Wrapper } = getReduxWrapperWithStore({ map: initialMapStateFixture, - backgrounds: BACKGROUND_INITIAL_STATE_MOCK, }); const dummyElement = document.createElement('div'); diff --git a/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts index 09d5b04e..2837c80b 100644 --- a/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts +++ b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts @@ -35,9 +35,7 @@ import { markersSufraceOfCurrentMapDataSelector } from '@/redux/markers/markers. import { parseSurfaceMarkersToBioEntityRender } from '@/components/Map/MapViewer/utils/config/overlaysLayer/parseSurfaceMarkersToBioEntityRender'; import processModelElements from '@/components/Map/MapViewer/utils/config/processLayer/processModelElements'; import useDebouncedValue from '@/utils/useDebouncedValue'; -import { mapBackgroundTypeSelector, mapDataSizeSelector } from '@/redux/map/map.selectors'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; -import { setMapBackgroundType } from '@/redux/map/map.slice'; +import { mapBackgroundSelector, mapDataSizeSelector } from '@/redux/map/map.selectors'; import { ZOOM_RESCALING_FACTOR } from '@/constants/map'; import { OverlayOrder } from '@/redux/overlayBioEntity/overlayBioEntity.utils'; import MarkerOverlay from '@/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay'; @@ -65,7 +63,7 @@ export const useOlMapProcessLayer = ({ const lineTypes = useSelector(lineTypesSelector); const arrowTypes = useSelector(arrowTypesSelector); const overlaysOrder = useSelector(getOverlayOrderSelector); - const mapBackgroundType = useSelector(mapBackgroundTypeSelector); + const backgroundId = useSelector(mapBackgroundSelector); const currentMarkers = useAppSelector(markersSufraceOfCurrentMapDataSelector); const markersRender = useMemo(() => { return parseSurfaceMarkersToBioEntityRender(currentMarkers); @@ -108,12 +106,6 @@ export const useOlMapProcessLayer = ({ } }, [currentModelId, dispatch, reactionsLoading, modelElementsLoading]); - useEffect(() => { - if (overlaysOrderState.length) { - dispatch(setMapBackgroundType(MapBackgroundsEnum.NETWORK)); - } - }, [dispatch, overlaysOrderState]); - const groupedElementsOverlays = useMemo(() => { const elementsBioEntitesOverlay = debouncedBioEntities.filter( bioEntity => bioEntity.type !== 'line', @@ -219,7 +211,7 @@ export const useOlMapProcessLayer = ({ vectorSource, mapInstance, pointToProjection, - mapBackgroundType, + backgroundId, mapSize, ); }, [ @@ -233,7 +225,7 @@ export const useOlMapProcessLayer = ({ vectorSource, mapInstance, pointToProjection, - mapBackgroundType, + backgroundId, mapSize, ]); diff --git a/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts b/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts index 3fe8e861..4b52f2cd 100644 --- a/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts +++ b/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts @@ -7,7 +7,6 @@ import VectorLayer from 'ol/layer/Vector'; import React from 'react'; import { useOlMap } from '@/components/Map/MapViewer/utils/useOlMap'; import { useOlMapLayers } from '@/components/Map/MapViewer/utils/config/useOlMapLayers'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; const useRefValue = { current: null, @@ -60,7 +59,6 @@ describe('useOlMapLayers - util', () => { message: '', }, openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); const dummyElement = document.createElement('div'); diff --git a/src/components/Map/MapViewer/utils/config/useOlMapTileLayer.test.ts b/src/components/Map/MapViewer/utils/config/useOlMapTileLayer.test.ts deleted file mode 100644 index 58e4aaa5..00000000 --- a/src/components/Map/MapViewer/utils/config/useOlMapTileLayer.test.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { MAP_DATA_INITIAL_STATE, OPENED_MAPS_INITIAL_STATE } from '@/redux/map/map.constants'; -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; -import { renderHook } from '@testing-library/react'; -import BaseLayer from 'ol/layer/Base'; -import TileLayer from 'ol/layer/Tile'; -import React from 'react'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; -import { useOlMapTileLayer } from './useOlMapTileLayer'; - -const useRefValue = { - current: null, -}; - -Object.defineProperty(useRefValue, 'current', { - get: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), - set: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), -}); - -jest.spyOn(React, 'useRef').mockReturnValue(useRefValue); - -describe('useOlMapTileLayer - util', () => { - const getRenderedHookResults = (): BaseLayer => { - const { Wrapper } = getReduxWrapperWithStore({ - map: { - data: { - ...MAP_DATA_INITIAL_STATE, - size: { - width: 256, - height: 256, - tileSize: 256, - minZoom: 1, - maxZoom: 1, - }, - position: { - initial: { - x: 256, - y: 256, - }, - last: { - x: 256, - y: 256, - }, - }, - }, - loading: 'idle', - error: { - name: '', - message: '', - }, - openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, - }, - }); - - const { result } = renderHook(() => useOlMapTileLayer(), { - wrapper: Wrapper, - }); - - return result.current; - }; - - it('should return valid TileLayer instance', () => { - const result = getRenderedHookResults(); - - expect(result).toBeInstanceOf(TileLayer); - expect(result.getSourceState()).toBe('ready'); - }); -}); diff --git a/src/components/Map/MapViewer/utils/config/useOlMapTileLayer.ts b/src/components/Map/MapViewer/utils/config/useOlMapTileLayer.ts deleted file mode 100644 index d98b480f..00000000 --- a/src/components/Map/MapViewer/utils/config/useOlMapTileLayer.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { OPTIONS } from '@/constants/map'; -import { currentBackgroundImagePathSelector } from '@/redux/backgrounds/background.selectors'; -import { mapDataSizeSelector } from '@/redux/map/map.selectors'; -import { projectDataSelector } from '@/redux/project/project.selectors'; -import { Point } from '@/types/map'; -import { usePointToProjection } from '@/utils/map/usePointToProjection'; -import { Extent, boundingExtent } from 'ol/extent'; -import BaseLayer from 'ol/layer/Base'; -import TileLayer from 'ol/layer/Tile'; -import { XYZ } from 'ol/source'; -import { useMemo } from 'react'; -import { useSelector } from 'react-redux'; -import { getMapTileUrl } from './getMapTileUrl'; - -// useOlMapTileLayer returns visual tile layer of the map -// it makes it possible to view the map, scroll, zoom etc. -export const useOlMapTileLayer = (): BaseLayer => { - const mapSize = useSelector(mapDataSizeSelector); - const currentBackgroundImagePath = useSelector(currentBackgroundImagePathSelector); - const project = useSelector(projectDataSelector); - const pointToProjection = usePointToProjection(); - - const tileExtent = useMemo((): Extent => { - const topLeftPoint: Point = { - x: mapSize.width, - y: mapSize.height, - }; - - const bottomRightPoint: Point = { - x: 0, - y: 0, - }; - - return boundingExtent([topLeftPoint, bottomRightPoint].map(pointToProjection)); - }, [pointToProjection, mapSize]); - - const sourceUrl = useMemo( - () => getMapTileUrl({ projectDirectory: project?.directory, currentBackgroundImagePath }), - [project?.directory, currentBackgroundImagePath], - ); - - const source = useMemo( - () => - new XYZ({ - url: sourceUrl, - maxZoom: mapSize.maxZoom, - minZoom: mapSize.minZoom, - tileSize: Math.max(mapSize.tileSize, 1), - wrapX: OPTIONS.wrapXInTileLayer, - }), - [sourceUrl, mapSize.maxZoom, mapSize.minZoom, mapSize.tileSize], - ); - - const tileLayer = useMemo( - (): TileLayer<XYZ> => - new TileLayer({ - visible: true, - source, - extent: tileExtent, - }), - [source, tileExtent], - ); - - return tileLayer; -}; diff --git a/src/components/Map/MapViewer/utils/config/useOlMapView.test.ts b/src/components/Map/MapViewer/utils/config/useOlMapView.test.ts index d630b12b..0a786468 100644 --- a/src/components/Map/MapViewer/utils/config/useOlMapView.test.ts +++ b/src/components/Map/MapViewer/utils/config/useOlMapView.test.ts @@ -1,8 +1,4 @@ /* eslint-disable no-magic-numbers */ -import { - BACKGROUNDS_MOCK, - BACKGROUND_INITIAL_STATE_MOCK, -} from '@/redux/backgrounds/background.mock'; import { MAP_DATA_INITIAL_STATE, OPENED_MAPS_INITIAL_STATE } from '@/redux/map/map.constants'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; import { setMapPosition } from '@/redux/map/map.slice'; @@ -11,7 +7,6 @@ import { act, renderHook, waitFor } from '@testing-library/react'; import { View } from 'ol'; import Map from 'ol/Map'; import React from 'react'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { useOlMap } from '../useOlMap'; import { useOlMapView } from './useOlMapView'; @@ -40,7 +35,6 @@ describe('useOlMapView - util', () => { it('should modify view of the map instance on INITIAL position config change', async () => { const { Wrapper, store } = getReduxWrapperWithStore({ map: initialMapStateFixture, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, }); const dummyElement = document.createElement('div'); @@ -96,9 +90,7 @@ describe('useOlMapView - util', () => { message: '', }, openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, - backgrounds: BACKGROUND_INITIAL_STATE_MOCK, }); const dummyElement = document.createElement('div'); const { result: hohResult } = renderHook(() => useOlMap({ target: dummyElement }), { diff --git a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts index 328c827b..2b2fabe1 100644 --- a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts @@ -3,7 +3,6 @@ import { renderHook } from '@testing-library/react'; import { View } from 'ol'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import * as positionListener from '@/components/Map/MapViewer/utils/listeners/onMapPositionChange'; import { useOlMapListeners } from '@/components/Map/MapViewer/utils/listeners/useOlMapListeners'; import { onMapLeftClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; @@ -32,7 +31,6 @@ describe('useOlMapListeners - util', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); diff --git a/src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts b/src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts index 23277551..59af80b8 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts @@ -49,7 +49,7 @@ export interface BaseMapElementProps { pointToProjection: UsePointToProjectionResult; overlaysVisible: boolean; vectorSource: VectorSource; - mapBackgroundType: number; + backgroundId: number; mapSize: MapSize; mapInstance: MapInstance; } @@ -117,7 +117,7 @@ export default abstract class BaseMultiPolygon { vectorSource: VectorSource; - mapBackgroundType: number; + backgroundId: number; mapSize: MapSize; @@ -153,7 +153,7 @@ export default abstract class BaseMultiPolygon { pointToProjection, overlaysVisible, vectorSource, - mapBackgroundType, + backgroundId, mapSize, mapInstance, }: BaseMapElementProps) { @@ -181,7 +181,7 @@ export default abstract class BaseMultiPolygon { this.overlaysVisible = overlaysVisible; this.pointToProjection = pointToProjection; this.vectorSource = vectorSource; - this.mapBackgroundType = mapBackgroundType; + this.backgroundId = backgroundId; this.mapSize = mapSize; const maxZoom = mapInstance?.getView().get('originalMaxZoom'); @@ -371,7 +371,7 @@ export default abstract class BaseMultiPolygon { const styles: Array<Style> = []; const scale = this.minResolution / resolution; - if (this.mapBackgroundType === MapBackgroundsEnum.SEMANTIC && scale < TEXT_CUTOFF_SCALE) { + if (this.backgroundId === MapBackgroundsEnum.SEMANTIC && scale < TEXT_CUTOFF_SCALE) { const { hide, coverStyle } = this.processSemanticView(feature, resolution, scale); if (hide) { return undefined; diff --git a/src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts b/src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts index 10802411..76770a4b 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts @@ -45,7 +45,7 @@ export interface CompartmentProps { pointToProjection: UsePointToProjectionResult; mapInstance: MapInstance; vectorSource: VectorSource; - mapBackgroundType: number; + backgroundId: number; mapSize: MapSize; } @@ -90,7 +90,7 @@ export default abstract class Compartment extends BaseMultiPolygon { pointToProjection, mapInstance, vectorSource, - mapBackgroundType, + backgroundId, mapSize, }: CompartmentProps) { super({ @@ -118,7 +118,7 @@ export default abstract class Compartment extends BaseMultiPolygon { pointToProjection, overlaysVisible, vectorSource, - mapBackgroundType, + backgroundId, mapSize, mapInstance, }); diff --git a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts index eb94b525..1d5f41d6 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts @@ -67,7 +67,7 @@ describe('CompartmentCircle', () => { pointToProjection: jest.fn(), mapInstance, vectorSource: new VectorSource(), - mapBackgroundType: MapBackgroundsEnum.SEMANTIC, + backgroundId: MapBackgroundsEnum.SEMANTIC, mapSize: { minZoom: 1, maxZoom: 9, diff --git a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts index 78915ae4..0de0037b 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts @@ -42,7 +42,7 @@ export type CompartmentCircleProps = { pointToProjection: UsePointToProjectionResult; mapInstance: MapInstance; vectorSource: VectorSource; - mapBackgroundType: number; + backgroundId: number; mapSize: MapSize; }; @@ -75,7 +75,7 @@ export default class CompartmentCircle extends Compartment { pointToProjection, mapInstance, vectorSource, - mapBackgroundType, + backgroundId, mapSize, }: CompartmentCircleProps) { super({ @@ -106,7 +106,7 @@ export default class CompartmentCircle extends Compartment { pointToProjection, mapInstance, vectorSource, - mapBackgroundType, + backgroundId, mapSize, }); } diff --git a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts index 05e1801e..0b0da3b4 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts @@ -65,7 +65,7 @@ describe('CompartmentPathway', () => { pointToProjection: jest.fn(() => [10, 10]), mapInstance, vectorSource: new VectorSource(), - mapBackgroundType: MapBackgroundsEnum.SEMANTIC, + backgroundId: MapBackgroundsEnum.SEMANTIC, mapSize: { minZoom: 1, maxZoom: 9, diff --git a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts index 94034677..bf6b269e 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts @@ -45,7 +45,7 @@ export type CompartmentPathwayProps = { pointToProjection: UsePointToProjectionResult; mapInstance: MapInstance; vectorSource: VectorSource; - mapBackgroundType: number; + backgroundId: number; mapSize: MapSize; }; @@ -80,7 +80,7 @@ export default class CompartmentPathway extends BaseMultiPolygon { pointToProjection, mapInstance, vectorSource, - mapBackgroundType, + backgroundId, mapSize, }: CompartmentPathwayProps) { super({ @@ -108,7 +108,7 @@ export default class CompartmentPathway extends BaseMultiPolygon { pointToProjection, overlaysVisible, vectorSource, - mapBackgroundType, + backgroundId, mapSize, mapInstance, }); diff --git a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts index acf2471c..ebfdcd7a 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts @@ -65,7 +65,7 @@ describe('CompartmentSquare', () => { pointToProjection: jest.fn(), mapInstance, vectorSource: new VectorSource(), - mapBackgroundType: MapBackgroundsEnum.SEMANTIC, + backgroundId: MapBackgroundsEnum.SEMANTIC, mapSize: { minZoom: 1, maxZoom: 9, diff --git a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts index 34f95693..32bb5a24 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts @@ -41,7 +41,7 @@ export type CompartmentSquareProps = { pointToProjection: UsePointToProjectionResult; mapInstance: MapInstance; vectorSource: VectorSource; - mapBackgroundType: number; + backgroundId: number; mapSize: MapSize; }; @@ -74,7 +74,7 @@ export default class CompartmentSquare extends Compartment { pointToProjection, mapInstance, vectorSource, - mapBackgroundType, + backgroundId, mapSize, }: CompartmentSquareProps) { super({ @@ -105,7 +105,7 @@ export default class CompartmentSquare extends Compartment { pointToProjection, mapInstance, vectorSource, - mapBackgroundType, + backgroundId, mapSize, }); } diff --git a/src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts index 744c6529..2137147c 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts @@ -66,7 +66,7 @@ describe('MapElement', () => { overlaysVisible: false, vectorSource: new VectorSource(), getOverlayColor: (): string => '#ffffff', - mapBackgroundType: MapBackgroundsEnum.SEMANTIC, + backgroundId: MapBackgroundsEnum.SEMANTIC, mapSize: { minZoom: 1, maxZoom: 9, diff --git a/src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts index ead1dd13..8f5f66d3 100644 --- a/src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts @@ -66,7 +66,7 @@ export type MapElementProps = { overlaysOrder?: Array<OverlayOrder>; overlaysVisible: boolean; getOverlayColor: GetOverlayBioEntityColorByAvailableProperties; - mapBackgroundType: number; + backgroundId: number; mapSize: MapSize; }; @@ -131,7 +131,7 @@ export default class MapElement extends BaseMultiPolygon { overlaysOrder = [], overlaysVisible, getOverlayColor, - mapBackgroundType, + backgroundId, mapSize, }: MapElementProps) { super({ @@ -159,7 +159,7 @@ export default class MapElement extends BaseMultiPolygon { pointToProjection, vectorSource, overlaysVisible, - mapBackgroundType, + backgroundId, mapSize, mapInstance, }); diff --git a/src/components/Map/MapViewer/utils/useOlMap.test.ts b/src/components/Map/MapViewer/utils/useOlMap.test.ts index 79bc1ed1..5b5fa97b 100644 --- a/src/components/Map/MapViewer/utils/useOlMap.test.ts +++ b/src/components/Map/MapViewer/utils/useOlMap.test.ts @@ -3,7 +3,6 @@ import { Map } from 'ol'; import React from 'react'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; -import { BACKGROUND_INITIAL_STATE_MOCK } from '@/redux/backgrounds/background.mock'; import { useOlMap } from './useOlMap'; const useRefValue = { @@ -30,7 +29,6 @@ jest.spyOn(React, 'useRef').mockReturnValue(useRefValue); describe('useOlMap - util', () => { const { Wrapper } = getReduxWrapperWithStore({ map: initialMapStateFixture, - backgrounds: BACKGROUND_INITIAL_STATE_MOCK, }); describe('when initializing', () => { diff --git a/src/constants/backgrounds.ts b/src/constants/backgrounds.ts deleted file mode 100644 index 1bfb4619..00000000 --- a/src/constants/backgrounds.ts +++ /dev/null @@ -1 +0,0 @@ -export const EMPTY_BACKGROUND_NAME = 'Empty'; diff --git a/src/models/fixtures/backgroundsFixture.ts b/src/models/fixtures/backgroundsFixture.ts deleted file mode 100644 index e06e5c15..00000000 --- a/src/models/fixtures/backgroundsFixture.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ZOD_SEED } from '@/constants'; -import { z } from 'zod'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { createFixture } from 'zod-fixture'; -import { mapBackground } from '../mapBackground'; - -export const backgroundsFixture = createFixture(z.array(mapBackground), { - seed: ZOD_SEED, - array: { min: 2, max: 2 }, -}); diff --git a/src/models/mapBackground.ts b/src/models/mapBackground.ts deleted file mode 100644 index fe6c6e9e..00000000 --- a/src/models/mapBackground.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { z } from 'zod'; - -export const mapBackground = z.object({ - id: z.number(), - name: z.string(), - defaultOverlay: z.boolean(), - project: z.object({ projectId: z.string() }), - creator: z.object({ login: z.string() }), - status: z.string(), - progress: z.number(), - description: z.string().nullable(), - order: z.number(), - images: z.array( - z.object({ - id: z.number(), - model: z.object({ id: z.number() }), - projectBackground: z.object({ id: z.number() }), - path: z.string(), - }), - ), -}); diff --git a/src/redux/apiPath.ts b/src/redux/apiPath.ts index d20f1a79..1e0c81b8 100644 --- a/src/redux/apiPath.ts +++ b/src/redux/apiPath.ts @@ -89,8 +89,6 @@ export const apiPath = { projectId: string, { publicOverlay }: { publicOverlay: boolean }, ): string => `projects/${projectId}/overlays/?isPublic=${String(publicOverlay)}`, - getAllBackgroundsByProjectIdQuery: (projectId: string): string => - `projects/${projectId}/backgrounds/`, getProjectById: (projectId: string): string => `projects/${projectId}`, getProjects: (): string => `projects/`, getSessionValid: (): string => `users/isSessionValid`, diff --git a/src/redux/backgrounds/background.mock.ts b/src/redux/backgrounds/background.mock.ts deleted file mode 100644 index 515bb724..00000000 --- a/src/redux/backgrounds/background.mock.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { DEFAULT_ERROR } from '@/constants/errors'; -import { MapBackground } from '@/types/models'; -import { BackgroundsState } from './backgrounds.types'; - -export const BACKGROUND_INITIAL_STATE_MOCK: BackgroundsState = { - data: undefined, - loading: 'idle', - error: DEFAULT_ERROR, -}; - -export const BACKGROUNDS_MOCK: MapBackground[] = [ - { - id: 13, - name: 'Pathways and compartments', - defaultOverlay: false, - project: { - projectId: 'pdmap_appu_test', - }, - creator: { - login: 'admin', - }, - status: 'NA', - progress: 0, - description: null, - order: 0, - images: [], - }, - { - id: 14, - name: 'Network', - defaultOverlay: false, - project: { - projectId: 'pdmap_appu_test', - }, - creator: { - login: 'admin', - }, - status: 'NA', - progress: 0, - description: null, - order: 1, - images: [], - }, - { - id: 15, - name: 'Empty', - defaultOverlay: false, - project: { - projectId: 'pdmap_appu_test', - }, - creator: { - login: 'admin', - }, - status: 'NA', - progress: 0, - description: null, - order: 2, - images: [], - }, -]; diff --git a/src/redux/backgrounds/background.selectors.ts b/src/redux/backgrounds/background.selectors.ts deleted file mode 100644 index eda37034..00000000 --- a/src/redux/backgrounds/background.selectors.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { EMPTY_BACKGROUND_NAME } from '@/constants/backgrounds'; -import { createSelector } from '@reduxjs/toolkit'; -import { mapDataSelector } from '../map/map.selectors'; -import { rootSelector } from '../root/root.selectors'; -import { PATHWAYS_AND_COMPARTMENTS_BACKGROUND, SEMANTIC_BACKGROUND } from './backgrounds.constants'; - -export const backgroundsSelector = createSelector(rootSelector, state => state.backgrounds); - -export const backgroundsDataSelector = createSelector(backgroundsSelector, backgrounds => { - return (backgrounds?.data || []).map(background => { - if (background.name === PATHWAYS_AND_COMPARTMENTS_BACKGROUND) { - return { - ...background, - name: SEMANTIC_BACKGROUND, - }; - } - - return background; - }); -}); - -const MAIN_BACKGROUND = 0; -export const mainBackgroundsDataSelector = createSelector( - backgroundsDataSelector, - backgrounds => backgrounds && backgrounds[MAIN_BACKGROUND], -); -export const mainBackgroundIdSelector = createSelector( - backgroundsDataSelector, - backgrounds => backgrounds && backgrounds[MAIN_BACKGROUND]?.id, -); - -export const currentBackgroundSelector = createSelector( - backgroundsDataSelector, - mapDataSelector, - (backgrounds, mapData) => - backgrounds && backgrounds.find(background => background.id === mapData.backgroundId), -); - -export const currentBackgroundImageSelector = createSelector( - mapDataSelector, - currentBackgroundSelector, - (mapData, background) => - background && background.images.find(image => image.model.id === mapData.modelId), -); - -export const currentBackgroundImagePathSelector = createSelector( - currentBackgroundImageSelector, - image => (image ? image.path : ''), -); - -export const emptyBackgroundIdSelector = createSelector(backgroundsDataSelector, backgrounds => { - const emptyBackground = backgrounds?.find( - background => background.name === EMPTY_BACKGROUND_NAME, - ); - return emptyBackground?.id; -}); diff --git a/src/redux/backgrounds/backgrounds.constants.ts b/src/redux/backgrounds/backgrounds.constants.ts deleted file mode 100644 index 49499431..00000000 --- a/src/redux/backgrounds/backgrounds.constants.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const BACKGROUNDS_FETCHING_ERROR_PREFIX = 'Failed to fetch backgrounds'; -export const PATHWAYS_AND_COMPARTMENTS_BACKGROUND = 'Pathways and compartments'; -export const SEMANTIC_BACKGROUND = 'Semantic'; diff --git a/src/redux/backgrounds/backgrounds.reducers.test.ts b/src/redux/backgrounds/backgrounds.reducers.test.ts deleted file mode 100644 index dd13a771..00000000 --- a/src/redux/backgrounds/backgrounds.reducers.test.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { PROJECT_ID } from '@/constants'; -import { backgroundsFixture } from '@/models/fixtures/backgroundsFixture'; -import { - ToolkitStoreWithSingleSlice, - createStoreInstanceUsingSliceReducer, -} from '@/utils/createStoreInstanceUsingSliceReducer'; -import { mockNetworkResponse } from '@/utils/mockNetworkResponse'; -import { HttpStatusCode } from 'axios'; -import { unwrapResult } from '@reduxjs/toolkit'; -import { apiPath } from '../apiPath'; -import backgroundsReducer from './backgrounds.slice'; -import { getAllBackgroundsByProjectId } from './backgrounds.thunks'; -import { BackgroundsState } from './backgrounds.types'; - -jest.mock('../../utils/showToast'); - -const mockedAxiosClient = mockNetworkResponse(); - -const INITIAL_STATE: BackgroundsState = { - data: [], - loading: 'idle', - error: { name: '', message: '' }, -}; - -describe('backgrounds reducer', () => { - let store = {} as ToolkitStoreWithSingleSlice<BackgroundsState>; - beforeEach(() => { - store = createStoreInstanceUsingSliceReducer('backgrounds', backgroundsReducer); - }); - - it('should match initial state', () => { - const action = { type: 'unknown' }; - - expect(backgroundsReducer(undefined, action)).toEqual(INITIAL_STATE); - }); - it('should update store after succesfull getAllBackgroundsByProjectId query', async () => { - mockedAxiosClient - .onGet(apiPath.getAllBackgroundsByProjectIdQuery(PROJECT_ID)) - .reply(HttpStatusCode.Ok, backgroundsFixture); - - const { type } = await store.dispatch(getAllBackgroundsByProjectId(PROJECT_ID)); - const { data, loading, error } = store.getState().backgrounds; - - expect(type).toBe('backgrounds/getAllBackgroundsByProjectId/fulfilled'); - expect(loading).toEqual('succeeded'); - expect(error).toEqual({ message: '', name: '' }); - expect(data).toEqual(backgroundsFixture); - }); - - it('should update store after failed getAllBackgroundsByProjectId query', async () => { - mockedAxiosClient - .onGet(apiPath.getAllBackgroundsByProjectIdQuery(PROJECT_ID)) - .reply(HttpStatusCode.NotFound, []); - - const action = await store.dispatch(getAllBackgroundsByProjectId(PROJECT_ID)); - const { data, loading, error } = store.getState().backgrounds; - - expect(action.type).toBe('backgrounds/getAllBackgroundsByProjectId/rejected'); - expect(loading).toEqual('failed'); - expect(error).toEqual({ message: '', name: '' }); - expect(data).toEqual([]); - expect(() => unwrapResult(action)).toThrow( - "Failed to fetch backgrounds: The page you're looking for doesn't exist. Please verify the URL and try again.", - ); - }); - - it('should update store on loading getAllBackgroundsByProjectId query', async () => { - mockedAxiosClient - .onGet(apiPath.getAllBackgroundsByProjectIdQuery(PROJECT_ID)) - .reply(HttpStatusCode.Ok, backgroundsFixture); - - const actionPromise = store.dispatch(getAllBackgroundsByProjectId(PROJECT_ID)); - - const { data, loading } = store.getState().backgrounds; - expect(data).toEqual([]); - expect(loading).toEqual('pending'); - - actionPromise.then(() => { - const { data: dataPromiseFulfilled, loading: promiseFulfilled } = - store.getState().backgrounds; - - expect(dataPromiseFulfilled).toEqual(backgroundsFixture); - expect(promiseFulfilled).toEqual('succeeded'); - }); - }); -}); diff --git a/src/redux/backgrounds/backgrounds.reducers.ts b/src/redux/backgrounds/backgrounds.reducers.ts deleted file mode 100644 index 2f0868b4..00000000 --- a/src/redux/backgrounds/backgrounds.reducers.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ActionReducerMapBuilder } from '@reduxjs/toolkit'; -import { getAllBackgroundsByProjectId } from './backgrounds.thunks'; -import { BackgroundsState } from './backgrounds.types'; - -export const getAllBackgroundsByProjectIdReducer = ( - builder: ActionReducerMapBuilder<BackgroundsState>, -): void => { - builder.addCase(getAllBackgroundsByProjectId.pending, state => { - state.loading = 'pending'; - }); - builder.addCase(getAllBackgroundsByProjectId.fulfilled, (state, action) => { - state.data = action.payload || []; - state.loading = 'succeeded'; - }); - builder.addCase(getAllBackgroundsByProjectId.rejected, state => { - state.loading = 'failed'; - // TODO to discuss manage state of failure - }); -}; diff --git a/src/redux/backgrounds/backgrounds.slice.ts b/src/redux/backgrounds/backgrounds.slice.ts deleted file mode 100644 index 491e981d..00000000 --- a/src/redux/backgrounds/backgrounds.slice.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; -import { getAllBackgroundsByProjectIdReducer } from './backgrounds.reducers'; -import { BackgroundsState } from './backgrounds.types'; - -const initialState: BackgroundsState = { - data: [], - loading: 'idle', - error: { name: '', message: '' }, -}; - -const backgroundsState = createSlice({ - name: 'backgrounds', - initialState, - reducers: {}, - extraReducers: builder => { - getAllBackgroundsByProjectIdReducer(builder); - }, -}); - -export default backgroundsState.reducer; diff --git a/src/redux/backgrounds/backgrounds.thunks.ts b/src/redux/backgrounds/backgrounds.thunks.ts deleted file mode 100644 index d2ce1949..00000000 --- a/src/redux/backgrounds/backgrounds.thunks.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { mapBackground } from '@/models/mapBackground'; -import { axiosInstance } from '@/services/api/utils/axiosInstance'; -import { MapBackground } from '@/types/models'; -import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; -import { createAsyncThunk } from '@reduxjs/toolkit'; -import { z } from 'zod'; -import { ThunkConfig } from '@/types/store'; -import { getError } from '@/utils/error-report/getError'; -import { apiPath } from '../apiPath'; -import { BACKGROUNDS_FETCHING_ERROR_PREFIX } from './backgrounds.constants'; - -export const getAllBackgroundsByProjectId = createAsyncThunk<MapBackground[], string, ThunkConfig>( - 'backgrounds/getAllBackgroundsByProjectId', - async (projectId: string) => { - try { - const response = await axiosInstance.get<MapBackground[]>( - apiPath.getAllBackgroundsByProjectIdQuery(projectId), - ); - - const isDataValid = validateDataUsingZodSchema(response.data, z.array(mapBackground)); - - return isDataValid ? response.data : []; - } catch (error) { - return Promise.reject(getError({ error, prefix: BACKGROUNDS_FETCHING_ERROR_PREFIX })); - } - }, -); diff --git a/src/redux/backgrounds/backgrounds.types.ts b/src/redux/backgrounds/backgrounds.types.ts deleted file mode 100644 index 7ce8fcfc..00000000 --- a/src/redux/backgrounds/backgrounds.types.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { FetchDataState } from '@/types/fetchDataState'; -import { MapBackground } from '@/types/models'; - -export type BackgroundsState = FetchDataState<MapBackground[]>; diff --git a/src/redux/map/map.constants.ts b/src/redux/map/map.constants.ts index 55b67d50..92de423d 100644 --- a/src/redux/map/map.constants.ts +++ b/src/redux/map/map.constants.ts @@ -18,7 +18,7 @@ export const MAP_BACKGROUND_TYPES = [ export const MODEL_ID_DEFAULT: number = 0; -export const BACKGROUND_ID_DEFAULT: number = 0; +export const BACKGROUND_ID_DEFAULT: number = MapBackgroundsEnum.SEMANTIC; export const OVERVIEW_IMAGE_ID_DEFAULT: number = 0; @@ -73,7 +73,6 @@ export const MAP_INITIAL_STATE: MapState = { loading: 'idle', error: { name: '', message: '' }, openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, }; export const INIT_MAP_SIZE_MODEL_ID_ERROR_PREFIX = 'Failed to initialize map size and model ID'; diff --git a/src/redux/map/map.fixtures.ts b/src/redux/map/map.fixtures.ts index 21674c65..77d17df6 100644 --- a/src/redux/map/map.fixtures.ts +++ b/src/redux/map/map.fixtures.ts @@ -22,7 +22,7 @@ export const initialMapDataFixture: MapData = { projectId: 'pdmap', meshId: '', modelId: 0, - backgroundId: 0, + backgroundId: MapBackgroundsEnum.SEMANTIC, overlaysIds: [], position: { initial: { x: 0, y: 0, z: 5 }, @@ -60,7 +60,6 @@ export const initialMapStateFixture: MapState = { loading: 'idle', error: DEFAULT_ERROR, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }; export const mapStateWithCurrentlySelectedMainMapFixture: MapState = { @@ -78,5 +77,4 @@ export const mapStateWithCurrentlySelectedMainMapFixture: MapState = { loading: 'idle', error: DEFAULT_ERROR, openedMaps: openedMapsInitialValueFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }; diff --git a/src/redux/map/map.reducers.ts b/src/redux/map/map.reducers.ts index 5ae6707d..553ad617 100644 --- a/src/redux/map/map.reducers.ts +++ b/src/redux/map/map.reducers.ts @@ -1,6 +1,6 @@ import { DEFAULT_ZOOM } from '@/constants/map'; import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; -import { ActionReducerMapBuilder, PayloadAction } from '@reduxjs/toolkit'; +import { ActionReducerMapBuilder } from '@reduxjs/toolkit'; import { getPointMerged } from '@/utils/object/getPointMerged'; import { initMapBackground, @@ -221,11 +221,3 @@ export const initOpenedMapsReducer = (builder: ActionReducerMapBuilder<MapState> state.openedMaps = action.payload; }); }; - -export const setMapBackgroundTypeReducer = ( - state: MapState, - action: PayloadAction<number>, -): void => { - const { payload } = action; - state.backgroundType = payload; -}; diff --git a/src/redux/map/map.selectors.ts b/src/redux/map/map.selectors.ts index 8cb88035..92737498 100644 --- a/src/redux/map/map.selectors.ts +++ b/src/redux/map/map.selectors.ts @@ -35,4 +35,4 @@ export const mapDataLastZoomValue = createSelector( export const mapDataMaxZoomValue = createSelector(mapDataSizeSelector, model => model.maxZoom); -export const mapBackgroundTypeSelector = createSelector(mapSelector, map => map.backgroundType); +export const mapBackgroundSelector = createSelector(mapSelector, map => map.data.backgroundId); diff --git a/src/redux/map/map.slice.ts b/src/redux/map/map.slice.ts index dbfd8bbe..3106a118 100644 --- a/src/redux/map/map.slice.ts +++ b/src/redux/map/map.slice.ts @@ -12,7 +12,6 @@ import { setActiveMapReducer, setLastPositionZoomReducer, setMapBackgroundReducer, - setMapBackgroundTypeReducer, setMapDataReducer, setMapPositionReducer, updateLastClickReducer, @@ -36,7 +35,6 @@ const mapSlice = createSlice({ setLastPositionZoom: setLastPositionZoomReducer, updateLastClick: updateLastClickReducer, updateLastRightClick: updateLastRightClickReducer, - setMapBackgroundType: setMapBackgroundTypeReducer, }, extraReducers: builder => { initMapPositionReducers(builder); @@ -59,7 +57,6 @@ export const { setLastPositionZoom, updateLastClick, updateLastRightClick, - setMapBackgroundType, } = mapSlice.actions; export default mapSlice.reducer; diff --git a/src/redux/map/map.thunks.test.ts b/src/redux/map/map.thunks.test.ts index b44d0fd8..81feb7da 100644 --- a/src/redux/map/map.thunks.test.ts +++ b/src/redux/map/map.thunks.test.ts @@ -6,7 +6,7 @@ import { Project } from '@/types/models'; import { PROJECT_STATE_INITIAL_MOCK } from '@/redux/project/project.mock'; import { ProjectState } from '@/redux/project/project.types'; import { MAIN_MAP_ID } from '@/constants/mocks'; -import { BACKGROUNDS_MOCK, BACKGROUND_INITIAL_STATE_MOCK } from '../backgrounds/background.mock'; +import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MODELS_INITIAL_STATE_MOCK } from '../models/models.mock'; import { INITIAL_STORE_STATE_MOCK } from '../root/root.fixtures'; import { RootState } from '../store'; @@ -68,33 +68,27 @@ const STATE_WITH_MODELS: RootState = { describe('map thunks - utils', () => { describe('getBackgroundId', () => { - it('should return backgroundId value from queryData', () => { - const backgroundId = getBackgroundId(INITIAL_STORE_STATE_MOCK, QUERY_DATA_WITH_BG); - expect(backgroundId).toBe(21); - }); - it('should return main map background id if query param does not include background id', () => { + it('should return main map background id (2 - semantic) if query param does not include background id', () => { const store: RootState = { ...INITIAL_STORE_STATE_MOCK, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, }; const backgroundId = getBackgroundId(store, EMPTY_QUERY_DATA); - expect(backgroundId).toBe(13); + expect(backgroundId).toBe(MapBackgroundsEnum.SEMANTIC); }); - it('should return default value (0) if query data does not include backgroundId and could not find main background in the store', () => { + it('should return default value (2 - semantic) if query data does not include backgroundId and could not find main background in the store', () => { const backgroundId = getBackgroundId(INITIAL_STORE_STATE_MOCK, EMPTY_QUERY_DATA); - expect(backgroundId).toBe(0); + expect(backgroundId).toBe(MapBackgroundsEnum.SEMANTIC); }); - it('should return main map background id if query param background id is invalid', () => { + it('should return semantic map background id if query param background id is invalid', () => { const store: RootState = { ...INITIAL_STORE_STATE_MOCK, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, }; const backgroundId = getBackgroundId(store, QUERY_DATA_WITH_BG); - expect(backgroundId).toBe(13); + expect(backgroundId).toBe(MapBackgroundsEnum.SEMANTIC); }); }); diff --git a/src/redux/map/map.thunks.ts b/src/redux/map/map.thunks.ts index 363b1d9c..bb1a81d3 100644 --- a/src/redux/map/map.thunks.ts +++ b/src/redux/map/map.thunks.ts @@ -7,6 +7,7 @@ import { getPointMerged } from '@/utils/object/getPointMerged'; import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; import { ThunkConfig } from '@/types/store'; import { getError } from '@/utils/error-report/getError'; +import MapBackgroundsEnum from '@/redux/map/map.enums'; import type { AppDispatch, RootState } from '../store'; import { InitMapBackgroundActionPayload, @@ -21,10 +22,6 @@ import { OppenedMap, Position, } from './map.types'; -import { - backgroundsDataSelector, - mainBackgroundsDataSelector, -} from '../backgrounds/background.selectors'; import { currentModelSelector, mainMapModelSelector, @@ -43,21 +40,13 @@ import { /** UTILS - in the same file because of dependency cycle */ export const getBackgroundId = (state: RootState, queryData: QueryData): number => { - const mainMapBackground = mainBackgroundsDataSelector(state); - const backgrounds = backgroundsDataSelector(state); - let backgroundId = queryData?.backgroundId || mainMapBackground?.id || ZERO; + let backgroundId = queryData?.backgroundId; - if (backgrounds.length > 0) { - if ( - backgrounds.filter(background => { - return background.id === backgroundId; - }).length === 0 - ) { - backgroundId = backgrounds[ZERO].id; - } + if (!backgroundId || !Object.values(MapBackgroundsEnum).includes(backgroundId)) { + backgroundId = MapBackgroundsEnum.SEMANTIC; } - if (backgroundId !== mainMapBackground?.id) { + if (backgroundId !== MapBackgroundsEnum.SEMANTIC) { PluginsEventBus.dispatchEvent('onBackgroundOverlayChange', backgroundId); } diff --git a/src/redux/map/map.types.ts b/src/redux/map/map.types.ts index dc838aaa..72b600dc 100644 --- a/src/redux/map/map.types.ts +++ b/src/redux/map/map.types.ts @@ -44,9 +44,7 @@ export type MapData = { }; }; -export type MapState = FetchDataState<MapData, MapData> & { openedMaps: OppenedMap[] } & { - backgroundType: number; -}; +export type MapState = FetchDataState<MapData, MapData> & { openedMaps: OppenedMap[] }; export type SetMapDataActionPayload = | (Omit<Partial<MapData>, 'position' | 'projectId'> & { diff --git a/src/redux/map/middleware/checkIfIsMapUpdateActionValid.test.ts b/src/redux/map/middleware/checkIfIsMapUpdateActionValid.test.ts index 1509a089..5580c024 100644 --- a/src/redux/map/middleware/checkIfIsMapUpdateActionValid.test.ts +++ b/src/redux/map/middleware/checkIfIsMapUpdateActionValid.test.ts @@ -1,6 +1,5 @@ import { RootState } from '@/redux/store'; import { Loading } from '@/types/loadingState'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MAP_DATA_INITIAL_STATE, MIDDLEWARE_ALLOWED_ACTIONS, @@ -18,7 +17,6 @@ const state: Pick<RootState, 'map'> = { loading: 'idle' as Loading, error: { name: '', message: '' }, openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }; diff --git a/src/redux/map/middleware/map.middleware.test.ts b/src/redux/map/middleware/map.middleware.test.ts index cb928afd..b783347e 100644 --- a/src/redux/map/middleware/map.middleware.test.ts +++ b/src/redux/map/middleware/map.middleware.test.ts @@ -3,7 +3,6 @@ import { modelsFixture } from '@/models/fixtures/modelsFixture'; import { Loading } from '@/types/loadingState'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { Action } from '@reduxjs/toolkit'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MAP_DATA_INITIAL_STATE, MIDDLEWARE_ALLOWED_ACTIONS, @@ -64,7 +63,6 @@ const { store } = getReduxWrapperWithStore({ modelId: modelsFixture[0].id, }, openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { ...defaultSliceState, diff --git a/src/redux/map/middleware/map.middleware.ts b/src/redux/map/middleware/map.middleware.ts index bacbb729..d4eef340 100644 --- a/src/redux/map/middleware/map.middleware.ts +++ b/src/redux/map/middleware/map.middleware.ts @@ -1,8 +1,7 @@ -import { currentBackgroundSelector } from '@/redux/backgrounds/background.selectors'; import type { AppListenerEffectAPI, AppStartListening } from '@/redux/store'; import { getUpdatedMapData } from '@/utils/map/getUpdatedMapData'; import { Action, createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit'; -import { mapOpenedMapPositionByIdSelector } from '../map.selectors'; +import { mapBackgroundSelector, mapOpenedMapPositionByIdSelector } from '../map.selectors'; import { closeMapAndSetMainMapActive, openMapAndOrSetActiveIfSelected, @@ -31,7 +30,7 @@ export const mapDataMiddlewareListener = async ( return; } - const background = currentBackgroundSelector(state); + const background = mapBackgroundSelector(state); const modelId = updatedModel.id; const lastPosition = mapOpenedMapPositionByIdSelector(state, modelId); const updatedMapData = getUpdatedMapData({ diff --git a/src/redux/overlayBioEntity/overlayBioEntity.thunk.ts b/src/redux/overlayBioEntity/overlayBioEntity.thunk.ts index f726bd8f..c0d3daed 100644 --- a/src/redux/overlayBioEntity/overlayBioEntity.thunk.ts +++ b/src/redux/overlayBioEntity/overlayBioEntity.thunk.ts @@ -12,8 +12,6 @@ import { import { apiPath } from '../apiPath'; import { modelsIdsSelector } from '../models/models.selectors'; import type { RootState } from '../store'; -import { setMapBackground } from '../map/map.slice'; -import { emptyBackgroundIdSelector } from '../backgrounds/background.selectors'; import { overlaySelector, userOverlaySelector } from '../overlays/overlays.selectors'; import { INIT_OVERLAYS_ERROR_PREFIX, @@ -89,11 +87,6 @@ export const getInitOverlays = createAsyncThunk< try { const state = getState(); - const emptyBackgroundId = emptyBackgroundIdSelector(state); - if (emptyBackgroundId) { - dispatch(setMapBackground(emptyBackgroundId)); - } - overlaysId.forEach(id => { const userOverlay = userOverlaySelector(state, id); const overlay = overlaySelector(state, id); diff --git a/src/redux/root/init.selectors.ts b/src/redux/root/init.selectors.ts index 67cdfa08..5ddcf77a 100644 --- a/src/redux/root/init.selectors.ts +++ b/src/redux/root/init.selectors.ts @@ -1,5 +1,4 @@ import { createSelector } from '@reduxjs/toolkit'; -import { backgroundsSelector } from '../backgrounds/background.selectors'; import { mapSelector } from '../map/map.selectors'; import { modelsSelector } from '../models/models.selectors'; import { overlaysSelector } from '../overlays/overlays.selectors'; @@ -7,7 +6,6 @@ import { projectSelector } from '../project/project.selectors'; export const initDataLoadingInitialized = createSelector( projectSelector, - backgroundsSelector, modelsSelector, overlaysSelector, (...selectors) => selectors.every(selector => selector.loading !== 'idle'), @@ -15,7 +13,6 @@ export const initDataLoadingInitialized = createSelector( export const initDataLoadingFinishedSelector = createSelector( projectSelector, - backgroundsSelector, modelsSelector, overlaysSelector, (...selectors) => selectors.every(selector => selector.loading === 'succeeded'), @@ -23,7 +20,6 @@ export const initDataLoadingFinishedSelector = createSelector( export const initDataAndMapLoadingFinished = createSelector( projectSelector, - backgroundsSelector, modelsSelector, overlaysSelector, mapSelector, diff --git a/src/redux/root/init.thunks.ts b/src/redux/root/init.thunks.ts index ba7f3059..562789dc 100644 --- a/src/redux/root/init.thunks.ts +++ b/src/redux/root/init.thunks.ts @@ -24,7 +24,6 @@ import { } from '@/components/FunctionalArea/CookieBanner/CookieBanner.constants'; import { injectMatomoTracking } from '@/utils/injectMatomoTracking'; import { getGlyphs } from '@/redux/glyphs/glyphs.thunks'; -import { getAllBackgroundsByProjectId } from '../backgrounds/backgrounds.thunks'; import { getConfiguration, getConfigurationOptions } from '../configuration/configuration.thunks'; import { initMapBackground, @@ -64,7 +63,6 @@ export const fetchInitialAppData = createAsyncThunk< dispatch(getConfiguration()), dispatch(getConfigurationOptions()), dispatch(getProjectById(PROJECT_ID)), - dispatch(getAllBackgroundsByProjectId(PROJECT_ID)), dispatch(getAllPublicOverlaysByProjectId(PROJECT_ID)), dispatch(getModels()), dispatch(getShapes()), diff --git a/src/redux/root/root.fixtures.ts b/src/redux/root/root.fixtures.ts index c90d96c3..f6d6110c 100644 --- a/src/redux/root/root.fixtures.ts +++ b/src/redux/root/root.fixtures.ts @@ -9,7 +9,6 @@ import { LAYERS_STATE_INITIAL_MOCK } from '@/redux/layers/layers.mock'; import { NEW_REACTIONS_INITIAL_STATE_MOCK } from '@/redux/newReactions/newReactions.mock'; import { GLYPHS_STATE_INITIAL_MOCK } from '@/redux/glyphs/glyphs.mock'; import { MAP_EDIT_TOOLS_STATE_INITIAL_MOCK } from '@/redux/mapEditTools/mapEditTools.mock'; -import { BACKGROUND_INITIAL_STATE_MOCK } from '../backgrounds/background.mock'; import { BIOENTITY_INITIAL_STATE_MOCK } from '../bioEntity/bioEntity.mock'; import { CHEMICALS_INITIAL_STATE_MOCK } from '../chemicals/chemicals.mock'; import { COMPARTMENT_PATHWAYS_INITIAL_STATE_MOCK } from '../compartmentPathways/compartmentPathways.mock'; @@ -51,7 +50,6 @@ export const INITIAL_STORE_STATE_MOCK: RootState = { modelElements: MODEL_ELEMENTS_INITIAL_STATE_MOCK, layers: LAYERS_STATE_INITIAL_MOCK, bioEntity: BIOENTITY_INITIAL_STATE_MOCK, - backgrounds: BACKGROUND_INITIAL_STATE_MOCK, drawer: drawerInitialStateMock, map: initialMapStateFixture, oauth: OAUTH_INITIAL_STATE_MOCK, diff --git a/src/redux/store.ts b/src/redux/store.ts index 0e3a85b9..a98370bc 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -1,4 +1,3 @@ -import backgroundsReducer from '@/redux/backgrounds/backgrounds.slice'; import bioEntityReducer from '@/redux/bioEntity/bioEntity.slice'; import chemicalsReducer from '@/redux/chemicals/chemicals.slice'; import configurationReducer from '@/redux/configuration/configuration.slice'; @@ -62,7 +61,6 @@ export const reducers = { drawer: drawerReducer, modal: modalReducer, map: mapReducer, - backgrounds: backgroundsReducer, overlays: overlaysReducer, models: modelsReducer, shapes: shapesReducer, diff --git a/src/services/pluginsManager/map/data/getBounds.test.ts b/src/services/pluginsManager/map/data/getBounds.test.ts index b824df10..99f587da 100644 --- a/src/services/pluginsManager/map/data/getBounds.test.ts +++ b/src/services/pluginsManager/map/data/getBounds.test.ts @@ -2,7 +2,6 @@ import { MAP_DATA_INITIAL_STATE } from '@/redux/map/map.constants'; import { store } from '@/redux/store'; import { Map } from 'ol'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MapManager } from '../mapManager'; import { getBounds } from './getBounds'; @@ -46,7 +45,6 @@ describe('getBounds', () => { message: '', }, openedMaps: [], - backgroundType: MapBackgroundsEnum.SEMANTIC, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any }) as any, diff --git a/src/services/pluginsManager/map/fitBounds/fitBounds.test.ts b/src/services/pluginsManager/map/fitBounds/fitBounds.test.ts index de852078..1fd5ec32 100644 --- a/src/services/pluginsManager/map/fitBounds/fitBounds.test.ts +++ b/src/services/pluginsManager/map/fitBounds/fitBounds.test.ts @@ -2,7 +2,6 @@ import { MAP_DATA_INITIAL_STATE } from '@/redux/map/map.constants'; import { Map } from 'ol'; import { store } from '@/redux/store'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { fitBounds } from './fitBounds'; import { MapManager } from '../mapManager'; @@ -52,7 +51,6 @@ describe('fitBounds', () => { message: '', }, openedMaps: [], - backgroundType: MapBackgroundsEnum.SEMANTIC, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any }) as any, @@ -103,7 +101,6 @@ describe('fitBounds', () => { message: '', }, openedMaps: [], - backgroundType: MapBackgroundsEnum.SEMANTIC, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any }) as any, diff --git a/src/services/pluginsManager/map/openMap.test.ts b/src/services/pluginsManager/map/openMap.test.ts index 69aca9db..ddebdab0 100644 --- a/src/services/pluginsManager/map/openMap.test.ts +++ b/src/services/pluginsManager/map/openMap.test.ts @@ -3,7 +3,6 @@ import { openMapAndSetActive, setActiveMap } from '@/redux/map/map.slice'; import { RootState, store } from '@/redux/store'; import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; import { MODELS_MOCK, MODELS_MOCK_SHORT } from '@/models/mocks/modelsMock'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import { PluginsEventBus } from '../pluginsEventBus'; import { openMap } from './openMap'; @@ -27,7 +26,6 @@ describe('openMap', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { data: MODELS_MOCK_SHORT, @@ -53,7 +51,6 @@ describe('openMap', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { data: MODELS_MOCK, @@ -81,7 +78,6 @@ describe('openMap', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, models: { data: MODELS_MOCK, diff --git a/src/services/pluginsManager/map/overlays/showDataOverlay/setBackgroundtoEmptyIfAvailable.test.ts b/src/services/pluginsManager/map/overlays/showDataOverlay/setBackgroundtoEmptyIfAvailable.test.ts deleted file mode 100644 index 15b32c94..00000000 --- a/src/services/pluginsManager/map/overlays/showDataOverlay/setBackgroundtoEmptyIfAvailable.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { - BACKGROUNDS_MOCK, - BACKGROUND_INITIAL_STATE_MOCK, -} from '@/redux/backgrounds/background.mock'; -import { initialMapStateFixture } from '@/redux/map/map.fixtures'; -import { RootState, store } from '@/redux/store'; -import { setBackgroundtoEmptyIfAvailable } from './setBackgroundtoEmptyIfAvailable'; - -const DEFAULT_BACKGROUND_ID = 0; -const EMPTY_BACKGROUND_ID = 15; - -describe('setEmptyBackground', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - const getStateSpy = jest.spyOn(store, 'getState'); - const dispatchSpy = jest.spyOn(store, 'dispatch'); - it('should not set background to empty if its not available', () => { - getStateSpy.mockImplementation( - () => - ({ - map: initialMapStateFixture, - backgrounds: BACKGROUND_INITIAL_STATE_MOCK, - }) as RootState, - ); - - expect(store.getState().map.data.backgroundId).toBe(DEFAULT_BACKGROUND_ID); - - setBackgroundtoEmptyIfAvailable(); - - expect(dispatchSpy).not.toHaveBeenCalled(); - }); - - it('should set background to empty if its available', () => { - getStateSpy.mockImplementation( - () => - ({ - map: initialMapStateFixture, - backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK }, - }) as RootState, - ); - - expect(store.getState().map.data.backgroundId).toBe(DEFAULT_BACKGROUND_ID); - - setBackgroundtoEmptyIfAvailable(); - - expect(dispatchSpy).toHaveBeenCalledWith({ - payload: EMPTY_BACKGROUND_ID, - type: 'map/setMapBackground', - }); - }); -}); diff --git a/src/services/pluginsManager/map/overlays/showDataOverlay/setBackgroundtoEmptyIfAvailable.ts b/src/services/pluginsManager/map/overlays/showDataOverlay/setBackgroundtoEmptyIfAvailable.ts deleted file mode 100644 index 59c6c061..00000000 --- a/src/services/pluginsManager/map/overlays/showDataOverlay/setBackgroundtoEmptyIfAvailable.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { emptyBackgroundIdSelector } from '@/redux/backgrounds/background.selectors'; -import { setMapBackground } from '@/redux/map/map.slice'; -import { store } from '@/redux/store'; - -export const setBackgroundtoEmptyIfAvailable = (): void => { - const { dispatch, getState } = store; - const emptyBackgroundId = emptyBackgroundIdSelector(getState()); - - if (emptyBackgroundId) { - dispatch(setMapBackground(emptyBackgroundId)); - } -}; diff --git a/src/services/pluginsManager/map/overlays/showDataOverlay/showDataOverlay.test.ts b/src/services/pluginsManager/map/overlays/showDataOverlay/showDataOverlay.test.ts index da92e7f9..7709f9ec 100644 --- a/src/services/pluginsManager/map/overlays/showDataOverlay/showDataOverlay.test.ts +++ b/src/services/pluginsManager/map/overlays/showDataOverlay/showDataOverlay.test.ts @@ -11,11 +11,9 @@ import { import { getOverlayBioEntityForAllModels } from '@/redux/overlayBioEntity/overlayBioEntity.thunk'; import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; import { showDataOverlay } from './showDataOverlay'; -import { setBackgroundtoEmptyIfAvailable } from './setBackgroundtoEmptyIfAvailable'; jest.mock('../../../../../redux/overlayBioEntity/overlayBioEntity.thunk'); jest.mock('../../../../../redux/store'); -jest.mock('./setBackgroundtoEmptyIfAvailable'); const OVERLAY_ID = overlaysPageFixture.content[0].idObject; @@ -110,45 +108,4 @@ describe('showDataOverlay function', () => { overlaysPageFixture.content[0], ); }); - - it('should not set empty background when it show overlay', () => { - getStateSpy.mockImplementation( - () => - ({ - overlays: { - ...OVERLAYS_INITIAL_STATE_MOCK, - userOverlays: { - data: overlaysPageFixture.content, - loading: 'idle', - error: DEFAULT_ERROR, - }, - }, - overlayBioEntity: { ...OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK }, - }) as RootState, - ); - - showDataOverlay(OVERLAY_ID); - - expect(setBackgroundtoEmptyIfAvailable).not.toHaveBeenCalled(); - }); - it('should set empty background when it show overlay if setBackgroundEmpty is true', () => { - getStateSpy.mockImplementation( - () => - ({ - overlays: { - ...OVERLAYS_INITIAL_STATE_MOCK, - userOverlays: { - data: overlaysPageFixture.content, - loading: 'idle', - error: DEFAULT_ERROR, - }, - }, - overlayBioEntity: { ...OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK }, - }) as RootState, - ); - - showDataOverlay(OVERLAY_ID, true); - - expect(setBackgroundtoEmptyIfAvailable).toHaveBeenCalled(); - }); }); diff --git a/src/services/pluginsManager/map/overlays/showDataOverlay/showDataOverlay.ts b/src/services/pluginsManager/map/overlays/showDataOverlay/showDataOverlay.ts index 8304beed..34359036 100644 --- a/src/services/pluginsManager/map/overlays/showDataOverlay/showDataOverlay.ts +++ b/src/services/pluginsManager/map/overlays/showDataOverlay/showDataOverlay.ts @@ -7,7 +7,8 @@ import { ERROR_OVERLAY_ID_ALREADY_ACTIVE, ERROR_OVERLAY_ID_NOT_FOUND, } from '@/services/pluginsManager/errorMessages'; -import { setBackgroundtoEmptyIfAvailable } from './setBackgroundtoEmptyIfAvailable'; +import { setMapBackground } from '@/redux/map/map.slice'; +import MapBackgroundsEnum from '@/redux/map/map.enums'; export const showDataOverlay = (overlayId: number, setBackgroundEmpty?: boolean): void => { const { dispatch, getState } = store; @@ -25,7 +26,7 @@ export const showDataOverlay = (overlayId: number, setBackgroundEmpty?: boolean) } if (setBackgroundEmpty) { - setBackgroundtoEmptyIfAvailable(); + dispatch(setMapBackground(MapBackgroundsEnum.SEMANTIC)); } dispatch(getOverlayBioEntityForAllModels({ overlayId })); diff --git a/src/services/pluginsManager/map/position/getCenter.test.ts b/src/services/pluginsManager/map/position/getCenter.test.ts index fe23d527..f9d9dd54 100644 --- a/src/services/pluginsManager/map/position/getCenter.test.ts +++ b/src/services/pluginsManager/map/position/getCenter.test.ts @@ -1,6 +1,5 @@ import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; import { RootState, store } from '@/redux/store'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { getCenter } from './getCenter'; jest.mock('../../../../redux/store'); @@ -26,7 +25,6 @@ describe('getCenter - plugin method', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }) as RootState, ); diff --git a/src/services/pluginsManager/map/triggerSearch/triggerSearch.test.ts b/src/services/pluginsManager/map/triggerSearch/triggerSearch.test.ts index 293f9476..abb470aa 100644 --- a/src/services/pluginsManager/map/triggerSearch/triggerSearch.test.ts +++ b/src/services/pluginsManager/map/triggerSearch/triggerSearch.test.ts @@ -11,7 +11,6 @@ import { RootState, store } from '@/redux/store'; import { mockNetworkNewAPIResponse, mockNetworkResponse } from '@/utils/mockNetworkResponse'; import { waitFor } from '@testing-library/react'; import { HttpStatusCode } from 'axios'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { triggerSearch } from './triggerSearch'; import { ERROR_INVALID_MODEL_ID_TYPE } from '../../errorMessages'; @@ -30,7 +29,6 @@ const MOCK_STATE = { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, configuration: CONFIGURATION_INITIAL_STORE_MOCKS, }; diff --git a/src/services/pluginsManager/map/zoom/getZoom.test.ts b/src/services/pluginsManager/map/zoom/getZoom.test.ts index 669d8773..b7808d53 100644 --- a/src/services/pluginsManager/map/zoom/getZoom.test.ts +++ b/src/services/pluginsManager/map/zoom/getZoom.test.ts @@ -1,7 +1,6 @@ /* eslint-disable no-magic-numbers */ import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; import { RootState, store } from '@/redux/store'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { getZoom } from './getZoom'; jest.mock('../../../../redux/store'); @@ -29,7 +28,6 @@ describe('getZoom - plugin method', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }) as RootState, ); @@ -59,7 +57,6 @@ describe('getZoom - plugin method', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }) as RootState, ); diff --git a/src/services/pluginsManager/map/zoom/setZoom.test.ts b/src/services/pluginsManager/map/zoom/setZoom.test.ts index 2d5f8a3d..55502f30 100644 --- a/src/services/pluginsManager/map/zoom/setZoom.test.ts +++ b/src/services/pluginsManager/map/zoom/setZoom.test.ts @@ -4,7 +4,6 @@ import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/ma import { setLastPositionZoom } from '@/redux/map/map.slice'; import { RootState, store } from '@/redux/store'; import { ZodError } from 'zod'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { setZoom } from './setZoom'; jest.mock('../../../../redux/store'); @@ -37,7 +36,6 @@ describe('setZoom - plugin method', () => { loading: 'succeeded', error: { message: '', name: '' }, openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }) as RootState, ); diff --git a/src/types/mapLayers.ts b/src/types/mapLayers.ts deleted file mode 100644 index d5b7bb6a..00000000 --- a/src/types/mapLayers.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* excluded from map.ts due to depenceny cycle */ - -import { useOlMapOverlaysLayer } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useOlMapOverlaysLayer'; -import { useOlMapPinsLayer } from '@/components/Map/MapViewer/utils/config/pinsLayer/useOlMapPinsLayer'; -import { useOlMapReactionsLayer } from '@/components/Map/MapViewer/utils/config/reactionsLayer/useOlMapReactionsLayer'; -import { useOlMapTileLayer } from '@/components/Map/MapViewer/utils/config/useOlMapTileLayer'; - -export type MapLayers = - | { - tileLayer: ReturnType<typeof useOlMapTileLayer>; - reactionsLayer: ReturnType<typeof useOlMapReactionsLayer>; - pinsLayer: ReturnType<typeof useOlMapPinsLayer>; - overlaysLayer: ReturnType<typeof useOlMapOverlaysLayer>; - } - | undefined; diff --git a/src/types/models.ts b/src/types/models.ts index c70bb0b7..168c7fde 100644 --- a/src/types/models.ts +++ b/src/types/models.ts @@ -16,7 +16,6 @@ import { exportElementsSchema, exportNetworkchema } from '@/models/exportSchema' import { geneVariant } from '@/models/geneVariant'; import { lineSchema } from '@/models/lineSchema'; import { loginSchema } from '@/models/loginSchema'; -import { mapBackground } from '@/models/mapBackground'; import { createdOverlayFileSchema, createdOverlaySchema, @@ -116,7 +115,6 @@ export type ShapeRelAbs = z.infer<typeof shapeRelAbsSchema>; export type ShapeRelAbsBezierPoint = z.infer<typeof shapeRelAbsBezierPointSchema>; export type Modification = z.infer<typeof modelElementModificationSchema>; export type MapOverlay = z.infer<typeof mapOverlay>; -export type MapBackground = z.infer<typeof mapBackground>; export type Organism = z.infer<typeof organism>; export type Disease = z.infer<typeof disease>; export type Drug = z.infer<typeof drugSchema>; diff --git a/src/utils/initialize/useInitializeStore.test.ts b/src/utils/initialize/useInitializeStore.test.ts index 34a1e072..92b5d635 100644 --- a/src/utils/initialize/useInitializeStore.test.ts +++ b/src/utils/initialize/useInitializeStore.test.ts @@ -1,21 +1,18 @@ import { PROJECT_ID } from '@/constants'; -import { backgroundsFixture } from '@/models/fixtures/backgroundsFixture'; import { modelsFixture, modelsPageFixture } from '@/models/fixtures/modelsFixture'; import { overlaysPageFixture } from '@/models/fixtures/overlaysFixture'; import { projectFixture } from '@/models/fixtures/projectFixture'; import { apiPath } from '@/redux/apiPath'; -import { backgroundsDataSelector } from '@/redux/backgrounds/background.selectors'; import { modelsDataSelector } from '@/redux/models/models.selectors'; import { overlaysDataSelector } from '@/redux/overlays/overlays.selectors'; import { projectDataSelector } from '@/redux/project/project.selectors'; import { initDataLoadingInitialized } from '@/redux/root/init.selectors'; -import { mockNetworkNewAPIResponse, mockNetworkResponse } from '@/utils/mockNetworkResponse'; +import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { renderHook, waitFor } from '@testing-library/react'; import { HttpStatusCode } from 'axios'; import * as hook from './useInitializeStore'; -const mockedAxiosClient = mockNetworkResponse(); const mockedAxiosNewClient = mockNetworkNewAPIResponse(); describe('useInitializeStore - hook', () => { @@ -30,9 +27,6 @@ describe('useInitializeStore - hook', () => { mockedAxiosNewClient .onGet(apiPath.getProjectById(PROJECT_ID)) .reply(HttpStatusCode.Ok, projectFixture); - mockedAxiosClient - .onGet(apiPath.getAllBackgroundsByProjectIdQuery(PROJECT_ID)) - .reply(HttpStatusCode.Ok, backgroundsFixture); }); it('should fetch project data in store', async () => { @@ -45,16 +39,6 @@ describe('useInitializeStore - hook', () => { }); }); - it('should fetch backgrounds data in store', async () => { - const { Wrapper, store } = getReduxWrapperWithStore(); - renderHook(() => hook.useInitializeStore(), { wrapper: Wrapper }); - - await waitFor(() => { - const data = backgroundsDataSelector(store.getState()); - expect(data).toEqual(backgroundsFixture); - }); - }); - it('should fetch overlays data in store', async () => { const { Wrapper, store } = getReduxWrapperWithStore(); renderHook(() => hook.useInitializeStore(), { wrapper: Wrapper }); diff --git a/src/utils/initialize/useInitializeStore.ts b/src/utils/initialize/useInitializeStore.ts index c6481127..3c6ed389 100644 --- a/src/utils/initialize/useInitializeStore.ts +++ b/src/utils/initialize/useInitializeStore.ts @@ -10,7 +10,7 @@ import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { parseQueryToTypes } from '../parseQueryToTypes'; /** - * 1. Initialise all required data before app starts: Project info, available Backgrounds, available Overlays, available Models (maps,submaps) + * 1. Initialise all required data before app starts: Project info, available Overlays, available Models (maps,submaps) * 2. Based on that set required map data to correctly display view. If query params are available -> use them to set map data */ @@ -25,7 +25,6 @@ export const useInitializeStore = (): void => { if (isInitialized || !isQueryReady) { return; } - dispatch(fetchInitialAppData({ queryData: parseQueryToTypes(query) })); }, [dispatch, isInitialized, query, isQueryReady, isInitDataLoadingFinished]); }; diff --git a/src/utils/map/getUpdatedMapData.ts b/src/utils/map/getUpdatedMapData.ts index 1e4fc498..1d5632f8 100644 --- a/src/utils/map/getUpdatedMapData.ts +++ b/src/utils/map/getUpdatedMapData.ts @@ -1,14 +1,15 @@ import { DEFAULT_ZOOM } from '@/constants/map'; import { MAP_DATA_INITIAL_STATE } from '@/redux/map/map.constants'; import { GetUpdatedMapDataResult, MapData } from '@/redux/map/map.types'; -import { MapBackground, MapModel } from '@/types/models'; +import { MapModel } from '@/types/models'; import { DeepPartial } from '@reduxjs/toolkit'; +import MapBackgroundsEnum from '@/redux/map/map.enums'; import { getPointMerged } from '../object/getPointMerged'; interface GetUpdatedMapDataArgs { model: MapModel; position?: DeepPartial<MapData['position']>; - background?: MapBackground; + background?: MapBackgroundsEnum; } const HALF = 2; @@ -28,7 +29,7 @@ export const getUpdatedMapData = ({ return { modelId: model.id, - backgroundId: background?.id || MAP_DATA_INITIAL_STATE.backgroundId, + backgroundId: background || MAP_DATA_INITIAL_STATE.backgroundId, size: { width: model.width, height: model.height, diff --git a/src/utils/map/useSetBounds.test.ts b/src/utils/map/useSetBounds.test.ts index fde34efd..71ee1260 100644 --- a/src/utils/map/useSetBounds.test.ts +++ b/src/utils/map/useSetBounds.test.ts @@ -4,7 +4,6 @@ import { MAP_DATA_INITIAL_STATE } from '@/redux/map/map.constants'; import { renderHook } from '@testing-library/react'; import { Map } from 'ol'; import { Coordinate } from 'ol/coordinate'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { getReduxWrapperWithStore } from '../testing/getReduxWrapperWithStore'; import { useSetBounds } from './useSetBounds'; @@ -35,7 +34,6 @@ describe('useSetBounds - hook', () => { message: '', }, openedMaps: [], - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }, { @@ -81,7 +79,6 @@ describe('useSetBounds - hook', () => { message: '', }, openedMaps: [], - backgroundType: MapBackgroundsEnum.SEMANTIC, }, }, { diff --git a/src/utils/query-manager/useReduxBusQueryManager.test.ts b/src/utils/query-manager/useReduxBusQueryManager.test.ts index e71069d6..9283e65b 100644 --- a/src/utils/query-manager/useReduxBusQueryManager.test.ts +++ b/src/utils/query-manager/useReduxBusQueryManager.test.ts @@ -2,7 +2,6 @@ import { MAP_DATA_INITIAL_STATE, OPENED_MAPS_INITIAL_STATE } from '@/redux/map/m import { Loading } from '@/types/loadingState'; import { renderHook, waitFor } from '@testing-library/react'; import mockRouter from 'next-router-mock'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; import { getReduxWrapperWithStore } from '../testing/getReduxWrapperWithStore'; import { useReduxBusQueryManager } from './useReduxBusQueryManager'; @@ -71,9 +70,7 @@ describe('useReduxBusQueryManager - util', () => { }, }, openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, }, - backgrounds: loadedDataMock, models: loadedDataMock, overlays: loadedDataMock, }); -- GitLab