diff --git a/surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/obsidian-connect-form.tsx b/surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/obsidian-connect-form.tsx index 695e97d7b..7ec39803b 100644 --- a/surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/obsidian-connect-form.tsx +++ b/surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/obsidian-connect-form.tsx @@ -2,10 +2,12 @@ import { Check, Copy, Info } from "lucide-react"; import type { FC } from "react"; +import { useState } from "react"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { EnumConnectorName } from "@/contracts/enums/connector"; -import { useApiKey } from "@/hooks/use-api-key"; +import { usePats } from "@/hooks/use-pats"; +import { copyToClipboard } from "@/lib/utils"; import { getConnectorBenefits } from "../connector-benefits"; import type { ConnectFormProps } from "../index"; @@ -26,13 +28,23 @@ const PLUGIN_RELEASES_URL = * nothing to validate or persist from this side. */ export const ObsidianConnectForm: FC = ({ onBack }) => { - const { apiKey, isLoading, copied, copyToClipboard } = useApiKey(); + const { createdToken, isMutating, createToken } = usePats(); + const [copied, setCopied] = useState(false); const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); onBack(); }; + const createAndCopyToken = async () => { + const token = await createToken({ label: "Obsidian plugin", expires_in_days: null }); + const success = await copyToClipboard(token.token); + if (success) { + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } + }; + return (
{/* Form is intentionally empty so the footer Connect button is a no-op @@ -82,48 +94,51 @@ export const ObsidianConnectForm: FC = ({ onBack }) => {
- {/* Step 2 — Copy API key */} + {/* Step 2 — Create PAT */}
2
-

Copy your API key

+

+ Create a personal access token +

- Paste this into the plugin's API token setting. - The token expires after 24 hours. Long-lived personal access tokens are coming in a - future release. + Create a token and paste it into the plugin's{" "} + API token setting. The token is shown only once.

- {isLoading ? ( -
- ) : apiKey ? ( + {createdToken ? (

- {apiKey} + {createdToken.token}

) : ( -

- No API key available — try refreshing the page. -

+ )}