Revert "Revert "Your commit message""

This reverts commit 27c8539e6f.
This commit is contained in:
Prakash Maheshwaran
2025-06-05 06:05:30 -04:00
parent 27c8539e6f
commit d4bd317d73
7 changed files with 160 additions and 155 deletions

View File

@@ -14,11 +14,10 @@ import { Input } from "@/components/ui/input";
import { toast } from "@/components/ui/use-toast";
import { useApiCredential } from "@/hooks/useApiCredential";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { copyText } from "@/util/copyText";
import { apiBaseUrl } from "@/util/env";
import { CopyIcon, PlayIcon, ReloadIcon } from "@radix-ui/react-icons";
import { PlayIcon, ReloadIcon } from "@radix-ui/react-icons";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import fetchToCurl from "fetch-to-curl";
import { CopyApiCommandDropdown } from "@/components/CopyApiCommandDropdown";
import { useForm } from "react-hook-form";
import { useNavigate, useParams } from "react-router-dom";
import { z } from "zod";
@@ -333,39 +332,20 @@ function RunWorkflowForm({
</div>
<div className="flex justify-end gap-2">
<Button
type="button"
variant="secondary"
onClick={() => {
const values = form.getValues();
const body = getRunWorkflowRequestBody(
values,
<CopyApiCommandDropdown
getRequest={() => ({
method: "POST",
url: `${apiBaseUrl}/workflows/${workflowPermanentId}/run`,
body: getRunWorkflowRequestBody(
form.getValues(),
workflowParameters,
);
const curl = fetchToCurl({
method: "POST",
url: `${apiBaseUrl}/workflows/${workflowPermanentId}/run`,
body,
headers: {
"Content-Type": "application/json",
"x-api-key": apiCredential ?? "<your-api-key>",
},
});
copyText(curl).then(() => {
toast({
variant: "success",
title: "Copied to Clipboard",
description:
"The cURL command has been copied to your clipboard.",
});
});
}}
>
<CopyIcon className="mr-2 h-4 w-4" />
cURL
</Button>
),
headers: {
"Content-Type": "application/json",
"x-api-key": apiCredential ?? "<your-api-key>",
},
})}
/>
<Button type="submit" disabled={runWorkflowMutation.isPending}>
{runWorkflowMutation.isPending && (
<ReloadIcon className="mr-2 h-4 w-4 animate-spin" />

View File

@@ -17,17 +17,15 @@ import { Skeleton } from "@/components/ui/skeleton";
import { toast } from "@/components/ui/use-toast";
import { useApiCredential } from "@/hooks/useApiCredential";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { copyText } from "@/util/copyText";
import { apiBaseUrl } from "@/util/env";
import {
CopyIcon,
FileIcon,
Pencil2Icon,
PlayIcon,
ReloadIcon,
} from "@radix-ui/react-icons";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import fetchToCurl from "fetch-to-curl";
import { CopyApiCommandDropdown } from "@/components/CopyApiCommandDropdown";
import { Link, Outlet, useParams, useSearchParams } from "react-router-dom";
import { statusIsFinalized, statusIsRunningOrQueued } from "../tasks/types";
import { useWorkflowQuery } from "./hooks/useWorkflowQuery";
@@ -183,37 +181,20 @@ function WorkflowRun() {
</div>
<div className="flex gap-2">
<Button
variant="secondary"
onClick={() => {
if (!workflowRun) {
return;
}
const curl = fetchToCurl({
method: "POST",
url: `${apiBaseUrl}/workflows/${workflowPermanentId}/run`,
body: {
data: workflowRun?.parameters,
proxy_location: "RESIDENTIAL",
},
headers: {
"Content-Type": "application/json",
"x-api-key": apiCredential ?? "<your-api-key>",
},
});
copyText(curl).then(() => {
toast({
variant: "success",
title: "Copied to Clipboard",
description:
"The cURL command has been copied to your clipboard.",
});
});
}}
>
<CopyIcon className="mr-2 h-4 w-4" />
cURL
</Button>
<CopyApiCommandDropdown
getRequest={() => ({
method: "POST",
url: `${apiBaseUrl}/workflows/${workflowPermanentId}/run`,
body: {
data: workflowRun?.parameters,
proxy_location: "RESIDENTIAL",
},
headers: {
"Content-Type": "application/json",
"x-api-key": apiCredential ?? "<your-api-key>",
},
})}
/>
<Button asChild variant="secondary">
<Link to={`/workflows/${workflowPermanentId}/edit`}>
<Pencil2Icon className="mr-2 h-4 w-4" />