1- import { DropdownMenu , Flex , IconButton } from '@radix-ui/themes'
2- import { EllipsisVerticalIcon } from 'lucide-react'
1+ import { DropdownMenu , Flex , IconButton , Tooltip } from '@radix-ui/themes'
2+ import {
3+ CircleCheckBigIcon ,
4+ DownloadIcon ,
5+ EllipsisVerticalIcon ,
6+ SaveIcon ,
7+ } from 'lucide-react'
38import { useState } from 'react'
49
510import { ButtonWithTooltip } from '@/components/ButtonWithTooltip'
611import { DeleteFileDialog } from '@/components/DeleteFileDialog'
12+ import { RunInCloudButton } from '@/components/RunInCloudDialog/RunInCloudButton'
13+ import { RunInCloudDialog } from '@/components/RunInCloudDialog/RunInCloudDialog'
714import { useDeleteFile } from '@/hooks/useDeleteFile'
815import { useProxyStatus } from '@/hooks/useProxyStatus'
916import { useScriptPreview } from '@/hooks/useScriptPreview'
@@ -12,25 +19,20 @@ import { getFileNameWithoutExtension } from '@/utils/file'
1219
1320import { ExportScriptDialog } from '../ExportScriptDialog'
1421import { useGeneratorParams , useScriptExport } from '../Generator.hooks'
15- import { RecordingSelector } from '../RecordingSelector'
1622import { ValidatorDialog } from '../ValidatorDialog'
1723
1824interface GeneratorControlsProps {
1925 onSave : ( ) => void
2026 isDirty : boolean
21- onChangeRecording : ( ) => void
2227}
2328
24- export function GeneratorControls ( {
25- onSave,
26- isDirty,
27- onChangeRecording,
28- } : GeneratorControlsProps ) {
29+ export function GeneratorControls ( { onSave, isDirty } : GeneratorControlsProps ) {
2930 const scriptName = useGeneratorStore ( ( store ) => store . scriptName )
3031
3132 const [ isValidatorDialogOpen , setIsValidatorDialogOpen ] = useState ( false )
3233 const [ isExportScriptDialogOpen , setIsExportScriptDialogOpen ] =
3334 useState ( false )
35+ const [ isRunInCloudDialogOpen , setIsRunInCloudDialogOpen ] = useState ( false )
3436 const { fileName } = useGeneratorParams ( )
3537 const { preview, hasError } = useScriptPreview ( )
3638 const proxyStatus = useProxyStatus ( )
@@ -51,35 +53,59 @@ export function GeneratorControls({
5153
5254 return (
5355 < >
54- < RecordingSelector onChangeRecording = { onChangeRecording } />
5556 < Flex align = "center" justify = "between" gap = "2" ml = "2" >
56- < ButtonWithTooltip
57- onClick = { onSave }
58- disabled = { ! isDirty }
59- tooltip = { ! isDirty ? 'Changes saved' : '' }
60- >
61- Save generator
62- </ ButtonWithTooltip >
57+ < Flex gap = "4" align = "center" >
58+ < Tooltip content = { ! isDirty ? 'Changes saved' : 'Save changes' } >
59+ < IconButton
60+ onClick = { onSave }
61+ disabled = { ! isDirty }
62+ variant = "ghost"
63+ color = "gray"
64+ >
65+ < SaveIcon />
66+ </ IconButton >
67+ </ Tooltip >
68+ < Tooltip content = "Export script" >
69+ < IconButton
70+ onClick = { ( ) => setIsExportScriptDialogOpen ( true ) }
71+ disabled = { ! isScriptExportable }
72+ variant = "ghost"
73+ color = "gray"
74+ >
75+ < DownloadIcon />
76+ </ IconButton >
77+ </ Tooltip >
78+ </ Flex >
79+ < Flex gap = "4" align = "center" pl = "2" >
80+ < ButtonWithTooltip
81+ variant = "ghost"
82+ tooltip = {
83+ ! isScriptExportable
84+ ? 'Fix script errors to enable validation'
85+ : proxyStatus !== 'online'
86+ ? 'Start proxy to enable validation'
87+ : ''
88+ }
89+ onClick = { ( ) => setIsValidatorDialogOpen ( true ) }
90+ disabled = { ! isScriptExportable || proxyStatus !== 'online' }
91+ >
92+ < CircleCheckBigIcon /> Validate
93+ </ ButtonWithTooltip >
94+ < RunInCloudButton
95+ variant = "solid"
96+ disabled = { ! isScriptExportable }
97+ onClick = { ( ) => {
98+ setIsRunInCloudDialogOpen ( true )
99+ } }
100+ />
101+ </ Flex >
63102 < DropdownMenu . Root >
64103 < DropdownMenu . Trigger >
65104 < IconButton variant = "ghost" color = "gray" >
66105 < EllipsisVerticalIcon />
67106 </ IconButton >
68107 </ DropdownMenu . Trigger >
69108 < DropdownMenu . Content >
70- < DropdownMenu . Item
71- onSelect = { ( ) => setIsValidatorDialogOpen ( true ) }
72- disabled = { ! isScriptExportable || proxyStatus !== 'online' }
73- >
74- Validate script
75- </ DropdownMenu . Item >
76- < DropdownMenu . Item
77- onSelect = { ( ) => setIsExportScriptDialogOpen ( true ) }
78- disabled = { ! isScriptExportable }
79- >
80- Export script
81- </ DropdownMenu . Item >
82- < DropdownMenu . Separator />
83109 < DeleteFileDialog
84110 file = { file }
85111 onConfirm = { handleDelete }
@@ -96,6 +122,11 @@ export function GeneratorControls({
96122 </ DropdownMenu . Root >
97123 { isScriptExportable && (
98124 < >
125+ < RunInCloudDialog
126+ open = { isRunInCloudDialogOpen }
127+ script = { { type : 'raw' , name : fileName , content : preview } }
128+ onOpenChange = { setIsRunInCloudDialogOpen }
129+ />
99130 < ValidatorDialog
100131 script = { preview }
101132 open = { isValidatorDialogOpen }
0 commit comments