Skip to content

Commit caddd89

Browse files
authored
Modify HVDC through NAD context menu (#3315)
Signed-off-by: Ayoub LABIDI <[email protected]>
1 parent 663db5e commit caddd89

File tree

1 file changed

+48
-11
lines changed

1 file changed

+48
-11
lines changed

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

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
OnToggleNadHoverCallbackType,
2525
OnSelectNodeCallbackType,
2626
NadViewerParametersOptions,
27+
EQUIPMENT_TYPES,
2728
} from '@powsybl/network-viewer';
2829
import LinearProgress from '@mui/material/LinearProgress';
2930
import Box from '@mui/material/Box';
@@ -35,6 +36,7 @@ import {
3536
ComputingType,
3637
ElementType,
3738
EquipmentType,
39+
ExtendedEquipmentType,
3840
IElementCreationDialog,
3941
IElementUpdateDialog,
4042
mergeSx,
@@ -48,6 +50,8 @@ import useEquipmentMenu from 'hooks/use-equipment-menu';
4850
import { MapEquipment } from 'components/menus/base-equipment-menu';
4951
import useEquipmentDialogs from 'hooks/use-equipment-dialogs';
5052
import { styles } from '../diagram-styles';
53+
import { fetchNetworkElementInfos } from 'services/study/network';
54+
import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types';
5155

5256
type NetworkAreaDiagramContentProps = {
5357
readonly showInSpreadsheet: (menu: { equipmentId: string | null; equipmentType: EquipmentType | null }) => void;
@@ -269,23 +273,56 @@ function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
269273
const showEquipmentMenu = useCallback(
270274
(svgId: string, equipmentId: string, equipmentType: string, mousePosition: Point) => {
271275
// don't display the equipment menu in edit mode.
272-
if (!isEditNadMode) {
276+
if (isEditNadMode) {
277+
return;
278+
}
279+
280+
const openMenu = (equipmentType: EquipmentType, equipmentSubtype: ExtendedEquipmentType | null = null) => {
281+
const equipment = { id: equipmentId };
282+
openEquipmentMenu(
283+
equipment as MapEquipment,
284+
mousePosition.x,
285+
mousePosition.y,
286+
equipmentType,
287+
equipmentSubtype
288+
);
289+
};
290+
291+
if (equipmentType === EquipmentType.HVDC_LINE) {
292+
// need a query to know the HVDC converters type (LCC vs VSC)
293+
// this section should be removed when the NAD will provide this information in the SVG metadata
294+
fetchNetworkElementInfos(
295+
studyUuid,
296+
currentNode?.id,
297+
currentRootNetworkUuid,
298+
EQUIPMENT_TYPES.HVDC_LINE,
299+
EQUIPMENT_INFOS_TYPES.MAP.type,
300+
equipmentId,
301+
false
302+
)
303+
.then((hvdcInfos) => {
304+
const equipmentSubtype =
305+
hvdcInfos?.hvdcType === 'LCC'
306+
? ExtendedEquipmentType.HVDC_LINE_LCC
307+
: ExtendedEquipmentType.HVDC_LINE_VSC;
308+
309+
openMenu(EquipmentType.HVDC_LINE, equipmentSubtype);
310+
})
311+
.catch(() => {
312+
snackError({
313+
messageId: 'NetworkEquipmentNotFound',
314+
messageValues: { equipmentId: equipmentId },
315+
});
316+
});
317+
} else {
273318
const convertedType = getEquipmentTypeFromFeederType(equipmentType);
274319

275320
if (convertedType?.equipmentType) {
276-
// Create a minimal equipment object
277-
const equipment = { id: equipmentId };
278-
openEquipmentMenu(
279-
equipment as MapEquipment,
280-
mousePosition.x,
281-
mousePosition.y,
282-
convertedType.equipmentType,
283-
convertedType.equipmentSubtype ?? null
284-
);
321+
openMenu(convertedType.equipmentType, convertedType.equipmentSubtype ?? null);
285322
}
286323
}
287324
},
288-
[isEditNadMode, openEquipmentMenu]
325+
[isEditNadMode, openEquipmentMenu, currentNode?.id, currentRootNetworkUuid, studyUuid, snackError]
289326
);
290327

291328
/**

0 commit comments

Comments
 (0)