diff --git a/src/components/config/GiteaConfigForm.tsx b/src/components/config/GiteaConfigForm.tsx index 65423e3..bff913d 100644 --- a/src/components/config/GiteaConfigForm.tsx +++ b/src/components/config/GiteaConfigForm.tsx @@ -10,6 +10,7 @@ import { giteaApi } from "@/lib/api"; import type { GiteaConfig, MirrorStrategy } from "@/types/config"; import { toast } from "sonner"; import { OrganizationStrategy } from "./OrganizationStrategy"; +import { OrganizationConfiguration } from "./OrganizationConfiguration"; import { Separator } from "../ui/separator"; interface GiteaConfigFormProps { @@ -205,8 +206,18 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g strategy={mirrorStrategy} destinationOrg={config.organization} starredReposOrg={config.starredReposOrg} - visibility={config.visibility} onStrategyChange={setMirrorStrategy} + githubUsername={githubUsername} + giteaUsername={config.username} + /> + + + + { const newConfig = { ...config, organization: org }; setConfig(newConfig); @@ -222,8 +233,6 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g setConfig(newConfig); if (onAutoSave) onAutoSave(newConfig); }} - githubUsername={githubUsername} - giteaUsername={config.username} /> diff --git a/src/components/config/OrganizationConfiguration.tsx b/src/components/config/OrganizationConfiguration.tsx new file mode 100644 index 0000000..2e3ecc5 --- /dev/null +++ b/src/components/config/OrganizationConfiguration.tsx @@ -0,0 +1,222 @@ +import React from "react"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Building2, Star, Globe, Lock, Shield, Info } from "lucide-react"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; +import { cn } from "@/lib/utils"; +import type { MirrorStrategy, GiteaOrgVisibility } from "@/types/config"; + +interface OrganizationConfigurationProps { + strategy: MirrorStrategy; + destinationOrg?: string; + starredReposOrg?: string; + visibility: GiteaOrgVisibility; + onDestinationOrgChange: (org: string) => void; + onStarredReposOrgChange: (org: string) => void; + onVisibilityChange: (visibility: GiteaOrgVisibility) => void; +} + +const visibilityOptions = [ + { value: "public" as GiteaOrgVisibility, label: "Public", icon: Globe, description: "Visible to everyone" }, + { value: "private" as GiteaOrgVisibility, label: "Private", icon: Lock, description: "Visible to members only" }, + { value: "limited" as GiteaOrgVisibility, label: "Limited", icon: Shield, description: "Visible to logged-in users" }, +]; + +export const OrganizationConfiguration: React.FC = ({ + strategy, + destinationOrg, + starredReposOrg, + visibility, + onDestinationOrgChange, + onStarredReposOrgChange, + onVisibilityChange, +}) => { + return ( +
+
+

+ + Organization Configuration +

+
+ +
+ {strategy === "single-org" ? ( + <> + {/* Destination Organization - Left Column */} +
+ + onDestinationOrgChange(e.target.value)} + placeholder="github-mirrors" + className="" + /> +

+ Organization for consolidated repositories +

+
+ + {/* Starred Repositories Organization - Right Column */} +
+ + onStarredReposOrgChange(e.target.value)} + placeholder="starred" + className="" + /> +

+ Keep starred repos organized separately +

+
+ + ) : ( + <> + {/* Starred Repositories Organization - Left Column */} +
+ + onStarredReposOrgChange(e.target.value)} + placeholder="starred" + className="" + /> +

+ Keep starred repos organized separately +

+
+ + {/* Organization Visibility - Right Column */} +
+ +
+ {visibilityOptions.map((option) => { + const Icon = option.icon; + const isSelected = visibility === option.value; + return ( + + ); + })} +
+
+ + )} +
+ + {/* Organization Visibility - Full width when single-org is selected */} + {strategy === "single-org" && ( +
+ +
+ {visibilityOptions.map((option) => { + const Icon = option.icon; + const isSelected = visibility === option.value; + return ( + + ); + })} +
+
+ )} +
+ ); +}; \ No newline at end of file diff --git a/src/components/config/OrganizationStrategy.tsx b/src/components/config/OrganizationStrategy.tsx index 6215f9a..5ffe982 100644 --- a/src/components/config/OrganizationStrategy.tsx +++ b/src/components/config/OrganizationStrategy.tsx @@ -1,10 +1,7 @@ import React 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 { Info, GitBranch, FolderTree, Star, Building2, User, Globe, Lock, Shield } from "lucide-react"; -import { Separator } from "@/components/ui/separator"; +import { Info, GitBranch, FolderTree, Star, Building2, User } from "lucide-react"; import { Tooltip, TooltipContent, @@ -17,7 +14,6 @@ import { PopoverTrigger, } from "@/components/ui/popover"; import { cn } from "@/lib/utils"; -import type { GiteaOrgVisibility } from "@/types/config"; export type MirrorStrategy = "preserve" | "single-org" | "flat-user"; @@ -25,11 +21,7 @@ interface OrganizationStrategyProps { strategy: MirrorStrategy; destinationOrg?: string; starredReposOrg?: string; - visibility: GiteaOrgVisibility; onStrategyChange: (strategy: MirrorStrategy) => void; - onDestinationOrgChange: (org: string) => void; - onStarredReposOrgChange: (org: string) => void; - onVisibilityChange: (visibility: GiteaOrgVisibility) => void; githubUsername?: string; giteaUsername?: string; } @@ -231,20 +223,10 @@ export const OrganizationStrategy: React.FC = ({ strategy, destinationOrg, starredReposOrg, - visibility, onStrategyChange, - onDestinationOrgChange, - onStarredReposOrgChange, - onVisibilityChange, githubUsername, giteaUsername, }) => { - const visibilityOptions = [ - { value: "public" as GiteaOrgVisibility, label: "Public", icon: Globe, description: "Visible to everyone" }, - { value: "private" as GiteaOrgVisibility, label: "Private", icon: Lock, description: "Visible to members only" }, - { value: "limited" as GiteaOrgVisibility, label: "Limited", icon: Shield, description: "Visible to logged-in users" }, - ]; - return (
@@ -329,190 +311,6 @@ export const OrganizationStrategy: React.FC = ({ })}
- - - -
-
-

- - Organization Configuration -

-
- -
- {strategy === "single-org" ? ( - <> - {/* Destination Organization - Left Column */} -
- - onDestinationOrgChange(e.target.value)} - placeholder="github-mirrors" - className="" - /> -

- Organization for consolidated repositories -

-
- - {/* Starred Repositories Organization - Right Column */} -
- - onStarredReposOrgChange(e.target.value)} - placeholder="starred" - className="" - /> -

- Keep starred repos organized separately -

-
- - ) : ( - <> - {/* Starred Repositories Organization - Left Column */} -
- - onStarredReposOrgChange(e.target.value)} - placeholder="starred" - className="" - /> -

- Keep starred repos organized separately -

-
- - {/* Organization Visibility - Right Column */} -
- -
- {visibilityOptions.map((option) => { - const Icon = option.icon; - const isSelected = visibility === option.value; - return ( - - ); - })} -
-
- - )} -
- - {/* Organization Visibility - Full width when single-org is selected */} - {strategy === "single-org" && ( -
- -
- {visibilityOptions.map((option) => { - const Icon = option.icon; - const isSelected = visibility === option.value; - return ( - - ); - })} -
-
- )} -
); }; \ No newline at end of file