feat: add copy button api key
This commit is contained in:
parent
4a474a9fa8
commit
b094fcf4b4
@ -11,6 +11,7 @@ import {
|
|||||||
FormMessage,
|
FormMessage,
|
||||||
Form,
|
Form,
|
||||||
} from "./ui/form";
|
} from "./ui/form";
|
||||||
|
import { CopyButton } from "@/components/CopyButton";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import {
|
import {
|
||||||
@ -387,16 +388,19 @@ function AddMachinesDialog() {
|
|||||||
{apiKey && (
|
{apiKey && (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>API Key (Copy the API key now)</FormLabel>
|
<FormLabel>API Key (Copy the API key now)</FormLabel>
|
||||||
<FormControl>
|
<div className="flex gap-2">
|
||||||
<Input readOnly value={apiKey.key} />
|
<FormControl>
|
||||||
</FormControl>
|
<Input readOnly value={apiKey.key} />
|
||||||
{/* <FormMessage></FormMessage> */}
|
</FormControl>
|
||||||
|
<CopyButton text={apiKey.key} />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
{apiKey ? (
|
{apiKey ? (
|
||||||
<Button
|
<Button
|
||||||
|
className="flex gap-2"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
@ -405,7 +409,11 @@ function AddMachinesDialog() {
|
|||||||
Close {form.formState.isSubmitting && <LoadingIcon />}
|
Close {form.formState.isSubmitting && <LoadingIcon />}
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<Button type="submit" disabled={form.formState.isSubmitting}>
|
<Button
|
||||||
|
className="flex gap-2"
|
||||||
|
type="submit"
|
||||||
|
disabled={form.formState.isSubmitting}
|
||||||
|
>
|
||||||
Create {form.formState.isSubmitting && <LoadingIcon />}
|
Create {form.formState.isSubmitting && <LoadingIcon />}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { Copy } from "lucide-react";
|
import { Copy } from "lucide-react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
export function CopyButton({
|
export function CopyButton({
|
||||||
className,
|
className,
|
||||||
@ -13,7 +14,9 @@ export function CopyButton({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
toast.success("Copied to clipboard");
|
||||||
navigator.clipboard.writeText(props.text);
|
navigator.clipboard.writeText(props.text);
|
||||||
}}
|
}}
|
||||||
className={cn(" p-2 min-h-0 aspect-square", className)}
|
className={cn(" p-2 min-h-0 aspect-square", className)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user