diff --git a/web/src/components/OAuthLoginModal.tsx b/web/src/components/OAuthLoginModal.tsx index a6cd2ca299..f88b9c4292 100644 --- a/web/src/components/OAuthLoginModal.tsx +++ b/web/src/components/OAuthLoginModal.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef, useState } from "react"; -import { ExternalLink, Copy, X, Check, Loader2 } from "lucide-react"; -import { Button, H2 } from "@nous-research/ui"; +import { ExternalLink, X, Check, Loader2 } from "lucide-react"; +import { Button, CopyButton, H2 } from "@nous-research/ui"; import { api, type OAuthProvider, type OAuthStartResponse } from "@/lib/api"; import { Input } from "@/components/ui/input"; import { useI18n } from "@/i18n"; @@ -25,14 +25,12 @@ export function OAuthLoginModal({ provider, onClose, onSuccess, - onError, }: Props) { const [phase, setPhase] = useState("starting"); const [start, setStart] = useState(null); const [pkceCode, setPkceCode] = useState(""); const [errorMsg, setErrorMsg] = useState(null); const [secondsLeft, setSecondsLeft] = useState(null); - const [codeCopied, setCodeCopied] = useState(false); const isMounted = useRef(true); const pollTimer = useRef(null); const { t } = useI18n(); @@ -153,16 +151,6 @@ export function OAuthLoginModal({ onClose(); }; - const handleCopyUserCode = async (code: string) => { - try { - await navigator.clipboard.writeText(code); - setCodeCopied(true); - window.setTimeout(() => isMounted.current && setCodeCopied(false), 1500); - } catch { - onError("Clipboard write failed"); - } - }; - const handleBackdrop = (e: React.MouseEvent) => { if (e.target === e.currentTarget) handleClose(); }; @@ -286,26 +274,16 @@ export function OAuthLoginModal({ ).user_code } - + /> (null); const [loading, setLoading] = useState(true); const [busyId, setBusyId] = useState(null); - const [copiedId, setCopiedId] = useState(null); const [loginFor, setLoginFor] = useState(null); const { t } = useI18n(); @@ -55,17 +54,6 @@ export function OAuthProvidersCard({ onError, onSuccess }: Props) { refresh(); }, [refresh]); - const handleCopy = async (provider: OAuthProvider) => { - try { - await navigator.clipboard.writeText(provider.cli_command); - setCopiedId(provider.id); - onSuccess?.(`Copied: ${provider.cli_command}`); - setTimeout(() => setCopiedId((v) => (v === provider.id ? null : v)), 1500); - } catch { - onError?.("Clipboard write failed — copy the command manually"); - } - }; - const handleDisconnect = async (provider: OAuthProvider) => { if (!confirm(`${t.oauth.disconnect} ${provider.name}?`)) { return; @@ -206,14 +194,11 @@ export function OAuthProvidersCard({ onError, onSuccess }: Props) { )} {!p.status.logged_in && ( - + )} {p.status.logged_in && p.flow !== "external" && (