import React, { useState } from "react"; import { Card } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Badge } from "@/components/ui/badge"; import { Info, GitBranch, FolderTree, Package, Star, Building2, User, ChevronDown, ChevronUp } from "lucide-react"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; export type MirrorStrategy = "preserve" | "single-org" | "flat-user"; interface OrganizationStrategyProps { strategy: MirrorStrategy; destinationOrg?: string; starredReposOrg?: string; onStrategyChange: (strategy: MirrorStrategy) => void; onDestinationOrgChange: (org: string) => void; onStarredReposOrgChange: (org: string) => void; githubUsername?: string; giteaUsername?: string; } const strategyConfig = { preserve: { title: "Mirror GitHub Structure", icon: FolderTree, description: "Keep the same organization structure as GitHub", color: "text-blue-600 dark:text-blue-400", bgColor: "bg-blue-50 dark:bg-blue-950/20", borderColor: "border-blue-200 dark:border-blue-900", details: [ "Personal repos → Your Gitea username", "Org repos → Same org name in Gitea", "Team structure preserved" ] }, "single-org": { title: "Consolidate to One Org", icon: Building2, description: "Mirror all repositories into a single organization", color: "text-purple-600 dark:text-purple-400", bgColor: "bg-purple-50 dark:bg-purple-950/20", borderColor: "border-purple-200 dark:border-purple-900", details: [ "All repos in one place", "Simplified management", "Custom organization name" ] }, "flat-user": { title: "Flat User Structure", icon: User, description: "Mirror all repositories under your user account", color: "text-green-600 dark:text-green-400", bgColor: "bg-green-50 dark:bg-green-950/20", borderColor: "border-green-200 dark:border-green-900", details: [ "All repos under your username", "No organizations needed", "Simple and personal" ] } }; const StrategyVisualizer: React.FC<{ strategy: MirrorStrategy; destinationOrg?: string; starredReposOrg?: string; githubUsername?: string; giteaUsername?: string; }> = ({ strategy, destinationOrg, starredReposOrg, githubUsername, giteaUsername }) => { const [isOpen, setIsOpen] = useState(false); const displayGithubUsername = githubUsername || ""; const displayGiteaUsername = giteaUsername || ""; const isGithubPlaceholder = !githubUsername; const isGiteaPlaceholder = !giteaUsername; const renderPreserveStructure = () => (
GitHub
{displayGithubUsername}/my-repo
my-org/team-repo
awesome/starred-repo
Gitea
{displayGiteaUsername}/my-repo
my-org/team-repo
{starredReposOrg || "starred"}/starred-repo
); const renderSingleOrg = () => (
GitHub
{displayGithubUsername}/my-repo
my-org/team-repo
awesome/starred-repo
Gitea
{destinationOrg || "github-mirrors"}/my-repo
{destinationOrg || "github-mirrors"}/team-repo
{starredReposOrg || "starred"}/starred-repo
); const renderFlatUser = () => (
GitHub
{displayGithubUsername}/my-repo
my-org/team-repo
awesome/starred-repo
Gitea
{displayGiteaUsername}/my-repo
{displayGiteaUsername}/team-repo
{starredReposOrg || "starred"}/starred-repo
); return (

Repository Mapping Preview {isOpen ? ( ) : ( )}

{strategy === "preserve" && renderPreserveStructure()} {strategy === "single-org" && renderSingleOrg()} {strategy === "flat-user" && renderFlatUser()}
); }; export const OrganizationStrategy: React.FC = ({ strategy, destinationOrg, starredReposOrg, onStrategyChange, onDestinationOrgChange, onStarredReposOrgChange, githubUsername, giteaUsername, }) => { return (

Organization Strategy

Choose how your repositories will be organized in Gitea

{(Object.entries(strategyConfig) as [MirrorStrategy, typeof strategyConfig.preserve][]).map(([key, config]) => { const isSelected = strategy === key; const Icon = config.icon; return (
{strategy === "single-org" && (
onDestinationOrgChange(e.target.value)} placeholder="github-mirrors" className="mt-1.5" />
)}
onStarredReposOrgChange(e.target.value)} placeholder="starred" className="mt-1.5" />

Keep starred repos organized separately from your own repositories

); };