@@ -48,7 +48,6 @@ function getEdgeColor(isDarkTheme: boolean) {
48
48
49
49
export default function Explain ( props : IExplain ) : JSX . Element {
50
50
const command = props . command . split ( ' ' ) [ 0 ] . toLowerCase ( )
51
-
52
51
if ( command . startsWith ( 'graph' ) ) {
53
52
const info = props . data [ 0 ] . response
54
53
const resp = ParseGraphV2 ( info )
@@ -140,7 +139,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
140
139
const container = useRef < HTMLDivElement | null > ( null )
141
140
142
141
const [ done , setDone ] = useState ( false )
143
- const [ collapse , setCollapse ] = useState ( true )
142
+ const [ collapse , setCollapse ] = useState ( type !== CoreType . Profile )
144
143
const [ isFullScreen , setIsFullScreen ] = useState ( false )
145
144
const [ core , setCore ] = useState < Graph > ( )
146
145
@@ -151,15 +150,15 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
151
150
if ( isFullScreen ) {
152
151
setIsFullScreen ( true )
153
152
const height = Math . max ( ( b ?. height || 585 ) + 100 , parent . document . body . offsetHeight )
154
- if ( collapse ) {
153
+ if ( type !== CoreType . Profile && collapse ) {
155
154
core ?. resize ( width , window . outerHeight - 250 )
156
155
core ?. positionContent ( "top" )
157
156
} else {
158
157
core ?. resize ( width , height )
159
158
}
160
159
} else {
161
160
setIsFullScreen ( false )
162
- if ( collapse ) {
161
+ if ( type !== CoreType . Profile && collapse ) {
163
162
core ?. resize ( width , 400 )
164
163
core ?. positionContent ( "top" )
165
164
} else {
@@ -236,45 +235,6 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
236
235
} )
237
236
} )
238
237
239
- const ele = document . querySelector ( "#container-parent" )
240
-
241
- let pos = { top : 0 , left : 0 , x : 0 , y : 0 }
242
-
243
- const mouseMoveHandler = function ( e ) {
244
- // How far the mouse has been moved
245
- const dx = e . clientX - pos . x
246
- const dy = e . clientY - pos . y
247
-
248
- // Scroll the element
249
- if ( ele ) {
250
- ele . scrollTop = pos . top - dy
251
- ele . scrollLeft = pos . left - dx
252
- }
253
- }
254
-
255
-
256
- const mouseUpHandler = function ( ) {
257
- document . removeEventListener ( 'mousemove' , mouseMoveHandler )
258
- document . removeEventListener ( 'mouseup' , mouseUpHandler )
259
- }
260
-
261
-
262
- const mouseDownHandler = function ( e ) {
263
- pos = {
264
- // The current scroll
265
- left : ele ?. scrollLeft || 0 ,
266
- top : ele ?. scrollTop || 0 ,
267
- // Get the current mouse position
268
- x : e . clientX ,
269
- y : e . clientY ,
270
- }
271
-
272
- document . addEventListener ( 'mousemove' , mouseMoveHandler )
273
- setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
274
- }
275
-
276
- ele ?. addEventListener ( 'mousedown' , mouseDownHandler )
277
-
278
238
resize ( )
279
239
280
240
const result = Hierarchy . compactBox ( data , {
@@ -426,7 +386,47 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
426
386
427
387
} , [ done ] )
428
388
429
- if ( collapse ) {
389
+ const ele = document . querySelector ( "#container-parent" )
390
+
391
+ let pos = { top : 0 , left : 0 , x : 0 , y : 0 }
392
+
393
+ const mouseMoveHandler = function ( e ) {
394
+ // How far the mouse has been moved
395
+ const dx = e . clientX - pos . x
396
+ const dy = e . clientY - pos . y
397
+
398
+ // Scroll the element
399
+ if ( ele ) {
400
+ ele . scrollTop = pos . top - dy
401
+ ele . scrollLeft = pos . left - dx
402
+ }
403
+ }
404
+
405
+
406
+ const mouseUpHandler = function ( ) {
407
+ document . removeEventListener ( 'mousemove' , mouseMoveHandler )
408
+ document . removeEventListener ( 'mouseup' , mouseUpHandler )
409
+ }
410
+
411
+
412
+ const mouseDownHandler = function ( e ) {
413
+ pos = {
414
+ // The current scroll
415
+ left : ele ?. scrollLeft || 0 ,
416
+ top : ele ?. scrollTop || 0 ,
417
+ // Get the current mouse position
418
+ x : e . clientX ,
419
+ y : e . clientY ,
420
+ }
421
+
422
+ document . addEventListener ( 'mousemove' , mouseMoveHandler )
423
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
424
+ }
425
+
426
+ ele ?. addEventListener ( 'mousedown' , mouseDownHandler )
427
+
428
+
429
+ if ( type !== CoreType . Profile && collapse ) {
430
430
core ?. resize ( undefined , isFullScreen ? ( window . outerHeight - 250 ) : 400 )
431
431
core ?. positionContent ( "top" )
432
432
} else {
@@ -435,23 +435,24 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
435
435
436
436
return (
437
437
< div >
438
- { collapse && < div style = { { paddingTop : '50px' } } > </ div > }
438
+ { type !== CoreType . Profile && collapse && < div style = { { paddingTop : '50px' } } > </ div > }
439
439
< div
440
440
id = "container-parent"
441
441
style = { {
442
- height : isFullScreen ? ( window . outerHeight - 170 ) + 'px' : collapse ? '500px' : '585px' ,
442
+ height : isFullScreen ? ( window . outerHeight - 170 ) + 'px' : type !== CoreType . Profile && collapse ? '500px' : '585px' ,
443
443
width : '100%' ,
444
444
overflow : 'auto' ,
445
445
} }
446
446
>
447
447
< div style = { { margin : 0 , width : '100vw' } } ref = { container } id = "container" />
448
- { ! collapse && (
448
+ { ! ( collapse ) && (
449
449
< div className = "ZoomMenu" >
450
450
{
451
451
[
452
452
{
453
453
name : 'Zoom In' ,
454
454
onClick : ( ) => {
455
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
455
456
core ?. zoom ( 0.5 )
456
457
core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
457
458
} ,
@@ -460,6 +461,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
460
461
{
461
462
name : 'Zoom Out' ,
462
463
onClick : ( ) => {
464
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
463
465
core && Math . floor ( core . zoom ( ) ) <= 0.5 ? core ?. zoom ( 0 ) : core ?. zoom ( - 0.5 )
464
466
core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
465
467
} ,
@@ -468,6 +470,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
468
470
{
469
471
name : 'Reset Zoom' ,
470
472
onClick : ( ) => {
473
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
471
474
core ?. zoomTo ( 1 )
472
475
core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
473
476
} ,
@@ -486,32 +489,35 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
486
489
}
487
490
</ div >
488
491
) }
489
- < div
490
- style = { { paddingBottom : ( isFullScreen && profilingTime && ModuleType . Search ? '60px' : '35px' ) } }
491
- className = "CollapseButton"
492
- onClick = { e => {
493
- e . preventDefault ( )
494
- if ( ! collapse ) { // About to collapse?
495
- core ?. zoomTo ( 1 )
496
- core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
492
+ { type !== CoreType . Profile &&
493
+ < div
494
+ style = { { paddingBottom : ( isFullScreen && profilingTime && ModuleType . Search ? '60px' : '35px' ) } }
495
+ className = "CollapseButton"
496
+ onClick = { e => {
497
+ e . preventDefault ( )
498
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
499
+ if ( ! collapse ) { // About to collapse?
500
+ core ?. zoomTo ( 1 )
501
+ core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
502
+ }
503
+ setCollapse ( ! collapse )
504
+ } }
505
+ >
506
+ {
507
+ collapse
508
+ ?
509
+ < >
510
+ < div > Expand</ div >
511
+ < EuiIcon className = "NodeIcon" size = "m" type = "arrowDown" />
512
+ </ >
513
+ :
514
+ < >
515
+ < div > Collapse</ div >
516
+ < EuiIcon className = "NodeIcon" size = "m" type = "arrowUp" />
517
+ </ >
497
518
}
498
- setCollapse ( ! collapse )
499
- } }
500
- >
501
- {
502
- collapse
503
- ?
504
- < >
505
- < div > Expand</ div >
506
- < EuiIcon className = "NodeIcon" size = "m" type = "arrowDown" />
507
- </ >
508
- :
509
- < >
510
- < div > Collapse</ div >
511
- < EuiIcon className = "NodeIcon" size = "m" type = "arrowUp" />
512
- </ >
513
- }
514
- </ div >
519
+ </ div >
520
+ }
515
521
{ profilingTime &&
516
522
(
517
523
module === ModuleType . Search &&
0 commit comments