import React from "react"; import { Card } from "@/components/ui/card"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Info, GitBranch, FolderTree, Star, Building2, User, Building } from "lucide-react"; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/components/ui/hover-card"; import { cn } from "@/lib/utils"; export type MirrorStrategy = "preserve" | "single-org" | "flat-user"; interface OrganizationStrategyProps { strategy: MirrorStrategy; destinationOrg?: string; starredReposOrg?: string; onStrategyChange: (strategy: MirrorStrategy) => void; githubUsername?: string; giteaUsername?: string; } const strategyConfig = { preserve: { title: "Preserve Structure", icon: FolderTree, description: "Keep the exact 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", repoColors: { bg: "bg-blue-50 dark:bg-blue-950/30", icon: "text-blue-600 dark:text-blue-400" } }, "single-org": { title: "Single Organization", icon: Building2, description: "Consolidate all repositories into one Gitea 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", repoColors: { bg: "bg-purple-50 dark:bg-purple-950/30", icon: "text-purple-600 dark:text-purple-400" } }, "flat-user": { title: "User Repositories", icon: User, description: "Place all repositories directly 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", repoColors: { bg: "bg-green-50 dark:bg-green-950/30", icon: "text-green-600 dark:text-green-400" } } }; const MappingPreview: React.FC<{ strategy: MirrorStrategy; config: typeof strategyConfig.preserve; destinationOrg?: string; starredReposOrg?: string; githubUsername?: string; giteaUsername?: string; }> = ({ strategy, config, destinationOrg, starredReposOrg, githubUsername, giteaUsername }) => { const displayGithubUsername = githubUsername || ""; const displayGiteaUsername = giteaUsername || ""; const isGithubPlaceholder = !githubUsername; const isGiteaPlaceholder = !giteaUsername; if (strategy === "preserve") { return (
GitHub
{displayGithubUsername}/my-repo
my-org/team-repo
awesome/starred-repo
Gitea
{displayGiteaUsername}/my-repo
my-org/team-repo
{starredReposOrg || "starred"}/starred-repo
); } if (strategy === "single-org") { return (
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
); } if (strategy === "flat-user") { return (
GitHub
{displayGithubUsername}/my-repo
my-org/team-repo
awesome/starred-repo
Gitea
{displayGiteaUsername}/my-repo
{displayGiteaUsername}/team-repo
{starredReposOrg || "starred"}/starred-repo
); } return null; }; export const OrganizationStrategy: React.FC = ({ strategy, destinationOrg, starredReposOrg, onStrategyChange, 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 (
); })}
); };