@@ -2,11 +2,11 @@ import { observer } from "mobx-react";
2
2
import { createContext , forwardRef , useCallback , useEffect , useMemo , useRef , useState } from "react" ;
3
3
import { useSDK } from "../../../providers/SDKProvider" ;
4
4
import { isDefined } from "../../../utils/utils" ;
5
- import { Button } from "../Button/Button" ;
6
5
import { Icon } from "../Icon/Icon" ;
7
6
import { modal } from "../Modal/Modal" ;
8
- import { IconCode , IconGear , IconGearNewUI } from "@humansignal/icons" ;
9
- import { AutoSizerTable , Tooltip } from "@humansignal/ui" ;
7
+ import { IconCode , IconGear , IconGearNewUI , IconCopyOutline } from "@humansignal/icons" ;
8
+ import { AutoSizerTable , Tooltip , Button } from "@humansignal/ui" ;
9
+ import { useCopyText } from "@humansignal/core/lib/hooks/useCopyText" ;
10
10
import "./Table.scss" ;
11
11
import { TableCheckboxCell } from "./TableCheckbox" ;
12
12
import { tableCN , TableContext } from "./TableContext" ;
@@ -132,16 +132,16 @@ export const Table = observer(
132
132
return (
133
133
< Tooltip title = "Show task source" >
134
134
< Button
135
- type = "link "
136
- style = { { width : 32 , height : 32 , padding : 0 } }
135
+ look = "string "
136
+ className = "w-6 h-6 p-0 text-primary-content hover:text-primary-content-hover"
137
137
onClick = { ( ) => {
138
138
modal ( {
139
139
title : `Source for task ${ out ?. id } ` ,
140
140
style : { width : 800 } ,
141
141
body : < TaskSourceView content = { out } onTaskLoad = { onTaskLoad } sdkType = { type } /> ,
142
142
} ) ;
143
143
} }
144
- icon = { < Icon icon = { IconCode } /> }
144
+ leading = { < Icon icon = { IconCode } /> }
145
145
/>
146
146
</ Tooltip >
147
147
) ;
@@ -445,5 +445,40 @@ const TaskSourceView = ({ content, onTaskLoad, sdkType }) => {
445
445
} ) ;
446
446
} , [ ] ) ;
447
447
448
- return < pre > { source ? JSON . stringify ( source , null , " " ) : null } </ pre > ;
448
+ const jsonString = useMemo ( ( ) => {
449
+ return source ? JSON . stringify ( source , null , 2 ) : "" ;
450
+ } , [ source ] ) ;
451
+
452
+ const [ handleCopy , copied ] = useCopyText ( jsonString ) ;
453
+
454
+ return (
455
+ < div
456
+ className = "bg-neutral-surface rounded-small font-mono text-body-small leading-body-small overflow-auto max-h-[500px]"
457
+ style = { { position : "relative" } }
458
+ >
459
+ < div style = { { padding : "16px" , paddingTop : "16px" } } >
460
+ < Tooltip title = { copied ? "Copied!" : "Copy JSON" } >
461
+ < Button
462
+ look = "string"
463
+ variant = "neutral"
464
+ style = { {
465
+ position : "absolute" ,
466
+ top : "8px" ,
467
+ right : "8px" ,
468
+ width : 32 ,
469
+ height : 32 ,
470
+ padding : 0 ,
471
+ zIndex : 10 ,
472
+ color : "var(--color-neutral-content-subtle)" ,
473
+ } }
474
+ onClick = { handleCopy }
475
+ leading = { < Icon icon = { IconCopyOutline } style = { { color : "var(--color-neutral-content-subtle)" } } /> }
476
+ />
477
+ </ Tooltip >
478
+ < pre className = "m-0 whitespace-pre-wrap break-words max-w-full" style = { { marginRight : "40px" } } >
479
+ { jsonString }
480
+ </ pre >
481
+ </ div >
482
+ </ div >
483
+ ) ;
449
484
} ;
0 commit comments