Skip to content

Commit 9a0e9ef

Browse files
clementleclercRTEBOUTIER CharlyEstherDarkishSOUISSI Maissa (Externe)sBouzols
authored
Open sld from nad (#3013)
* NAD depth refactor (WIP) Signed-off-by: BOUTIER Charly <[email protected]> * add men when click on voltage level on nad Signed-off-by: SOUISSI Maissa (Externe) <[email protected]> * add voltage level to expand , when clicking on vl nad Signed-off-by: SOUISSI Maissa (Externe) <[email protected]> * NAD depth refactor (WIP) Signed-off-by: BOUTIER Charly <[email protected]> * hide voltageLevel Signed-off-by: Leclerc Clement <[email protected]> * hide voltageLevel Signed-off-by: Leclerc Clement <[email protected]> * hide voltageLevel fix Signed-off-by: Leclerc Clement <[email protected]> * rename voltagelevel context menu Signed-off-by: Leclerc Clement <[email protected]> * rename node context menu Signed-off-by: Leclerc Clement <[email protected]> * New button to augment depth in NAD Signed-off-by: BOUTIER Charly <[email protected]> * NAD_FROM_ELEMENT removal. Still needs to fix the diagram's titles. Signed-off-by: BOUTIER Charly <[email protected]> * TS Fixes Signed-off-by: BOUTIER Charly <[email protected]> * TS Fixes Signed-off-by: BOUTIER Charly <[email protected]> * PR Review Signed-off-by: BOUTIER Charly <[email protected]> * PR Review Signed-off-by: BOUTIER Charly <[email protected]> * Clean front data when receiving SVG Signed-off-by: BOUTIER Charly <[email protected]> * Update front data when receiving NAD SVG Signed-off-by: BOUTIER Charly <[email protected]> * add positions Signed-off-by: Leclerc Clement <[email protected]> * type fix Signed-off-by: Leclerc Clement <[email protected]> * type fix Signed-off-by: Leclerc Clement <[email protected]> * type fix Signed-off-by: Leclerc Clement <[email protected]> * Fix diagram names Signed-off-by: BOUTIER Charly <[email protected]> * Code cleaning Signed-off-by: BOUTIER Charly <[email protected]> * Code cleaning Signed-off-by: BOUTIER Charly <[email protected]> * Code cleaning Signed-off-by: BOUTIER Charly <[email protected]> * open SLD from diagram Signed-off-by: Leclerc Clement <[email protected]> * update useEffect dependencies Signed-off-by: Leclerc Clement <[email protected]> * prettier fix Signed-off-by: Leclerc Clement <[email protected]> * Fix positions Signed-off-by: BOUTIER Charly <[email protected]> * TS Signed-off-by: BOUTIER Charly <[email protected]> * Store positions in session storage Signed-off-by: BOUTIER Charly <[email protected]> * import fix * create styles Signed-off-by: Leclerc Clement <[email protected]> * replace style with sx Signed-off-by: Leclerc Clement <[email protected]> * add nad loading state checks Signed-off-by: Leclerc Clement <[email protected]> * merge depth-refactor Signed-off-by: Leclerc Clement <[email protected]> * PR Review Signed-off-by: BOUTIER Charly <[email protected]> * PR Review Signed-off-by: BOUTIER Charly <[email protected]> * fix Signed-off-by: Leclerc Clement <[email protected]> * merge main Signed-off-by: Leclerc Clement <[email protected]> * add callback props for voltage level navigation Signed-off-by: Leclerc Clement <[email protected]> --------- Signed-off-by: BOUTIER Charly <[email protected]> Signed-off-by: SOUISSI Maissa (Externe) <[email protected]> Signed-off-by: Leclerc Clement <[email protected]> Co-authored-by: BOUTIER Charly <[email protected]> Co-authored-by: Charly B <[email protected]> Co-authored-by: SOUISSI Maissa (Externe) <[email protected]> Co-authored-by: Sylvain Bouzols <[email protected]>
1 parent 6faaa0e commit 9a0e9ef

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

src/components/diagrams/diagram-grid-layout.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ function DiagramGridLayout({ studyUuid, showInSpreadsheet, visible }: Readonly<D
310310
);
311311
}, []);
312312

313+
const handleVoltageLevelClick = useCallback(
314+
(vlId: string): void => {
315+
createDiagram({
316+
diagramUuid: v4() as UUID,
317+
type: DiagramType.VOLTAGE_LEVEL,
318+
voltageLevelId: vlId,
319+
name: '',
320+
});
321+
},
322+
[createDiagram]
323+
);
324+
313325
// This function is called by the diagram's contents, when they get their sizes from the backend.
314326
const setDiagramSize = useCallback((diagramId: UUID, diagramType: DiagramType, width: number, height: number) => {
315327
console.log('TODO setDiagramSize', diagramId, diagramType, width, height);
@@ -358,6 +370,7 @@ function DiagramGridLayout({ studyUuid, showInSpreadsheet, visible }: Readonly<D
358370
loadingState={loadingDiagrams.includes(diagram.diagramUuid)}
359371
diagramSizeSetter={setDiagramSize}
360372
visible={visible}
373+
onNextVoltageLevelClick={handleVoltageLevelClick}
361374
/>
362375
)}
363376
{diagram.type === DiagramType.NETWORK_AREA_DIAGRAM && (
@@ -387,6 +400,7 @@ function DiagramGridLayout({ studyUuid, showInSpreadsheet, visible }: Readonly<D
387400
onExpandAllVoltageLevels={() => handleExpandAllVoltageLevels(diagram.diagramUuid)}
388401
onHideVoltageLevel={(vlId) => handleHideVoltageLevelId(diagram.diagramUuid, vlId)}
389402
onMoveNode={(vlId, x, y) => handleMoveNode(diagram.diagramUuid, vlId, x, y)}
403+
onVoltageLevelClick={handleVoltageLevelClick}
390404
customPositions={diagram.positions}
391405
/>
392406
)}
@@ -408,6 +422,7 @@ function DiagramGridLayout({ studyUuid, showInSpreadsheet, visible }: Readonly<D
408422
handleExpandVoltageLevelId,
409423
handleHideVoltageLevelId,
410424
handleMoveNode,
425+
handleVoltageLevelClick,
411426
onRemoveCard,
412427
setDiagramSize,
413428
showInSpreadsheet,

src/components/diagrams/networkAreaDiagram/network-area-diagram-content.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import { ComputingType, ElementType, IElementCreationDialog, mergeSx, useSnackMe
3535
import DiagramControls from '../diagram-controls';
3636
import { createDiagramConfig, DiagramConfigPosition } from '../../../services/explore';
3737
import { DiagramType } from '../diagram.type';
38-
3938
import NodeContextMenu from './node-context-menu';
4039

4140
const equipmentsWithPopover = [
@@ -62,6 +61,7 @@ type NetworkAreaDiagramContentProps = {
6261
readonly onHideVoltageLevel: (vlId: string) => void;
6362
readonly onMoveNode: (vlId: string, x: number, y: number) => void;
6463
readonly customPositions: DiagramConfigPosition[];
64+
readonly onVoltageLevelClick: (vlId: string) => void;
6565
};
6666

6767
function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
@@ -75,6 +75,7 @@ function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
7575
onExpandVoltageLevel,
7676
onExpandAllVoltageLevels,
7777
onHideVoltageLevel,
78+
onVoltageLevelClick,
7879
onMoveNode,
7980
} = props;
8081
const svgRef = useRef();
@@ -144,12 +145,16 @@ function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
144145
const OnLeftClickCallback: OnSelectNodeCallbackType = useCallback(
145146
(equipmentId, nodeId, mousePosition) => {
146147
if (mousePosition && !props.loadingState) {
147-
setSelectedVoltageLevelId(equipmentId);
148-
setShouldDisplayMenu(true);
149-
setMenuAnchorPosition(mousePosition ? { mouseX: mousePosition.x, mouseY: mousePosition.y } : null);
148+
if (isEditNadMode) {
149+
setSelectedVoltageLevelId(equipmentId);
150+
setShouldDisplayMenu(true);
151+
setMenuAnchorPosition(mousePosition ? { mouseX: mousePosition.x, mouseY: mousePosition.y } : null);
152+
} else {
153+
onVoltageLevelClick(equipmentId);
154+
}
150155
}
151156
},
152-
[props.loadingState]
157+
[isEditNadMode, onVoltageLevelClick, props.loadingState]
153158
);
154159

155160
const handleSaveNadConfig = (directoryData: IElementCreationDialog) => {
@@ -196,7 +201,7 @@ function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
196201
onMoveNodeCallback,
197202
onMoveTextNodeCallback,
198203
OnLeftClickCallback,
199-
isEditNadMode,
204+
true,
200205
true,
201206
NAD_ZOOM_LEVELS,
202207
isEditNadMode ? null : OnToggleHoverCallback,

src/components/diagrams/singleLineDiagram/single-line-diagram-content.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { startShortCircuitAnalysis } from '../../../services/study/short-circuit
4545
import { fetchNetworkElementInfos } from '../../../services/study/network';
4646
import { useOneBusShortcircuitAnalysisLoader } from '../use-one-bus-shortcircuit-analysis-loader';
4747
import { DynamicSimulationEventDialog } from '../../dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog';
48-
import { openDiagram, setComputationStarting, setComputingStatus, setLogsFilter } from '../../../redux/actions';
48+
import { setComputationStarting, setComputingStatus, setLogsFilter } from '../../../redux/actions';
4949
import { AppState } from 'redux/reducer';
5050
import { UUID } from 'crypto';
5151
import { INVALID_LOADFLOW_OPACITY } from '../../../utils/colors';
@@ -69,6 +69,7 @@ interface SingleLineDiagramContentProps {
6969
readonly diagramSizeSetter: (id: UUID, type: DiagramType, width: number, height: number) => void;
7070
readonly diagramId: UUID;
7171
readonly visible: boolean;
72+
readonly onNextVoltageLevelClick: (voltageLevelId: string) => void;
7273
}
7374

7475
type EquipmentToModify = {
@@ -116,7 +117,7 @@ function applyInvalidStyles(svgContainer: HTMLElement) {
116117
}
117118

118119
function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
119-
const { diagramSizeSetter, studyUuid, visible } = props;
120+
const { diagramSizeSetter, studyUuid, visible, onNextVoltageLevelClick } = props;
120121
const theme = useTheme();
121122
const dispatch = useDispatch();
122123
const MenuBranch = withOperatingStatusMenu(BaseEquipmentMenu);
@@ -219,18 +220,6 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
219220
[studyUuid, currentNode, modificationInProgress]
220221
);
221222

222-
const handleNextVoltageLevelClick = useCallback(
223-
(id: string) => {
224-
// This function is called by powsybl-network-viewer when clicking on a navigation arrow in a single line diagram.
225-
// At the moment, there is no plan to open something other than a voltage-level by using these navigation arrows.
226-
if (!studyUuid || !currentNode) {
227-
return;
228-
}
229-
dispatch(openDiagram(id, DiagramType.VOLTAGE_LEVEL));
230-
},
231-
[dispatch, studyUuid, currentNode]
232-
);
233-
234223
const [equipmentMenu, setEquipmentMenu] = useState<EquipmentMenuState>(defaultMenuState);
235224

236225
const [busMenu, setBusMenu] = useState<BusMenuState>(defaultBusMenuState);
@@ -543,7 +532,7 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
543532
props.svgType === DiagramType.VOLTAGE_LEVEL ? MAX_HEIGHT_VOLTAGE_LEVEL : MAX_HEIGHT_SUBSTATION,
544533

545534
// callback on the next voltage arrows
546-
isReadyForInteraction ? handleNextVoltageLevelClick : null,
535+
isReadyForInteraction ? onNextVoltageLevelClick : null,
547536

548537
// callback on the breakers
549538
isReadyForInteraction && !isNodeReadOnly(currentNode) ? handleBreakerClick : null,
@@ -610,7 +599,7 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
610599
props.loadingState,
611600
locallySwitchedBreaker,
612601
handleBreakerClick,
613-
handleNextVoltageLevelClick,
602+
onNextVoltageLevelClick,
614603
diagramSizeSetter,
615604
handleTogglePopover,
616605
computationStarting,

0 commit comments

Comments
 (0)