From 1c9cad43bafc58bbf3ae5f130e2f841af30fb68d Mon Sep 17 00:00:00 2001 From: Claire Dagan Date: Fri, 29 Nov 2024 09:46:04 +0100 Subject: [PATCH] [Tech] fix sonarCloud issues --- frontend/src/domain/entities/missions.ts | 2 +- .../src/features/missions/Layers/EditingMissionLayer.ts | 4 ++-- .../src/features/missions/Layers/HoveredMissionLayer.ts | 4 ++-- .../src/features/missions/Layers/SelectedMissionLayer.ts | 4 ++-- frontend/src/features/missions/Layers/index.tsx | 2 +- .../features/missions/Layers/missionGeometryHelpers.ts | 9 +++++---- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/frontend/src/domain/entities/missions.ts b/frontend/src/domain/entities/missions.ts index a0f43bbcb..ba5c9a8ca 100644 --- a/frontend/src/domain/entities/missions.ts +++ b/frontend/src/domain/entities/missions.ts @@ -292,7 +292,7 @@ export type Awareness = { themeId?: number } -export type ControlOrSurveillance = EnvActionControl | EnvActionSurveillance +export type ControlOrSurveillance = EnvActionControl | NewEnvActionControl | EnvActionSurveillance export type EnvActionNote = EnvActionCommonProperties & { actionType: ActionTypeEnum.NOTE diff --git a/frontend/src/features/missions/Layers/EditingMissionLayer.ts b/frontend/src/features/missions/Layers/EditingMissionLayer.ts index 1bbc459e3..8f2457d55 100644 --- a/frontend/src/features/missions/Layers/EditingMissionLayer.ts +++ b/frontend/src/features/missions/Layers/EditingMissionLayer.ts @@ -54,7 +54,7 @@ export function EditingMissionLayer({ currentFeatureOver, map }: BaseMapChildren zIndex: Layers.MISSION_SELECTED.zIndex }) ) as MutableRefObject - ;(editingMissionVectorLayerRef.current as VectorLayerWithName).name = Layers.MISSION_SELECTED.code + editingMissionVectorLayerRef.current.name = Layers.MISSION_SELECTED.code const editingMissionActionsVectorSourceRef = useRef(new VectorSource()) as MutableRefObject< VectorSource> @@ -66,7 +66,7 @@ export function EditingMissionLayer({ currentFeatureOver, map }: BaseMapChildren zIndex: Layers.ACTIONS.zIndex }) ) as MutableRefObject - ;(editingMissionActionsVectorLayerRef.current as VectorLayerWithName).name = Layers.ACTIONS.code + editingMissionActionsVectorLayerRef.current.name = Layers.ACTIONS.code const feature = editingMissionVectorSourceRef.current.getFeatureById( `${Layers.MISSION_SELECTED.code}:${activeMissionId}` diff --git a/frontend/src/features/missions/Layers/HoveredMissionLayer.ts b/frontend/src/features/missions/Layers/HoveredMissionLayer.ts index f10d0cc52..e393dc89e 100644 --- a/frontend/src/features/missions/Layers/HoveredMissionLayer.ts +++ b/frontend/src/features/missions/Layers/HoveredMissionLayer.ts @@ -21,7 +21,7 @@ export function HoveredMissionLayer({ currentFeatureOver, map }: BaseMapChildren zIndex: Layers.HOVERED_MISSION.zIndex }) ) as MutableRefObject - ;(hoveredMissionVectorLayerRef.current as VectorLayerWithName).name = Layers.HOVERED_MISSION.code + hoveredMissionVectorLayerRef.current.name = Layers.HOVERED_MISSION.code useEffect(() => { if (map) { @@ -39,7 +39,7 @@ export function HoveredMissionLayer({ currentFeatureOver, map }: BaseMapChildren useEffect(() => { hoveredMissionVectorSourceRef.current?.clear(true) const feature = convertToFeature(currentFeatureOver) - if (feature && feature.getId()?.toString()?.includes(Layers.MISSIONS.code)) { + if (feature?.getId()?.toString()?.includes(Layers.MISSIONS.code)) { hoveredMissionVectorSourceRef.current?.addFeature(feature) } }, [currentFeatureOver]) diff --git a/frontend/src/features/missions/Layers/SelectedMissionLayer.ts b/frontend/src/features/missions/Layers/SelectedMissionLayer.ts index 5a5e7ba80..f959f083c 100644 --- a/frontend/src/features/missions/Layers/SelectedMissionLayer.ts +++ b/frontend/src/features/missions/Layers/SelectedMissionLayer.ts @@ -53,7 +53,7 @@ export function SelectedMissionLayer({ currentFeatureOver, map }: BaseMapChildre zIndex: Layers.MISSION_SELECTED.zIndex }) ) as MutableRefObject - ;(selectedMissionVectorLayerRef.current as VectorLayerWithName).name = Layers.MISSION_SELECTED.code + selectedMissionVectorLayerRef.current.name = Layers.MISSION_SELECTED.code const selectedMissionActionsVectorSourceRef = useRef(new VectorSource()) as MutableRefObject< VectorSource> @@ -66,7 +66,7 @@ export function SelectedMissionLayer({ currentFeatureOver, map }: BaseMapChildre }) ) as MutableRefObject - ;(selectedMissionActionsVectorLayerRef.current as VectorLayerWithName).name = Layers.ACTIONS.code + selectedMissionActionsVectorLayerRef.current.name = Layers.ACTIONS.code const overlayCoordinates = useAppSelector(state => getOverlayCoordinates(state.global, `${Layers.MISSIONS.code}:${selectedMissionIdOnMap}`) diff --git a/frontend/src/features/missions/Layers/index.tsx b/frontend/src/features/missions/Layers/index.tsx index 86b21f558..766c154c3 100644 --- a/frontend/src/features/missions/Layers/index.tsx +++ b/frontend/src/features/missions/Layers/index.tsx @@ -100,7 +100,7 @@ export function MissionsLayer({ map, mapClickEvent }: BaseMapChildrenProps) { zIndex: Layers.MISSIONS.zIndex }) ) as MutableRefObject - ;(missionVectorLayerRef.current as VectorLayerWithName).name = Layers.MISSIONS.code + missionVectorLayerRef.current.name = Layers.MISSIONS.code useEffect(() => { if (map) { diff --git a/frontend/src/features/missions/Layers/missionGeometryHelpers.ts b/frontend/src/features/missions/Layers/missionGeometryHelpers.ts index fd8b57b7c..24c8c72b7 100644 --- a/frontend/src/features/missions/Layers/missionGeometryHelpers.ts +++ b/frontend/src/features/missions/Layers/missionGeometryHelpers.ts @@ -12,7 +12,8 @@ import { getMissionStatus, type Mission, type NewMission, - type NewEnvActionControl + type NewEnvActionControl, + type ControlOrSurveillance } from '../../../domain/entities/missions' import { getTotalOfControls, getTotalOfSurveillances } from '../utils' @@ -73,7 +74,7 @@ const getActionSurveillanceProperties = (action: EnvActionSurveillance) => { } } -const getActionProperties = (action: EnvActionControl | EnvActionSurveillance | NewEnvActionControl) => { +const getActionProperties = (action: ControlOrSurveillance) => { switch (action.actionType) { case ActionTypeEnum.CONTROL: return getActionControlProperties(action) @@ -84,7 +85,7 @@ const getActionProperties = (action: EnvActionControl | EnvActionSurveillance | } const getActionFeature = ( - action: EnvActionControl | EnvActionSurveillance | NewEnvActionControl, + action: ControlOrSurveillance, missionGeom: Geometry, isEditingSurveillanceZoneOrControlPoint: boolean ) => { @@ -115,7 +116,7 @@ const getActionFeature = ( return feature } -const isActionControlOrActionSurveillance = (f): f is EnvActionControl | EnvActionSurveillance | NewEnvActionControl => +const isActionControlOrActionSurveillance = (f): f is ControlOrSurveillance => f.actionType === ActionTypeEnum.CONTROL || f.actionType === ActionTypeEnum.SURVEILLANCE export const getActionsFeatures = (mission, isEditingSurveillanceZoneOrControlPoint = false) => {