@@ -19,7 +19,7 @@ function buildGraph(
1919 dagreGraph . setDefaultEdgeLabel ( ( ) => ( { } ) ) ;
2020 dagreGraph . setGraph ( { rankdir : 'TB' } ) ;
2121
22- const nodeMap : Record < string , Node < NodeData > > = { } ;
22+ const nodeMap = new Map < string , Node < NodeData > > ( ) ;
2323 treeData . forEach ( ( n ) => {
2424 const colorKey = colorBy === 'source' ? n . providerType : n . providerConfigName ;
2525 const node : Node < NodeData > = {
@@ -39,7 +39,7 @@ function buildGraph(
3939 sourcePosition : Position . Bottom ,
4040 targetPosition : Position . Top ,
4141 } ;
42- nodeMap [ n . id ] = node ;
42+ nodeMap . set ( n . id , node ) ;
4343 dagreGraph . setNode ( n . id , { width : nodeWidth , height : nodeHeight } ) ;
4444 } ) ;
4545
@@ -55,7 +55,7 @@ function buildGraph(
5555 } ) ;
5656 }
5757 n . extraRefs ?. forEach ( ( refId ) => {
58- if ( nodeMap [ refId ] ) {
58+ if ( nodeMap . has ( refId ) ) {
5959 dagreGraph . setEdge ( refId , n . id ) ;
6060 edgeList . push ( {
6161 id : `e-${ refId } -${ n . id } ` ,
@@ -68,12 +68,12 @@ function buildGraph(
6868 } ) ;
6969
7070 dagre . layout ( dagreGraph ) ;
71- Object . values ( nodeMap ) . forEach ( ( node ) => {
71+ nodeMap . forEach ( ( node ) => {
7272 const pos = dagreGraph . node ( node . id ) ;
7373 node . position = { x : pos . x - nodeWidth / 2 , y : pos . y - nodeHeight / 2 } ;
7474 } ) ;
7575
76- return { nodes : Object . values ( nodeMap ) , edges : edgeList } ;
76+ return { nodes : Array . from ( nodeMap . values ( ) ) , edges : edgeList } ;
7777}
7878
7979export function useGraph ( colorBy : ColorBy , onYamlClick : ( item : ManagedResourceItem ) => void ) {
0 commit comments