Skip to content

Commit 0952d46

Browse files
authored
Fix so can change prod branch (supabase#37937)
* fix so can change prod branch * update to remove useEffect
1 parent 41bfd35 commit 0952d46

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,15 @@ const GitHubIntegrationConnectionForm = ({
8989
enabled: Boolean(gitHubAuthorization),
9090
})
9191

92-
const { mutate: updateBranch } = useBranchUpdateMutation()
92+
const { mutate: updateBranch } = useBranchUpdateMutation({
93+
onSuccess: () => {
94+
toast.success('Production branch settings successfully updated')
95+
},
96+
})
9397
const { mutate: createBranch } = useBranchCreateMutation({
98+
onSuccess: () => {
99+
toast.success('Production branch settings successfully updated')
100+
},
94101
onError: (error) => {
95102
console.error('Failed to enable branching:', error)
96103
},
@@ -105,7 +112,11 @@ const GitHubIntegrationConnectionForm = ({
105112
useCheckGithubBranchValidity({ onError: () => {} })
106113

107114
const { mutate: createConnection, isLoading: isCreatingConnection } =
108-
useGitHubConnectionCreateMutation()
115+
useGitHubConnectionCreateMutation({
116+
onSuccess: () => {
117+
toast.success('GitHub integration successfully updated')
118+
},
119+
})
109120

110121
const { mutateAsync: deleteConnection, isLoading: isDeletingConnection } =
111122
useGitHubConnectionDeleteMutation({
@@ -245,7 +256,6 @@ const GitHubIntegrationConnectionForm = ({
245256
gitBranch: data.branchName,
246257
})
247258
}
248-
toast.success('GitHub integration successfully updated')
249259
}
250260

251261
const handleUpdateConnection = async (
@@ -289,7 +299,6 @@ const GitHubIntegrationConnectionForm = ({
289299
})
290300
}
291301

292-
toast.success('GitHub integration successfully updated')
293302
setIsConfirmingBranchChange(false)
294303
}
295304

@@ -344,15 +353,6 @@ const GitHubIntegrationConnectionForm = ({
344353
}
345354
}
346355

347-
useEffect(() => {
348-
if (selectedRepository) {
349-
githubSettingsForm.setValue(
350-
'branchName',
351-
githubRepos.find((repo) => repo.id === selectedRepository.id)?.default_branch || 'main'
352-
)
353-
}
354-
}, [selectedRepository])
355-
356356
useEffect(() => {
357357
if (connection) {
358358
const hasGitBranch = Boolean(prodBranch?.git_branch?.trim())
@@ -463,6 +463,10 @@ const GitHubIntegrationConnectionForm = ({
463463
onSelect={() => {
464464
field.onChange(repo.id)
465465
setRepoComboboxOpen(false)
466+
githubSettingsForm.setValue(
467+
'branchName',
468+
repo.default_branch || 'main'
469+
)
466470
}}
467471
>
468472
<div className="bg-black shadow rounded p-1 w-5 h-5 flex justify-center items-center">

0 commit comments

Comments
 (0)