Skip to content

Commit 42d4ed6

Browse files
AAJELLALsBouzols
andauthored
Remove the map svg from the diagram grid layout. (#3275)
* Remove the svg map from the diagram grid layout. Signed-off-by: AAJELLAL <[email protected]> Co-authored-by: Sylvain Bouzols <[email protected]>
1 parent 722cab5 commit 42d4ed6

File tree

7 files changed

+163
-1213
lines changed

7 files changed

+163
-1213
lines changed

src/components/grid-layout/cards/map/map-card.tsx

Lines changed: 0 additions & 173 deletions
This file was deleted.

src/components/grid-layout/diagram-grid-layout.types.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import { DiagramParams, DiagramParamsDto } from 'components/grid-layout/cards/diagrams/diagram.type';
9-
import { UUID } from 'crypto';
109
import { Layout } from 'react-grid-layout';
1110

1211
export type DiagramLayoutParam = DiagramParams & {
@@ -17,12 +16,7 @@ export interface DiagramGridLayout {
1716
diagramLayouts: DiagramLayoutParam[];
1817
}
1918

20-
type MapDTO = {
21-
diagramUuid: UUID;
22-
type: 'map';
23-
};
24-
25-
export type DiagramLayoutDto = (DiagramParamsDto | MapDTO) & {
19+
export type DiagramLayoutDto = DiagramParamsDto & {
2620
diagramPositions: Record<string, Pick<Layout, 'w' | 'h' | 'x' | 'y'>>;
2721
};
2822

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
import { Dialog, Fab, Theme } from '@mui/material';
8+
import { useCallback, useRef } from 'react';
9+
import { UUID } from 'crypto';
10+
import { EquipmentType, LineFlowMode, NetworkVisualizationParameters, useStateBoolean } from '@gridsuite/commons-ui';
11+
import { useDispatch, useSelector } from 'react-redux';
12+
import { AppState } from 'redux/reducer';
13+
import { resetMapEquipment, setMapDataLoading, setOpenMap, setReloadMapNeeded } from 'redux/actions';
14+
import NetworkMapPanel, { NetworkMapPanelRef } from 'components/network/network-map-panel';
15+
import { Close } from '@mui/icons-material';
16+
import { FormattedMessage } from 'react-intl';
17+
import { CurrentTreeNode } from 'components/graph/tree-node.type';
18+
19+
const styles = {
20+
closeButton: (theme: Theme) => ({
21+
alignSelf: 'center',
22+
margin: theme.spacing(1),
23+
padding: theme.spacing(2),
24+
}),
25+
};
26+
27+
interface MapDialogProps {
28+
studyUuid: UUID;
29+
onClose: () => void;
30+
errorMessage?: string;
31+
showInSpreadsheet: (equipment: { equipmentId: string | null; equipmentType: EquipmentType | null }) => void;
32+
onOpenNetworkAreaDiagram: (elementId?: string) => void;
33+
currentRootNetworkUuid: UUID;
34+
networkVisuParams: NetworkVisualizationParameters;
35+
currentNode: CurrentTreeNode;
36+
}
37+
38+
export const MapDialog = (props: MapDialogProps) => {
39+
const {
40+
studyUuid,
41+
onClose,
42+
currentRootNetworkUuid,
43+
networkVisuParams,
44+
showInSpreadsheet,
45+
onOpenNetworkAreaDiagram,
46+
currentNode,
47+
} = props;
48+
49+
const dispatch = useDispatch();
50+
51+
const mapOpen = useSelector((state: AppState) => state.mapOpen);
52+
53+
const isInDrawingMode = useStateBoolean(false);
54+
const networkMapPanelRef = useRef<NetworkMapPanelRef>(null);
55+
56+
const handleCloseMap = useCallback(
57+
(event?: any, reason?: string) => {
58+
if (isInDrawingMode.value) {
59+
networkMapPanelRef.current?.leaveDrawingMode();
60+
if (reason && reason === 'escapeKeyDown') {
61+
return; // Do not close the map but only the drawing mode
62+
}
63+
}
64+
dispatch(setOpenMap(false));
65+
dispatch(resetMapEquipment());
66+
dispatch(setMapDataLoading(false));
67+
dispatch(setReloadMapNeeded(true));
68+
onClose();
69+
},
70+
[dispatch, isInDrawingMode, onClose]
71+
);
72+
73+
return (
74+
<Dialog open={mapOpen} onClose={handleCloseMap} fullScreen>
75+
<Fab onClick={handleCloseMap} size="small" aria-label="close" variant="extended" sx={styles.closeButton}>
76+
<Close fontSize="small" />
77+
<FormattedMessage id="close" />
78+
</Fab>
79+
<NetworkMapPanel
80+
ref={networkMapPanelRef}
81+
studyUuid={studyUuid}
82+
visible={mapOpen}
83+
lineFullPath={networkVisuParams.mapParameters.lineFullPath}
84+
lineParallelPath={networkVisuParams.mapParameters.lineParallelPath}
85+
lineFlowMode={networkVisuParams.mapParameters.lineFlowMode as LineFlowMode}
86+
currentNode={currentNode}
87+
currentRootNetworkUuid={currentRootNetworkUuid}
88+
showInSpreadsheet={(eq) => {
89+
handleCloseMap();
90+
showInSpreadsheet(eq);
91+
}}
92+
onOpenNetworkAreaDiagram={onOpenNetworkAreaDiagram}
93+
onPolygonChanged={() => {}}
94+
isInDrawingMode={isInDrawingMode}
95+
/>
96+
</Dialog>
97+
);
98+
};
99+
100+
export default MapDialog;

0 commit comments

Comments
 (0)