add PowerShell command option to API command copy dropdown (#2633)

This commit is contained in:
Prakash Maheshwaran
2025-06-09 21:01:45 -04:00
committed by GitHub
parent 0503f403bd
commit 4872f9fa4e
7 changed files with 178 additions and 109 deletions

View File

@@ -17,17 +17,14 @@ 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 { Link, Outlet, useParams, useSearchParams } from "react-router-dom";
import { statusIsFinalized, statusIsRunningOrQueued } from "../tasks/types";
import { useWorkflowQuery } from "./hooks/useWorkflowQuery";
@@ -39,6 +36,8 @@ import { Label } from "@/components/ui/label";
import { CodeEditor } from "./components/CodeEditor";
import { cn } from "@/util/utils";
import { ScrollArea, ScrollAreaViewport } from "@/components/ui/scroll-area";
import { CopyApiCommandDropdown } from "@/components/CopyApiCommandDropdown";
import { type ApiCommandOptions } from "@/util/apiCommands";
function WorkflowRun() {
const [searchParams, setSearchParams] = useSearchParams();
@@ -183,13 +182,9 @@ function WorkflowRun() {
</div>
<div className="flex gap-2">
<Button
variant="secondary"
onClick={() => {
if (!workflowRun) {
return;
}
const curl = fetchToCurl({
<CopyApiCommandDropdown
getOptions={() =>
({
method: "POST",
url: `${apiBaseUrl}/workflows/${workflowPermanentId}/run`,
body: {
@@ -200,20 +195,9 @@ function WorkflowRun() {
"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>
}) satisfies ApiCommandOptions
}
/>
<Button asChild variant="secondary">
<Link to={`/workflows/${workflowPermanentId}/edit`}>
<Pencil2Icon className="mr-2 h-4 w-4" />