Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Heading } from "@chakra-ui/react";
import { FC } from "react";
import { FC, useState } from "react";
import { ClipboardDocumentIcon, ClipboardDocumentCheckIcon } from "@heroicons/react/24/outline";
import CodeBlock from "../../../components/tavern-base-ui/CodeBlock";
import AlertError from "../../../components/tavern-base-ui/AlertError";
import { RepositoryNode } from "../../../utils/interfacesQuery";
Expand All @@ -13,11 +14,23 @@ type StepAddDeploymentKeyProps = {
}

const StepAddDeploymentKey: FC<StepAddDeploymentKeyProps> = ({ setCurrStep, newRepository, setOpen }) => {
const [copied, setCopied] = useState(false);

const handleOnSuccess = () => {
setOpen(false);
}
const { importRepositoryTomes, loading, error } = useFetchRepositoryTome(handleOnSuccess);

const handleCopy = async () => {
try {
await navigator.clipboard.writeText(newRepository?.publicKey || "");
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch (err) {
console.error("Failed to copy text:", err);
}
};

return (
<form className="flex flex-col gap-6">
<div className="flex flex-col">
Expand All @@ -36,7 +49,24 @@ const StepAddDeploymentKey: FC<StepAddDeploymentKeyProps> = ({ setCurrStep, newR
)}
<div className="flex flex-col gap-2">
<Heading size="sm">Copy public key</Heading>
<CodeBlock code={newRepository?.publicKey || ""} showCopyButton />
<div className="flex flex-row items-start gap-2">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a copy button in CodeBlock. We should probably be editing and modifying that rather than creating a wrapper with duplicated functionality.

<Button
onClick={(e) => {
e.preventDefault();
handleCopy();
}}
buttonVariant="ghost"
buttonStyle={{ color: "gray", size: "sm" }}
aria-label={copied ? "Copied" : "Copy code"}
leftIcon={copied
? <ClipboardDocumentCheckIcon className="w-5 h-5 text-green-600" />
: <ClipboardDocumentIcon className="w-5 h-5" />
}
/>
<div className="flex-grow w-full">
<CodeBlock code={newRepository?.publicKey || ""} />
</div>
</div>
</div>
<div className="flex flex-row gap-2">
<Button
Expand Down
Loading