2026-01-24 19:49:42 -06:00
|
|
|
import React, { useState } from "react";
|
2026-05-11 01:23:11 -05:00
|
|
|
import { Button } from "@/components/button.tsx";
|
|
|
|
|
import { Input } from "@/components/input.tsx";
|
2026-05-28 22:29:20 -05:00
|
|
|
import { Shield, Copy, ExternalLink, Check } from "lucide-react";
|
2026-01-24 19:49:42 -06:00
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
import { toast } from "sonner";
|
|
|
|
|
|
|
|
|
|
interface WarpgateDialogProps {
|
|
|
|
|
isOpen: boolean;
|
|
|
|
|
url: string;
|
|
|
|
|
securityKey: string;
|
|
|
|
|
onContinue: () => void;
|
|
|
|
|
onCancel: () => void;
|
|
|
|
|
onOpenUrl: () => void;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function WarpgateDialog({
|
|
|
|
|
isOpen,
|
|
|
|
|
url,
|
|
|
|
|
securityKey,
|
|
|
|
|
onContinue,
|
|
|
|
|
onCancel,
|
|
|
|
|
onOpenUrl,
|
|
|
|
|
backgroundColor,
|
|
|
|
|
}: WarpgateDialogProps) {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const [copied, setCopied] = useState(false);
|
|
|
|
|
|
|
|
|
|
if (!isOpen) return null;
|
|
|
|
|
|
|
|
|
|
const handleCopyUrl = async () => {
|
|
|
|
|
try {
|
|
|
|
|
await navigator.clipboard.writeText(url);
|
|
|
|
|
setCopied(true);
|
|
|
|
|
toast.success(t("common.copied"));
|
|
|
|
|
setTimeout(() => setCopied(false), 2000);
|
2026-05-06 15:12:07 -05:00
|
|
|
} catch {
|
2026-01-24 19:49:42 -06:00
|
|
|
toast.error(t("common.copyFailed"));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2026-05-28 22:29:20 -05:00
|
|
|
<div className="absolute inset-0 flex items-center justify-center z-500 animate-in fade-in duration-200 overflow-y-auto">
|
2026-01-24 19:49:42 -06:00
|
|
|
<div
|
|
|
|
|
className="absolute inset-0 bg-canvas rounded-md"
|
|
|
|
|
style={{ backgroundColor: backgroundColor || undefined }}
|
|
|
|
|
/>
|
2026-05-28 22:29:20 -05:00
|
|
|
<div className="bg-card border border-border w-full max-w-md mx-4 my-4 relative z-10 animate-in fade-in zoom-in-95 duration-200">
|
|
|
|
|
<div className="p-4 border-b border-border">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<Shield className="size-4 text-accent-brand" />
|
|
|
|
|
<h3 className="text-xs font-bold uppercase tracking-widest">
|
|
|
|
|
{t("terminal.warpgateAuthRequired")}
|
|
|
|
|
</h3>
|
|
|
|
|
</div>
|
2026-01-24 19:49:42 -06:00
|
|
|
</div>
|
2026-05-28 22:29:20 -05:00
|
|
|
<div className="p-4 flex flex-col gap-4">
|
|
|
|
|
<div className="flex flex-col gap-1.5">
|
|
|
|
|
<p className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
|
2026-01-24 19:49:42 -06:00
|
|
|
{t("terminal.warpgateSecurityKey")}
|
2026-05-28 22:29:20 -05:00
|
|
|
</p>
|
|
|
|
|
<div className="border border-border bg-muted/10 p-4 text-center">
|
|
|
|
|
<div className="text-2xl font-mono font-bold tracking-wider text-accent-brand">
|
2026-01-24 19:49:42 -06:00
|
|
|
{securityKey}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-05-28 22:29:20 -05:00
|
|
|
<div className="flex flex-col gap-1.5">
|
|
|
|
|
<p className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
|
2026-01-24 19:49:42 -06:00
|
|
|
{t("terminal.warpgateAuthUrl")}
|
2026-05-28 22:29:20 -05:00
|
|
|
</p>
|
|
|
|
|
<div className="flex gap-2">
|
2026-01-24 19:49:42 -06:00
|
|
|
<Input
|
|
|
|
|
type="text"
|
|
|
|
|
value={url}
|
|
|
|
|
readOnly
|
2026-05-28 22:29:20 -05:00
|
|
|
className="rounded-none bg-muted/50 border-border text-xs font-mono flex-1"
|
2026-01-24 19:49:42 -06:00
|
|
|
/>
|
|
|
|
|
<Button
|
|
|
|
|
type="button"
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="icon"
|
|
|
|
|
onClick={handleCopyUrl}
|
2026-05-28 22:29:20 -05:00
|
|
|
className="rounded-none border-border shrink-0"
|
2026-01-24 19:49:42 -06:00
|
|
|
title={t("common.copy")}
|
|
|
|
|
>
|
2026-05-28 22:29:20 -05:00
|
|
|
{copied ? (
|
|
|
|
|
<Check className="size-4 text-accent-brand" />
|
|
|
|
|
) : (
|
|
|
|
|
<Copy className="size-4" />
|
|
|
|
|
)}
|
2026-01-24 19:49:42 -06:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-05-28 22:29:20 -05:00
|
|
|
<div className="flex flex-wrap justify-end gap-2 pt-1">
|
2026-01-24 19:49:42 -06:00
|
|
|
<Button
|
|
|
|
|
type="button"
|
2026-05-28 22:29:20 -05:00
|
|
|
variant="ghost"
|
|
|
|
|
onClick={onCancel}
|
|
|
|
|
className="rounded-none text-[10px] font-bold uppercase tracking-widest sm:mr-auto"
|
2026-01-24 19:49:42 -06:00
|
|
|
>
|
2026-05-28 22:29:20 -05:00
|
|
|
{t("common.cancel")}
|
2026-01-24 19:49:42 -06:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
type="button"
|
2026-05-28 22:29:20 -05:00
|
|
|
variant="outline"
|
2026-01-24 19:49:42 -06:00
|
|
|
onClick={onContinue}
|
2026-05-28 22:29:20 -05:00
|
|
|
className="rounded-none text-[10px] font-bold uppercase tracking-widest"
|
2026-01-24 19:49:42 -06:00
|
|
|
>
|
|
|
|
|
{t("terminal.warpgateContinue")}
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
type="button"
|
|
|
|
|
variant="outline"
|
2026-05-28 22:29:20 -05:00
|
|
|
onClick={onOpenUrl}
|
|
|
|
|
className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 rounded-none text-[10px] font-bold uppercase tracking-widest flex items-center gap-1.5"
|
2026-01-24 19:49:42 -06:00
|
|
|
>
|
2026-05-28 22:29:20 -05:00
|
|
|
<ExternalLink className="size-3.5" />
|
|
|
|
|
{t("terminal.warpgateOpenBrowser")}
|
2026-01-24 19:49:42 -06:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|