mirror of
https://github.com/tale/headplane.git
synced 2026-08-20 18:02:17 +00:00
feat: separate code snippets and code blocks for copyable snippets
This commit is contained in:
+3
-25
@@ -1,4 +1,4 @@
|
||||
import { Check, Copy } from "lucide-react";
|
||||
import { Check } from "lucide-react";
|
||||
import { redirect } from "react-router";
|
||||
|
||||
import androidSvg from "~/assets/android.svg";
|
||||
@@ -6,14 +6,13 @@ import iosSvg from "~/assets/ios.svg";
|
||||
import linuxSvg from "~/assets/linux.svg";
|
||||
import macosSvg from "~/assets/macos.svg";
|
||||
import windowsSvg from "~/assets/windows.svg";
|
||||
import Button from "~/components/button";
|
||||
import Card from "~/components/card";
|
||||
import CodeBlock from "~/components/code-block";
|
||||
import Link from "~/components/link";
|
||||
import LinkAccount from "~/layout/link-account";
|
||||
import { usersResource } from "~/server/headscale/live-store";
|
||||
import { Capabilities } from "~/server/web/roles";
|
||||
import cn from "~/utils/cn";
|
||||
import toast from "~/utils/toast";
|
||||
import { getUserDisplayName } from "~/utils/user";
|
||||
|
||||
import type { Route } from "./+types/home";
|
||||
@@ -152,28 +151,7 @@ export default function Home({ loaderData }: Route.ComponentProps) {
|
||||
<img alt="Linux" className="w-4 dark:invert" src={linuxSvg} />
|
||||
<span className="text-sm font-medium">Linux</span>
|
||||
</div>
|
||||
<div className="mt-2 flex items-center gap-2">
|
||||
<code
|
||||
className={cn(
|
||||
"flex-1 rounded-md px-3 py-2 text-xs h-8",
|
||||
"bg-mist-100 dark:bg-mist-800",
|
||||
)}
|
||||
>
|
||||
curl -fsSL https://tailscale.com/install.sh | sh
|
||||
</code>
|
||||
<Button
|
||||
className="h-8 p-1 px-2"
|
||||
variant="ghost"
|
||||
onClick={async () => {
|
||||
await navigator.clipboard.writeText(
|
||||
"curl -fsSL https://tailscale.com/install.sh | sh",
|
||||
);
|
||||
toast("Copied to clipboard");
|
||||
}}
|
||||
>
|
||||
<Copy className="size-4" />
|
||||
</Button>
|
||||
</div>
|
||||
<CodeBlock className="mt-2">curl -fsSL https://tailscale.com/install.sh | sh</CodeBlock>
|
||||
<p className="mt-1 text-xs text-mist-500 dark:text-mist-400">
|
||||
<Link
|
||||
external
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Computer, FileKey2 } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router";
|
||||
|
||||
import Code from "~/components/code";
|
||||
import CodeBlock from "~/components/code-block";
|
||||
import Dialog, { DialogPanel } from "~/components/dialog";
|
||||
import Input from "~/components/input";
|
||||
import { Menu, MenuContent, MenuItem, MenuTrigger } from "~/components/menu";
|
||||
@@ -36,10 +36,8 @@ export default function NewMachine(data: NewMachineProps) {
|
||||
<Dialog isOpen={pushDialog} onOpenChange={setPushDialog}>
|
||||
<DialogPanel isDisabled={!form.canSubmit}>
|
||||
<Title>Register Machine Key</Title>
|
||||
<Text className="mb-4">
|
||||
The machine key is given when you run{" "}
|
||||
<Code isCopyable>tailscale up --login-server={data.server}</Code> on your device.
|
||||
</Text>
|
||||
<Text>The machine key is given when you run the following command on your device:</Text>
|
||||
<CodeBlock className="mb-4">{`tailscale up --login-server=${data.server}`}</CodeBlock>
|
||||
<input name="action_id" type="hidden" value="register" />
|
||||
<Input
|
||||
{...form.field("register_key")}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from "react";
|
||||
import { useFetcher } from "react-router";
|
||||
|
||||
import Button from "~/components/button";
|
||||
import Code from "~/components/code";
|
||||
import CodeBlock from "~/components/code-block";
|
||||
import Dialog, { DialogPanel } from "~/components/dialog";
|
||||
import Input from "~/components/input";
|
||||
import Link from "~/components/link";
|
||||
@@ -12,7 +12,6 @@ import Switch from "~/components/switch";
|
||||
import Text from "~/components/text";
|
||||
import Title from "~/components/title";
|
||||
import type { User } from "~/types";
|
||||
import toast from "~/utils/toast";
|
||||
import { getUserDisplayName } from "~/utils/user";
|
||||
|
||||
interface AddAuthKeyProps {
|
||||
@@ -95,23 +94,11 @@ export default function AddAuthKey({
|
||||
<DialogPanel variant="unactionable">
|
||||
<Title>Pre-auth key created</Title>
|
||||
<Text>Copy this key now. You will not be able to see the full key again.</Text>
|
||||
<div className="mt-4 flex items-center gap-2 rounded-lg bg-mist-100 px-3 py-2 dark:bg-mist-800">
|
||||
<code className="min-w-0 flex-1 truncate font-mono text-sm">{createdKey}</code>
|
||||
<Button
|
||||
className="shrink-0"
|
||||
onClick={async () => {
|
||||
await navigator.clipboard.writeText(createdKey);
|
||||
toast("Copied key to clipboard");
|
||||
}}
|
||||
variant="light"
|
||||
>
|
||||
Copy
|
||||
</Button>
|
||||
</div>
|
||||
<CodeBlock className="mt-4">{createdKey}</CodeBlock>
|
||||
<Text className="mt-4 text-sm">To register a device with this key:</Text>
|
||||
<Code isCopyable className="mt-1 block text-sm">
|
||||
<CodeBlock className="mt-1">
|
||||
{`tailscale up --login-server=${url} --authkey ${createdKey}`}
|
||||
</Code>
|
||||
</CodeBlock>
|
||||
</DialogPanel>
|
||||
) : (
|
||||
<DialogPanel
|
||||
|
||||
Reference in New Issue
Block a user