import { useState } from "react"; import { ArrowRight, Edit3, RotateCcw, CheckCircle2, Building2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Badge } from "@/components/ui/badge"; import { toast } from "sonner"; import { cn } from "@/lib/utils"; interface MirrorDestinationEditorProps { organizationId: string; organizationName: string; currentDestination?: string; onUpdate: (newDestination: string | null) => Promise; isUpdating?: boolean; className?: string; } export function MirrorDestinationEditor({ organizationId, organizationName, currentDestination, onUpdate, isUpdating = false, className, }: MirrorDestinationEditorProps) { const [isOpen, setIsOpen] = useState(false); const [editValue, setEditValue] = useState(currentDestination || ""); const [isLoading, setIsLoading] = useState(false); const hasOverride = currentDestination && currentDestination !== organizationName; const effectiveDestination = currentDestination || organizationName; const handleSave = async () => { const trimmedValue = editValue.trim(); const newDestination = trimmedValue === "" || trimmedValue === organizationName ? null : trimmedValue; setIsLoading(true); try { await onUpdate(newDestination); setIsOpen(false); toast.success( newDestination ? `Destination updated to: ${newDestination}` : "Destination reset to default" ); } catch (error) { toast.error("Failed to update destination"); } finally { setIsLoading(false); } }; const handleReset = async () => { setEditValue(""); await handleSave(); }; const handleCancel = () => { setEditValue(currentDestination || ""); setIsOpen(false); }; return (
{organizationName} {effectiveDestination} {hasOverride && ( custom )}

Mirror Destination

Customize where this organization's repositories are mirrored to in Gitea.

{/* Visual Preview */}
Preview
{organizationName}
{editValue.trim() || organizationName}
{/* Input Field */}
setEditValue(e.target.value)} placeholder={organizationName} className="h-8" disabled={isLoading} />

Leave empty to use the default GitHub organization name

{/* Quick Actions */} {hasOverride && ( )}
{/* Action Buttons */}
); }