@@ -14,9 +14,10 @@ import DeleteIcon from '@mui/icons-material/Delete'
14
14
import ConfirmDialog from '@/ui-component/dialog/ConfirmDialog'
15
15
import { CodeEditor } from '@/ui-component/editor/CodeEditor'
16
16
import HowToUseFunctionDialog from './HowToUseFunctionDialog'
17
+ import PasteJSONDialog from './PasteJSONDialog'
17
18
18
19
// Icons
19
- import { IconX , IconFileDownload , IconPlus , IconTemplate } from '@tabler/icons-react'
20
+ import { IconX , IconFileDownload , IconPlus , IconTemplate , IconCode } from '@tabler/icons-react'
20
21
21
22
// API
22
23
import toolsApi from '@/api/tools'
@@ -83,6 +84,8 @@ const ToolDialog = ({ show, dialogProps, onUseTemplate, onCancel, onConfirm, set
83
84
const [ exportAsTemplateDialogOpen , setExportAsTemplateDialogOpen ] = useState ( false )
84
85
const [ exportAsTemplateDialogProps , setExportAsTemplateDialogProps ] = useState ( { } )
85
86
87
+ const [ showPasteJSONDialog , setShowPasteJSONDialog ] = useState ( false )
88
+
86
89
const deleteItem = useCallback (
87
90
( id ) => ( ) => {
88
91
setTimeout ( ( ) => {
@@ -409,6 +412,11 @@ const ToolDialog = ({ show, dialogProps, onUseTemplate, onCancel, onConfirm, set
409
412
}
410
413
}
411
414
415
+ const handlePastedJSON = ( formattedData ) => {
416
+ setToolSchema ( formattedData )
417
+ setShowPasteJSONDialog ( false )
418
+ }
419
+
412
420
const component = show ? (
413
421
< Dialog
414
422
fullWidth
@@ -507,9 +515,14 @@ const ToolDialog = ({ show, dialogProps, onUseTemplate, onCancel, onConfirm, set
507
515
< TooltipWithParser title = { 'What is the input format in JSON?' } />
508
516
</ Stack >
509
517
{ dialogProps . type !== 'TEMPLATE' && (
510
- < Button variant = 'outlined' onClick = { addNewRow } startIcon = { < IconPlus /> } >
511
- Add Item
512
- </ Button >
518
+ < Stack direction = 'row' spacing = { 1 } >
519
+ < Button variant = 'outlined' onClick = { ( ) => setShowPasteJSONDialog ( true ) } startIcon = { < IconCode /> } >
520
+ Paste JSON
521
+ </ Button >
522
+ < Button variant = 'outlined' onClick = { addNewRow } startIcon = { < IconPlus /> } >
523
+ Add Item
524
+ </ Button >
525
+ </ Stack >
513
526
) }
514
527
</ Stack >
515
528
< Grid columns = { columns } rows = { toolSchema } disabled = { dialogProps . type === 'TEMPLATE' } onRowUpdate = { onRowUpdate } />
@@ -577,6 +590,15 @@ const ToolDialog = ({ show, dialogProps, onUseTemplate, onCancel, onConfirm, set
577
590
) }
578
591
579
592
< HowToUseFunctionDialog show = { showHowToDialog } onCancel = { ( ) => setShowHowToDialog ( false ) } />
593
+
594
+ { showPasteJSONDialog && (
595
+ < PasteJSONDialog
596
+ show = { showPasteJSONDialog }
597
+ onCancel = { ( ) => setShowPasteJSONDialog ( false ) }
598
+ onConfirm = { handlePastedJSON }
599
+ customization = { customization }
600
+ />
601
+ ) }
580
602
</ Dialog >
581
603
) : null
582
604
0 commit comments