add PowerShell command option to API command copy dropdown (#2633)
This commit is contained in:
committed by
GitHub
parent
0503f403bd
commit
4872f9fa4e
@@ -20,14 +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 { CopyApiCommandDropdown } from "@/components/CopyApiCommandDropdown";
|
||||
import { type ApiCommandOptions } from "@/util/apiCommands";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { CopyIcon, PlayIcon, ReloadIcon } from "@radix-ui/react-icons";
|
||||
import { 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";
|
||||
@@ -622,11 +622,9 @@ function CreateNewTaskForm({ initialValues }: Props) {
|
||||
</TaskFormSection>
|
||||
|
||||
<div className="flex justify-end gap-3">
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={async () => {
|
||||
const curl = fetchToCurl({
|
||||
<CopyApiCommandDropdown
|
||||
getOptions={() =>
|
||||
({
|
||||
method: "POST",
|
||||
url: `${apiBaseUrl}/tasks`,
|
||||
body: createTaskRequestObject(form.getValues()),
|
||||
@@ -634,18 +632,9 @@ function CreateNewTaskForm({ initialValues }: Props) {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": apiCredential ?? "<your-api-key>",
|
||||
},
|
||||
});
|
||||
copyText(curl).then(() => {
|
||||
toast({
|
||||
title: "Copied cURL",
|
||||
description: "cURL copied to clipboard",
|
||||
});
|
||||
});
|
||||
}}
|
||||
>
|
||||
<CopyIcon className="mr-2 h-4 w-4" />
|
||||
cURL
|
||||
</Button>
|
||||
}) satisfies ApiCommandOptions
|
||||
}
|
||||
/>
|
||||
<Button type="submit" disabled={mutation.isPending}>
|
||||
{mutation.isPending && (
|
||||
<ReloadIcon className="mr-2 h-4 w-4 animate-spin" />
|
||||
|
||||
@@ -16,14 +16,14 @@ import { useApiCredential } from "@/hooks/useApiCredential";
|
||||
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
||||
import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
|
||||
import { SubmitEvent } from "@/types";
|
||||
import { copyText } from "@/util/copyText";
|
||||
import { apiBaseUrl } from "@/util/env";
|
||||
import { CopyApiCommandDropdown } from "@/components/CopyApiCommandDropdown";
|
||||
import { type ApiCommandOptions } from "@/util/apiCommands";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { CopyIcon, PlayIcon, ReloadIcon } from "@radix-ui/react-icons";
|
||||
import { 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, useParams } from "react-router-dom";
|
||||
@@ -737,11 +737,9 @@ function SavedTaskForm({ initialValues }: Props) {
|
||||
</TaskFormSection>
|
||||
|
||||
<div className="flex justify-end gap-3">
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={async () => {
|
||||
const curl = fetchToCurl({
|
||||
<CopyApiCommandDropdown
|
||||
getOptions={() =>
|
||||
({
|
||||
method: "POST",
|
||||
url: `${apiBaseUrl}/tasks`,
|
||||
body: createTaskRequestObject(form.getValues()),
|
||||
@@ -749,19 +747,9 @@ function SavedTaskForm({ initialValues }: Props) {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": apiCredential ?? "<your-api-key>",
|
||||
},
|
||||
});
|
||||
copyText(curl).then(() => {
|
||||
toast({
|
||||
variant: "success",
|
||||
title: "Copied successfully",
|
||||
description: "cURL copied to clipboard",
|
||||
});
|
||||
});
|
||||
}}
|
||||
>
|
||||
<CopyIcon className="mr-2 h-4 w-4" />
|
||||
cURL
|
||||
</Button>
|
||||
}) satisfies ApiCommandOptions
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
name="save"
|
||||
|
||||
Reference in New Issue
Block a user