Skip to content

Commit 2a0d589

Browse files
committed
refactor(frontend): reset state and emit empty model on repo change
1 parent 326cdb5 commit 2a0d589

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

services/frontend/src/components/deploy/steps/SelectRepositoryStep.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,42 @@ function handleRepoChange(repoId: any) {
137137
const repo = repositories.value.find(r => r.id.toString() === repoIdStr)
138138
if (!repo) return
139139
140+
// Reset state when switching repositories
141+
selectedRepo.value = null
142+
branch.value = ''
143+
branches.value = []
144+
branchesError.value = null
145+
146+
// Emit empty state to parent to disable Next button
147+
emit('update:modelValue', {
148+
url: '',
149+
name: '',
150+
branch: ''
151+
})
152+
153+
// Now set the new repository
140154
selectedRepo.value = repo
141155
selectedRepoId.value = repoIdStr
142-
branch.value = repo.default_branch
143156
144157
// Fetch branches for the selected repository
145158
fetchBranches(repo)
146159
}
147160
148161
// Watch for changes and emit to parent
149162
watch([selectedRepo, branch], () => {
150-
if (selectedRepo.value) {
163+
if (selectedRepo.value && branch.value) {
151164
emit('update:modelValue', {
152165
url: selectedRepo.value.clone_url,
153166
name: selectedRepo.value.full_name,
154167
branch: branch.value
155168
})
169+
} else {
170+
// If repo or branch is missing, emit empty state
171+
emit('update:modelValue', {
172+
url: '',
173+
name: '',
174+
branch: ''
175+
})
156176
}
157177
})
158178

0 commit comments

Comments
 (0)