mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
## Context Related to marketplace related work, just moves the Queues integration to the new UI (Changes are feature flagged) <img width="1145" height="584" alt="image" src="https://github.com/user-attachments/assets/d3245889-597d-44e2-9850-f20907e42056" /> Installation is now in a side panel with the intention that it'll just be a single click to install integrations that involve multiple parts <img width="400" height="955" alt="image" src="https://github.com/user-attachments/assets/71903b61-6bd2-486c-903e-b48ae2133887" /> ## To test - Verify that you can install the integration and everything else should be status quo - Verify that everything should be status quo if the flag is off
79 lines
2.2 KiB
TypeScript
79 lines
2.2 KiB
TypeScript
import { getEnableDatabaseExtensionSQL } from '@supabase/pg-meta'
|
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
import { configKeys } from 'data/config/keys'
|
|
import { executeSql } from 'data/sql/execute-sql-query'
|
|
import { toast } from 'sonner'
|
|
import type { ResponseError, UseCustomMutationOptions } from 'types'
|
|
|
|
import { databaseExtensionsKeys } from './keys'
|
|
|
|
export type DatabaseExtensionEnableVariables = {
|
|
projectRef: string
|
|
connectionString?: string | null
|
|
schema: string
|
|
name: string
|
|
version: string
|
|
cascade?: boolean
|
|
createSchema?: boolean
|
|
}
|
|
|
|
export async function enableDatabaseExtension({
|
|
projectRef,
|
|
connectionString,
|
|
schema,
|
|
name,
|
|
version,
|
|
cascade = false,
|
|
createSchema = false,
|
|
}: DatabaseExtensionEnableVariables) {
|
|
let headers = new Headers()
|
|
if (connectionString) headers.set('x-connection-encrypted', connectionString)
|
|
|
|
const sql = getEnableDatabaseExtensionSQL({ schema, name, version, cascade, createSchema })
|
|
const { result } = await executeSql({
|
|
projectRef,
|
|
connectionString,
|
|
sql,
|
|
queryKey: ['extension', 'create'],
|
|
})
|
|
|
|
return result
|
|
}
|
|
|
|
type DatabaseExtensionEnableData = Awaited<ReturnType<typeof enableDatabaseExtension>>
|
|
|
|
export const useDatabaseExtensionEnableMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseCustomMutationOptions<
|
|
DatabaseExtensionEnableData,
|
|
ResponseError,
|
|
DatabaseExtensionEnableVariables
|
|
>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation<DatabaseExtensionEnableData, ResponseError, DatabaseExtensionEnableVariables>({
|
|
mutationFn: (vars) => enableDatabaseExtension(vars),
|
|
async onSuccess(data, variables, context) {
|
|
const { projectRef } = variables
|
|
await Promise.all([
|
|
queryClient.invalidateQueries({ queryKey: databaseExtensionsKeys.list(projectRef) }),
|
|
queryClient.invalidateQueries({ queryKey: configKeys.upgradeEligibility(projectRef) }),
|
|
])
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to enable database extension: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
})
|
|
}
|