@@ -33,7 +33,6 @@ import { CollapseWrapper, DirectoryTreeStyle, Node } from "./styledComponents";
33
33
import { DataNode , EventDataNode } from "antd/es/tree" ;
34
34
import { isAggregationApp } from "util/appUtils" ;
35
35
import Modal from "antd/es/modal/Modal" ;
36
- import copyToClipboard from "copy-to-clipboard" ;
37
36
38
37
const CollapseTitleWrapper = styled . div `
39
38
display: flex;
@@ -69,8 +68,22 @@ function getLen(config: string | boolean | number) {
69
68
return 0 ;
70
69
}
71
70
71
+ function safeStringify ( obj : any , space = 2 ) {
72
+ const cache = new Set ( ) ;
73
+ return JSON . stringify ( obj , ( key , value ) => {
74
+ if ( typeof value === 'object' && value !== null ) {
75
+ if ( cache . has ( value ) ) {
76
+ return '[Circular]' ;
77
+ }
78
+ cache . add ( value ) ;
79
+ }
80
+ return value ;
81
+ } , space ) ;
82
+ }
83
+
84
+
72
85
function toDataView ( value : any , name : string , desc ?: ReactNode , modal ?: boolean ) {
73
- const str = typeof value === "function" ? "Function" : safeJSONStringify ( value ) ;
86
+ const str = typeof value === "function" ? "Function" : safeStringify ( value ) ;
74
87
const descRecord : Record < string , ReactNode > = { } ;
75
88
const shortenedString = modal === true ? ( getLen ( str ) > 42 ? str . slice ( 0 , 42 ) + "..." : str ) : ( getLen ( str ) > 20 ? str . slice ( 0 , 20 ) + "..." : str ) ;
76
89
descRecord [ name ] = desc ;
@@ -205,7 +218,7 @@ const CollapseView = React.memo(
205
218
</ CollapseTitleWrapper >
206
219
</ Tooltip >
207
220
{ Object . keys ( data ) . length > 0 &&
208
- < CopyTextButton text = { JSON . stringify ( data ) } style = { { color : "#aaa" , marginRight : "8px" } } />
221
+ < CopyTextButton text = { safeStringify ( data ) } style = { { color : "#aaa" , marginRight : "8px" } } />
209
222
}
210
223
</ div >
211
224
) ,
@@ -440,7 +453,7 @@ export const LeftContent = (props: LeftContentProps) => {
440
453
maskClosable = { true } // Prevent closing on background click
441
454
>
442
455
< div
443
- style = { { whiteSpace : 'pre-wrap ' , wordWrap : 'break-word ' , maxHeight : "calc(100vh - 400px)" , overflow : "scroll" } }
456
+ style = { { whiteSpace : 'nowrap ' , wordWrap : 'normal ' , maxHeight : "calc(100vh - 400px)" , overflow : "scroll" } }
444
457
onClick = { ( e ) => e . stopPropagation ( ) } // Prevent closing on clicking inside the modal
445
458
>
446
459
{ prepareData ( data . data , data . dataDesc ) }
0 commit comments