@@ -24,6 +24,7 @@ import {
24
24
OnToggleNadHoverCallbackType ,
25
25
OnSelectNodeCallbackType ,
26
26
NadViewerParametersOptions ,
27
+ EQUIPMENT_TYPES ,
27
28
} from '@powsybl/network-viewer' ;
28
29
import LinearProgress from '@mui/material/LinearProgress' ;
29
30
import Box from '@mui/material/Box' ;
@@ -35,6 +36,7 @@ import {
35
36
ComputingType ,
36
37
ElementType ,
37
38
EquipmentType ,
39
+ ExtendedEquipmentType ,
38
40
IElementCreationDialog ,
39
41
IElementUpdateDialog ,
40
42
mergeSx ,
@@ -48,6 +50,8 @@ import useEquipmentMenu from 'hooks/use-equipment-menu';
48
50
import { MapEquipment } from 'components/menus/base-equipment-menu' ;
49
51
import useEquipmentDialogs from 'hooks/use-equipment-dialogs' ;
50
52
import { styles } from '../diagram-styles' ;
53
+ import { fetchNetworkElementInfos } from 'services/study/network' ;
54
+ import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types' ;
51
55
52
56
type NetworkAreaDiagramContentProps = {
53
57
readonly showInSpreadsheet : ( menu : { equipmentId : string | null ; equipmentType : EquipmentType | null } ) => void ;
@@ -269,23 +273,56 @@ function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
269
273
const showEquipmentMenu = useCallback (
270
274
( svgId : string , equipmentId : string , equipmentType : string , mousePosition : Point ) => {
271
275
// 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 {
273
318
const convertedType = getEquipmentTypeFromFeederType ( equipmentType ) ;
274
319
275
320
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 ) ;
285
322
}
286
323
}
287
324
} ,
288
- [ isEditNadMode , openEquipmentMenu ]
325
+ [ isEditNadMode , openEquipmentMenu , currentNode ?. id , currentRootNetworkUuid , studyUuid , snackError ]
289
326
) ;
290
327
291
328
/**
0 commit comments