Updates to Org strategy

This commit is contained in:
Arunavo Ray
2025-07-18 09:52:55 +05:30
parent 3458891511
commit 9d5db86bdf
3 changed files with 10 additions and 32 deletions

View File

@@ -44,11 +44,13 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g
case "preserve": case "preserve":
newConfig.preserveOrgStructure = true; newConfig.preserveOrgStructure = true;
newConfig.mirrorStrategy = "preserve"; newConfig.mirrorStrategy = "preserve";
newConfig.personalReposOrg = undefined; // Clear personal repos org in preserve mode
break; break;
case "single-org": case "single-org":
newConfig.preserveOrgStructure = false; newConfig.preserveOrgStructure = false;
newConfig.mirrorStrategy = "single-org"; newConfig.mirrorStrategy = "single-org";
if (!newConfig.organization) { // Reset to default if coming from mixed mode where it was personal repos org
if (config.mirrorStrategy === "mixed" || !newConfig.organization || newConfig.organization === "github-personal") {
newConfig.organization = "github-mirrors"; newConfig.organization = "github-mirrors";
} }
break; break;
@@ -60,8 +62,10 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g
case "mixed": case "mixed":
newConfig.preserveOrgStructure = false; newConfig.preserveOrgStructure = false;
newConfig.mirrorStrategy = "mixed"; newConfig.mirrorStrategy = "mixed";
if (!newConfig.organization) { // In mixed mode, organization field represents personal repos org
newConfig.organization = "github-mirrors"; // Reset it to default if coming from single-org mode
if (config.mirrorStrategy === "single-org" || !newConfig.organization || newConfig.organization === "github-mirrors") {
newConfig.organization = "github-personal";
} }
if (!newConfig.personalReposOrg) { if (!newConfig.personalReposOrg) {
newConfig.personalReposOrg = "github-personal"; newConfig.personalReposOrg = "github-personal";

View File

@@ -104,7 +104,7 @@ export const OrganizationConfiguration: React.FC<OrganizationConfigurationProps>
id="destinationOrg" id="destinationOrg"
value={destinationOrg || ""} value={destinationOrg || ""}
onChange={(e) => onDestinationOrgChange(e.target.value)} onChange={(e) => onDestinationOrgChange(e.target.value)}
placeholder="github-mirrors" placeholder={strategy === "mixed" ? "github-personal" : "github-mirrors"}
className="" className=""
/> />
<p className="text-xs text-muted-foreground mt-1"> <p className="text-xs text-muted-foreground mt-1">
@@ -114,32 +114,6 @@ export const OrganizationConfiguration: React.FC<OrganizationConfigurationProps>
} }
</p> </p>
</div> </div>
) : strategy === "preserve" ? (
<div className="space-y-1">
<Label htmlFor="personalReposOrg" className="text-sm font-normal flex items-center gap-2">
Personal Repos Organization
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<Info className="h-3.5 w-3.5 text-muted-foreground" />
</TooltipTrigger>
<TooltipContent>
<p>Override where your personal repositories are mirrored (leave empty to use your username)</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</Label>
<Input
id="personalReposOrg"
value={personalReposOrg || ""}
onChange={(e) => onPersonalReposOrgChange(e.target.value)}
placeholder="my-personal-mirrors"
className=""
/>
<p className="text-xs text-muted-foreground mt-1">
Override destination for your personal repos
</p>
</div>
) : ( ) : (
<div className="hidden md:block" /> <div className="hidden md:block" />
)} )}

View File

@@ -48,8 +48,8 @@ export function InlineDestinationEditor({
if (repository.organization) { if (repository.organization) {
return repository.organization; return repository.organization;
} }
// For personal repos, check if personalReposOrg is configured // For personal repos, check if personalReposOrg is configured (but not in preserve mode)
if (!repository.organization && giteaConfig?.personalReposOrg) { if (!repository.organization && giteaConfig?.personalReposOrg && strategy !== 'preserve') {
return giteaConfig.personalReposOrg; return giteaConfig.personalReposOrg;
} }
// Default to the gitea username or owner // Default to the gitea username or owner