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" | "mixed"; 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" } }, "mixed": { title: "Mixed Mode", icon: GitBranch, description: "user repos in single org, org repos preserve structure", color: "text-orange-600 dark:text-orange-400", bgColor: "bg-orange-50 dark:bg-orange-950/20", borderColor: "border-orange-200 dark:border-orange-900", repoColors: { bg: "bg-orange-50 dark:bg-orange-950/30", icon: "text-orange-600 dark:text-orange-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
); } if (strategy === "mixed") { return (
GitHub
{displayGithubUsername}/my-repo
my-org/team-repo
awesome/starred-repo
Gitea
{destinationOrg || "github-mirrors"}/my-repo
my-org/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

Fine-tune Your Mirror Destinations

After selecting a strategy, you can customize destinations for specific organizations and repositories.

Organization Overrides

Click the edit button on any organization card to redirect all its repositories to a different Gitea organization.

Repository Overrides

Use the inline editor in the repository table's "Destination" column to set custom destinations for individual repositories.

Starred Repositories

Always go to the configured starred repos organization and cannot be overridden.

Priority: Repository override → Organization override → Strategy default

{(Object.entries(strategyConfig) as [MirrorStrategy, typeof strategyConfig.preserve][]).map(([key, config]) => { const isSelected = strategy === key; const Icon = config.icon; return (
); })}
); };