mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 02:15:05 +03:00
Merge complete loop (#37018)
* prevent merge complete loop * dependency
This commit is contained in:
1 parent
6504a8460f
commit
53cd3e44a7
1 file changed
+45
-26
@@ -103,39 +103,67 @@ const MergePage: NextPageWithLayout = () => {
|
||||
currentBranchCreatedAt: currentBranch?.created_at,
|
||||
})
|
||||
|
||||
const { mutate: updateBranch } = useBranchUpdateMutation({
|
||||
onSuccess: () => {
|
||||
toast.success('Branch updated successfully')
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(`Failed to update branch: ${error.message}`)
|
||||
},
|
||||
})
|
||||
|
||||
const clearDiffsOptimistically = edgeFunctionsDiff.clearDiffsOptimistically
|
||||
|
||||
const currentWorkflowRunId = router.query.workflow_run_id as string | undefined
|
||||
|
||||
useEffect(() => {
|
||||
setWorkflowFinalStatus(null)
|
||||
}, [currentWorkflowRunId])
|
||||
|
||||
const handleCurrentBranchWorkflowComplete = useCallback(
|
||||
(status: string) => {
|
||||
setWorkflowFinalStatus(status)
|
||||
refetchDiff()
|
||||
clearDiffsOptimistically()
|
||||
},
|
||||
[refetchDiff, clearDiffsOptimistically]
|
||||
)
|
||||
|
||||
const handleParentBranchWorkflowComplete = useCallback(
|
||||
(status: string) => {
|
||||
setWorkflowFinalStatus(status)
|
||||
refetchDiff()
|
||||
clearDiffsOptimistically()
|
||||
if (parentProjectRef && currentBranch?.id && currentBranch.review_requested_at) {
|
||||
updateBranch({
|
||||
id: currentBranch.id,
|
||||
projectRef: parentProjectRef,
|
||||
requestReview: false,
|
||||
})
|
||||
}
|
||||
},
|
||||
[
|
||||
refetchDiff,
|
||||
clearDiffsOptimistically,
|
||||
parentProjectRef,
|
||||
currentBranch?.id,
|
||||
updateBranch,
|
||||
currentBranch?.review_requested_at,
|
||||
]
|
||||
)
|
||||
|
||||
const { currentWorkflowRun: currentBranchWorkflow, workflowRunLogs: currentBranchLogs } =
|
||||
useWorkflowManagement({
|
||||
workflowRunId: currentWorkflowRunId,
|
||||
projectRef: ref,
|
||||
onWorkflowComplete: (status) => {
|
||||
setWorkflowFinalStatus(status)
|
||||
refetchDiff()
|
||||
edgeFunctionsDiff.clearDiffsOptimistically()
|
||||
},
|
||||
onWorkflowComplete: handleCurrentBranchWorkflowComplete,
|
||||
})
|
||||
|
||||
const { currentWorkflowRun: parentBranchWorkflow, workflowRunLogs: parentBranchLogs } =
|
||||
useWorkflowManagement({
|
||||
workflowRunId: currentWorkflowRunId,
|
||||
projectRef: parentProjectRef,
|
||||
onWorkflowComplete: (status) => {
|
||||
setWorkflowFinalStatus(status)
|
||||
refetchDiff()
|
||||
edgeFunctionsDiff.clearDiffsOptimistically()
|
||||
if (parentProjectRef && currentBranch?.id) {
|
||||
updateBranch({
|
||||
id: currentBranch.id,
|
||||
projectRef: parentProjectRef,
|
||||
requestReview: false,
|
||||
})
|
||||
}
|
||||
},
|
||||
onWorkflowComplete: handleParentBranchWorkflowComplete,
|
||||
})
|
||||
|
||||
const currentWorkflowRun = currentBranchWorkflow || parentBranchWorkflow
|
||||
@@ -210,15 +238,6 @@ const MergePage: NextPageWithLayout = () => {
|
||||
},
|
||||
})
|
||||
|
||||
const { mutate: updateBranch } = useBranchUpdateMutation({
|
||||
onSuccess: () => {
|
||||
toast.success('Branch updated successfully')
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(`Failed to update branch: ${error.message}`)
|
||||
},
|
||||
})
|
||||
|
||||
const handlePush = () => {
|
||||
if (!currentBranch?.id || !parentProjectRef) return
|
||||
pushBranch({
|
||||
|
||||
Reference in new issue
Block a user