diff --git a/skyvern-frontend/src/components/CopyApiCommandDropdown.tsx b/skyvern-frontend/src/components/CopyApiCommandDropdown.tsx deleted file mode 100644 index 57dd40db..00000000 --- a/skyvern-frontend/src/components/CopyApiCommandDropdown.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { CopyIcon } from "@radix-ui/react-icons"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { Button } from "@/components/ui/button"; -import { useToast } from "@/components/ui/use-toast"; -import { copyText } from "@/util/copyText"; -import { - type ApiRequest, - getCurlCommand, - getPowerShellCommand, -} from "@/util/apiCommands"; - -interface Props { - getRequest: () => ApiRequest; -} - -function CopyApiCommandDropdown({ getRequest }: Props) { - const { toast } = useToast(); - - const handleCopy = async (type: "curl" | "powershell") => { - const request = getRequest(); - const text = - type === "curl" ? getCurlCommand(request) : getPowerShellCommand(request); - await copyText(text); - toast({ - variant: "success", - title: "Copied to Clipboard", - description: - type === "curl" - ? "The cURL command has been copied to your clipboard." - : "The PowerShell command has been copied to your clipboard.", - }); - }; - - return ( - - - - - Copy API Command - - - - handleCopy("curl")}> - Copy cURL (Unix/Linux/macOS) - - handleCopy("powershell")}> - Copy PowerShell (Windows) - - - - ); -} - -export { CopyApiCommandDropdown }; diff --git a/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx b/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx index cf697f22..8631daa3 100644 --- a/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx +++ b/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx @@ -20,12 +20,14 @@ import { toast } from "@/components/ui/use-toast"; import { useApiCredential } from "@/hooks/useApiCredential"; import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { CodeEditor } from "@/routes/workflows/components/CodeEditor"; +import { copyText } from "@/util/copyText"; import { apiBaseUrl } from "@/util/env"; import { zodResolver } from "@hookform/resolvers/zod"; -import { PlayIcon, ReloadIcon } from "@radix-ui/react-icons"; +import { CopyIcon, PlayIcon, ReloadIcon } from "@radix-ui/react-icons"; import { ToastAction } from "@radix-ui/react-toast"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { AxiosError } from "axios"; +import fetchToCurl from "fetch-to-curl"; import { useState } from "react"; import { useForm, useFormState } from "react-hook-form"; import { Link } from "react-router-dom"; @@ -37,7 +39,6 @@ import { } from "./taskFormTypes"; import { ProxySelector } from "@/components/ProxySelector"; import { Switch } from "@/components/ui/switch"; -import { CopyApiCommandDropdown } from "@/components/CopyApiCommandDropdown"; type Props = { initialValues: CreateNewTaskFormValues; }; @@ -621,17 +622,30 @@ function CreateNewTaskForm({ initialValues }: Props) {