From d21b6e6adcf5224c69100ae9ddda8b82313485bd Mon Sep 17 00:00:00 2001 From: Kerem Yilmaz Date: Mon, 26 Aug 2024 13:17:32 +0300 Subject: [PATCH] Add copy as curl in task details (#732) --- .../src/routes/tasks/detail/TaskDetails.tsx | 122 ++++++++++++------ 1 file changed, 84 insertions(+), 38 deletions(-) diff --git a/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx b/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx index 1a78005a2..ae7c14222 100644 --- a/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx +++ b/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx @@ -1,5 +1,5 @@ import { getClient } from "@/api/AxiosClient"; -import { Status } from "@/api/types"; +import { Status, TaskApiResponse } from "@/api/types"; import { Button } from "@/components/ui/button"; import { Dialog, @@ -17,17 +17,34 @@ import { Textarea } from "@/components/ui/textarea"; import { toast } from "@/components/ui/use-toast"; import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { cn } from "@/util/utils"; -import { ReloadIcon } from "@radix-ui/react-icons"; +import { CopyIcon, ReloadIcon } from "@radix-ui/react-icons"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { Link, NavLink, Outlet, useParams } from "react-router-dom"; import { TaskInfo } from "./TaskInfo"; import { useTaskQuery } from "./hooks/useTaskQuery"; import { taskIsFinalized } from "@/api/utils"; +import fetchToCurl from "fetch-to-curl"; +import { apiBaseUrl } from "@/util/env"; +import { useApiCredential } from "@/hooks/useApiCredential"; + +function createTaskRequestObject(values: TaskApiResponse) { + return { + url: values.request.url, + webhook_callback_url: values.request.webhook_callback_url, + navigation_goal: values.request.navigation_goal, + data_extraction_goal: values.request.data_extraction_goal, + proxy_location: values.request.proxy_location, + error_code_mapping: values.request.error_code_mapping, + navigation_payload: values.request.navigation_payload, + extracted_information_schema: values.request.extracted_information_schema, + }; +} function TaskDetails() { const { taskId } = useParams(); const credentialGetter = useCredentialGetter(); const queryClient = useQueryClient(); + const apiCredential = useApiCredential(); const { data: task, @@ -109,43 +126,72 @@ function TaskDetails() { {taskId} {taskId && } - {taskIsRunningOrQueued && ( - - - - - - - Are you sure? - - Are you sure you want to cancel this task? - - - - - - - - - - - )} - {taskHasTerminalState && ( - - )} + {taskIsRunningOrQueued && ( + + + + + + + Are you sure? + + Are you sure you want to cancel this task? + + + + + + + + + + + )} + {taskHasTerminalState && ( + + )} + {taskIsLoading ? (