diff --git a/src/views/Generator/GeneraterControls/GeneratorControls.tsx b/src/views/Generator/GeneraterControls/GeneratorControls.tsx index aa865bab..c5a826dc 100644 --- a/src/views/Generator/GeneraterControls/GeneratorControls.tsx +++ b/src/views/Generator/GeneraterControls/GeneratorControls.tsx @@ -1,10 +1,9 @@ +import { useState } from 'react' import { Button, ButtonProps, Tooltip } from '@radix-ui/themes' -import { RecordingSelector } from '../RecordingSelector' -import { Allowlist } from '../Allowlist' + import { useScriptPreview } from '@/hooks/useScriptPreview' import { exportScript } from '../Generator.utils' import { ValidatorDialog } from './ValidatorDialog' -import { useState } from 'react' interface GeneratorControlsProps { onSave: () => void @@ -18,9 +17,6 @@ export function GeneratorControls({ onSave, isDirty }: GeneratorControlsProps) { return ( <> - - - {!!preview && ( <> (null) const { filter, setFilter, filteredRequests } = useFilterRequests(requests) - // Preserve the selected request when modifiying rules + // Preserve the selected request when modifying rules useShallowCompareEffect(() => { setSelectedRequest(null) }, [requests]) return ( - - - - - - - - -
- - + + + + + +
+ + + + + + + + +
+ + +
+
) } diff --git a/src/views/Generator/RecordingSelector.tsx b/src/views/Generator/RecordingSelector.tsx index 4e61ed0e..7c9511e6 100644 --- a/src/views/Generator/RecordingSelector.tsx +++ b/src/views/Generator/RecordingSelector.tsx @@ -1,57 +1,74 @@ -import { Button, DropdownMenu } from '@radix-ui/themes' +import { Flex, IconButton, Select, Text, Tooltip } from '@radix-ui/themes' +import { PlusIcon } from '@radix-ui/react-icons' +import { css } from '@emotion/react' import { useGeneratorStore } from '@/store/generator' import { harToProxyData } from '@/utils/harToProxyData' import { useStudioUIStore } from '@/store/ui' -import { CaretDownIcon } from '@radix-ui/react-icons' import { getFileNameWithoutExtension } from '@/utils/file' +import { useToast } from '@/store/ui/useToast' export function RecordingSelector() { const recordingPath = useGeneratorStore((store) => store.recordingPath) const setRecording = useGeneratorStore((store) => store.setRecording) const recordings = useStudioUIStore((store) => store.recordings) + const showToast = useToast() const handleOpen = async (filePath: string) => { - const harFile = await window.studio.har.openFile(filePath) + try { + const harFile = await window.studio.har.openFile(filePath) - const proxyData = harToProxyData(harFile.content) - setRecording(proxyData, harFile.name) + const proxyData = harToProxyData(harFile.content) + setRecording(proxyData, harFile.name) + } catch (error) { + showToast({ + title: 'Failed to open recording', + status: 'error', + }) + } } const handleImport = async () => { - const filePath = await window.studio.har.importFile() + try { + const filePath = await window.studio.har.importFile() - if (!filePath) return + if (!filePath) return - await handleOpen(filePath) + await handleOpen(filePath) + } catch (error) { + showToast({ + title: 'Failed to import recording', + status: 'error', + }) + } } return ( - - - - - - + + + Recording + + + + {recordings.map((harFileName) => ( - + {getFileNameWithoutExtension(harFileName)} - + ))} - - {recordings.length > 0 && } - - Import HAR file - - - + + + + + + + + ) }