mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 21:59:16 +03:00
* remove enable branching modal * re-add github linker * abstract away enable and disable * toggle fixes * update logic to lean on connection status * update form logic * sheet layout * gitless flag * fix side panel size * copy changes * remove import * add cost * allow connection details on create * Fix TS issues * Fix TS issues * Couple of clean ups * Revert hardcode in useFlag * Fix TS * layout issues and github check * refactor * refactor to use new field * cleanup * style * clarification with github integration * replace branch dropdown button * update repo picker * remove modal * change defaults * disable if not gitless and no connection * fixes * prevent editing on child branch --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
|
|
import { toast } from 'sonner'
|
|
|
|
import { handleError, patch } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { EnvironmentTargets } from './integrations.types'
|
|
import { integrationKeys } from './keys'
|
|
|
|
type UpdateConnectionPayload = {
|
|
id: string
|
|
organizationIntegrationId: string
|
|
envSyncTargets: EnvironmentTargets[]
|
|
publicEnvVarPrefix?: string
|
|
}
|
|
|
|
export async function updateVercelConnection({
|
|
id,
|
|
envSyncTargets,
|
|
publicEnvVarPrefix,
|
|
}: UpdateConnectionPayload) {
|
|
const { data, error } = await patch('/platform/integrations/vercel/connections/{connection_id}', {
|
|
params: {
|
|
path: { connection_id: id },
|
|
},
|
|
body: {
|
|
// the array part of this type correctly
|
|
env_sync_targets: envSyncTargets,
|
|
public_env_var_prefix: publicEnvVarPrefix,
|
|
},
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
type UpdateVercelConnectionData = Awaited<ReturnType<typeof updateVercelConnection>>
|
|
|
|
export const useVercelConnectionUpdateMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseMutationOptions<UpdateVercelConnectionData, ResponseError, UpdateConnectionPayload>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
const queryClient = useQueryClient()
|
|
return useMutation<UpdateVercelConnectionData, ResponseError, UpdateConnectionPayload>(
|
|
(vars) => updateVercelConnection(vars),
|
|
{
|
|
async onSuccess(data, variables, context) {
|
|
await queryClient.invalidateQueries(
|
|
integrationKeys.vercelConnectionsList(variables.organizationIntegrationId)
|
|
)
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to update Vercel connection: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
}
|
|
)
|
|
}
|