feat: support secondary promotion repos in git sync settings (#7173)

This commit is contained in:
Alexander Petric
2025-11-18 18:02:04 -05:00
committed by GitHub
parent 0701c4cc5e
commit cff3df6c6f
3 changed files with 76 additions and 36 deletions

View File

@@ -595,7 +595,7 @@ export function createGitSyncContext(workspace: string) {
return result
}
function getLegacyPromotionRepositories(): { repo: GitSyncRepository, idx: number }[] {
function getSecondaryPromotionRepositories(): { repo: GitSyncRepository, idx: number }[] {
const result: { repo: GitSyncRepository, idx: number }[] = []
let foundFirst = false
repositories.forEach((repo, idx) => {
@@ -736,7 +736,7 @@ export function createGitSyncContext(workspace: string) {
getPrimarySyncRepository,
getPrimaryPromotionRepository,
getSecondarySyncRepositories,
getLegacyPromotionRepositories,
getSecondaryPromotionRepositories,
// Helper methods
getTargetBranch,

View File

@@ -94,10 +94,19 @@
: isLegacy
? 'Legacy promotion repository'
: isSecondary
? 'Secondary sync repository'
? repo?.use_individual_branch
? 'Secondary promotion repository'
: 'Secondary sync repository'
: `Repository #${(idx ?? 0) + 1}`
)
// Determine the actual mode based on repository configuration
const repoMode = $derived<'sync' | 'promotion'>(
variant === 'primary-promotion' || variant === 'legacy' || repo?.use_individual_branch
? 'promotion'
: 'sync'
)
// Determine display description based on variant and mode
const displayDescription = $derived(
variant === 'primary-sync' || variant === 'primary-promotion'
@@ -353,7 +362,7 @@
{#if repo.isUnsavedConnection && !emptyString(repo.git_repo_resource_path) && idx !== null}
<DetectionFlow
{idx}
mode={variant === 'primary-promotion' || variant === 'legacy' ? 'promotion' : 'sync'}
mode={repoMode}
/>
{:else}
<GitSyncFilterSettings
@@ -380,9 +389,7 @@
<!-- Display mode settings as prominent text -->
<div class="flex-1 mr-4">
<GitSyncModeDisplay
mode={variant === 'primary-promotion' || variant === 'legacy'
? 'promotion'
: 'sync'}
mode={repoMode}
{targetBranch}
repository={repo}
/>

View File

@@ -30,14 +30,15 @@
const primarySync = $derived(gitSyncContext?.getPrimarySyncRepository() || null)
const primaryPromotion = $derived(gitSyncContext?.getPrimaryPromotionRepository() || null)
const secondarySync = $derived(gitSyncContext?.getSecondarySyncRepositories() || [])
const legacyPromotion = $derived(gitSyncContext?.getLegacyPromotionRepositories() || [])
const secondaryPromotion = $derived(gitSyncContext?.getSecondaryPromotionRepositories() || [])
// State for collapsible sections
let secondarySyncExpanded = $state(false)
let legacyPromotionExpanded = $state(false)
let secondaryPromotionExpanded = $state(false)
// Check if any secondary repositories are unsaved
const hasUnsavedSecondary = $derived(secondarySync.some((s) => s.repo.isUnsavedConnection))
const hasUnsavedSecondaryPromotion = $derived(secondaryPromotion.some((s) => s.repo.isUnsavedConnection))
</script>
{#if !gitSyncContext}
@@ -169,38 +170,70 @@
isCollapsible={false}
showEmptyState={primaryPromotion?.repo === null}
/>
</div>
<!-- Legacy promotion repositories (backwards compatibility) -->
{#if legacyPromotion.length > 0}
<Alert type="warning" title="Multiple promotion repositories detected">
Multiple promotion repositories are no longer supported. Please reduce to a single
promotion repository. Only deletion is allowed for the additional repositories below.
</Alert>
<div class="mt-4">
<button
class="flex items-center gap-2 text-sm text-secondary hover:text-primary transition-colors"
onclick={() => (legacyPromotionExpanded = !legacyPromotionExpanded)}
>
{#if legacyPromotionExpanded}
<ChevronDown size={16} />
{:else}
<ChevronRight size={16} />
{/if}
Legacy promotion repositories ({legacyPromotion.length})
</button>
<!-- Secondary Promotion Repositories -->
{#if primaryPromotion && !primaryPromotion.repo?.isUnsavedConnection}
{#if secondaryPromotion.length > 0 || secondaryPromotionExpanded}
<div class="mt-4">
<button
class="flex items-center gap-2 text-sm text-secondary hover:text-primary transition-colors"
onclick={() => (secondaryPromotionExpanded = !secondaryPromotionExpanded)}
>
{#if secondaryPromotionExpanded}
<ChevronDown size={16} />
{:else}
<ChevronRight size={16} />
{/if}
Secondary promotion repositories ({secondaryPromotion.length})
</button>
{#if legacyPromotionExpanded}
<div class="space-y-3 mt-3">
{#each legacyPromotion as { repo, idx } (repo.git_repo_resource_path)}
<div class="pl-4">
<GitSyncRepositoryCard {idx} variant="legacy" isLegacy={true} />
{#if secondaryPromotionExpanded}
<div class="mt-3 space-y-3">
{#if secondaryPromotion.length === 0}
<div class="text-sm text-secondary italic">
No secondary promotion repositories configured
</div>
{:else}
{#each secondaryPromotion as { repo, idx } (repo.git_repo_resource_path)}
<div class="pl-4">
<GitSyncRepositoryCard variant="secondary" {idx} isSecondary={true} />
</div>
{/each}
{/if}
{#if !hasUnsavedSecondaryPromotion}
<div class="pl-4">
<Button
size="xs"
variant="default"
startIcon={{ icon: Plus }}
onclick={() => gitSyncContext.addPromotionRepository()}
>
Add secondary promotion
</Button>
</div>
{/if}
</div>
{/each}
{/if}
</div>
{:else}
<!-- Collapsed state when no secondary promotion repos exist -->
{#if !hasUnsavedSecondaryPromotion}
<div class="mt-2">
<button
class="text-xs text-primary hover:text-secondary transition-colors"
onclick={() => {
secondaryPromotionExpanded = true
gitSyncContext.addPromotionRepository()
}}
>
+ Add secondary promotion repository
</button>
</div>
{/if}
{/if}
</div>
{/if}
{/if}
</div>
</div>
<!-- Modals -->