mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 05:09:12 +03:00
* Swap analytics buckets endpoint * Fix type issues * fix * Update API types * Fix tests * nit * Final fixes * Fix * chore(studio): analytics buckets contents (#39701) * first commit * improvements * misc * cleanup * remove tappable whole * design updates * analytics improvements * polish * add clashed case * fix pairing status * connect tables basics * add multiselect * restore prod version for non-feature preview users * fix padding inconsistency * terminology fix * better empty state * fix terminology * block table connection dialog button * Nit refactors * minor nits * Add comment --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * Default circumstance to fresh in ImportForeignSchemaDialog * Hook up connecting tables for analytics buckets (#39906) * Hook up connecting tables for analytics buckets * Address comments * Clean up iceberg wrapper when deleting analytics bucket (#39902) * Clean up iceberg wrapper when deleting analytics bucket * Clean up s3 access key when deleting analytics bucket * Make connect table disabled for now * Most clean up and refactoring * Refactor RQ * Nit * Refactor * nit --------- Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
|
|
import { toast } from 'sonner'
|
|
|
|
import { del, handleError } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { replicationKeys } from './keys'
|
|
|
|
export type DeletePublicationParams = {
|
|
projectRef: string
|
|
sourceId: number
|
|
publicationName: string
|
|
}
|
|
|
|
async function deletePublication(
|
|
{ projectRef, sourceId, publicationName }: DeletePublicationParams,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!projectRef) throw new Error('projectRef is required')
|
|
|
|
const { data, error } = await del(
|
|
'/platform/replication/{ref}/sources/{source_id}/publications/{publication_name}',
|
|
{
|
|
params: {
|
|
path: {
|
|
ref: projectRef,
|
|
source_id: sourceId,
|
|
publication_name: publicationName,
|
|
},
|
|
},
|
|
signal,
|
|
}
|
|
)
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
type DeletePublicationData = Awaited<ReturnType<typeof deletePublication>>
|
|
|
|
export const useDeletePublicationMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseMutationOptions<DeletePublicationData, ResponseError, DeletePublicationParams>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation<DeletePublicationData, ResponseError, DeletePublicationParams>({
|
|
mutationFn: (vars) => deletePublication(vars),
|
|
async onSuccess(data, variables, context) {
|
|
const { projectRef, sourceId } = variables
|
|
await queryClient.invalidateQueries(replicationKeys.publications(projectRef, sourceId))
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to delete publication: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
})
|
|
}
|