Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: Integrations followup - clean up extra files (#30653)

Ivan Vasilovbff3d56eef80
diff --git a/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx b/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx
deleted file mode 100644
index 9194d22335e..00000000000
--- a/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx
+++ /dev/null
@@ -1,339 +0,0 @@
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useQueryClient } from '@tanstack/react-query'
-import { isEmpty } from 'lodash'
-import { ArrowLeft, Edit, Trash } from 'lucide-react'
-import Link from 'next/link'
-import { useRouter } from 'next/router'
-import { useState } from 'react'
-import { toast } from 'sonner'
-
-import { useParams } from 'common'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { DocsButton } from 'components/ui/DocsButton'
-import { FormActions } from 'components/ui/Forms/FormActions'
-import { FormPanel } from 'components/ui/Forms/FormPanel'
-import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'
-import { FormsContainer } from 'components/ui/Forms/FormsContainer'
-import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
-import { invalidateSchemasQuery } from 'data/database/schemas-query'
-import { useFDWCreateMutation } from 'data/fdw/fdw-create-mutation'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import {
- AlertDescription_Shadcn_,
- AlertTitle_Shadcn_,
- Alert_Shadcn_,
- Button,
- Form,
- Input,
- WarningIcon,
- cn,
-} from 'ui'
-import InputField from './InputField'
-import WrapperTableEditor from './WrapperTableEditor'
-import { WRAPPERS } from './Wrappers.constants'
-import { makeValidateRequired } from './Wrappers.utils'
-
-const CreateWrapper = () => {
- const formId = 'create-wrapper-form'
- const router = useRouter()
- const queryClient = useQueryClient()
- const { ref, type } = useParams()
- const { project } = useProjectContext()
- const canCreateWrapper = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'wrappers')
-
- const [newTables, setNewTables] = useState<any[]>([])
- const [isEditingTable, setIsEditingTable] = useState(false)
- const [selectedTableToEdit, setSelectedTableToEdit] = useState()
- const [formErrors, setFormErrors] = useState<{ [k: string]: string }>({})
-
- const { mutate: createFDW, isLoading: isCreating } = useFDWCreateMutation({
- onSuccess: () => {
- toast.success(`Successfully created ${wrapperMeta?.label} foreign data wrapper`)
- setNewTables([])
-
- const hasNewSchema = newTables.some((table) => table.is_new_schema)
- if (hasNewSchema) invalidateSchemasQuery(queryClient, ref)
-
- router.push(`/project/${ref}/integrations/wrappers`)
- },
- })
-
- const wrapperMeta = WRAPPERS.find((wrapper) => wrapper.name === type)
- const initialValues =
- wrapperMeta !== undefined
- ? {
- wrapper_name: '',
- server_name: '',
- ...Object.fromEntries(
- wrapperMeta.server.options.map((option) => [option.name, option.defaultValue ?? ''])
- ),
- }
- : {}
-
- const { data } = useDatabaseExtensionsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const wrappersExtension = data?.find((ext) => ext.name === 'wrappers')
-
- const hasRequiredVersion =
- (wrappersExtension?.installed_version ?? '') >= (wrapperMeta?.minimumExtensionVersion ?? '')
-
- if (wrapperMeta === undefined) {
- return (
- <div className="flex flex-col items-center justify-center w-full h-full space-y-4">
- <div className="space-y-2 flex flex-col items-center w-[400px]">
- <p>Unsupported wrapper type</p>
- <p className="text-sm text-center text-foreground-light">
- The wrapper type {type} not supported by the dashboard. Head back to create a different
- wrapper.
- </p>
- </div>
- <Button asChild type="default">
- <Link href={`/project/${ref}/integrations/wrappers`}>Head back</Link>
- </Button>
- </div>
- )
- }
-
- const databaseNeedsUpgrading =
- wrappersExtension?.installed_version !== wrappersExtension?.default_version
-
- const onUpdateTable = (values: any) => {
- setNewTables((prev) => {
- // if the new values have tableIndex, we are editing an existing table
- if (values.tableIndex !== undefined) {
- const tableIndex = values.tableIndex
- const newTables = [...prev]
- delete values.tableIndex
- newTables[tableIndex] = values
- return newTables
- }
- return [...prev, values]
- })
- setIsEditingTable(false)
- setSelectedTableToEdit(undefined)
- }
-
- const onSubmit = async (values: any) => {
- const validate = makeValidateRequired(wrapperMeta.server.options)
- const errors: any = validate(values)
-
- const { wrapper_name } = values
- if (wrapper_name.length === 0) errors.name = 'Please provide a name for your wrapper'
- if (newTables.length === 0) errors.tables = 'Please add at least one table'
- if (!isEmpty(errors)) return setFormErrors(errors)
-
- createFDW({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- wrapperMeta,
- formState: { ...values, server_name: `${wrapper_name}_server` },
- tables: newTables,
- })
- }
-
- return (
- <FormsContainer className="[&>div]:space-y-0">
- <div className="relative flex items-center justify-between mb-6">
- <div
- className={cn(
- 'transition cursor-pointer',
- 'absolute -left-20 top-1 opacity-75 hover:opacity-100'
- )}
- >
- <Link href={`/project/${ref}/integrations/wrappers`}>
- <div className="flex items-center space-x-2">
- <ArrowLeft strokeWidth={1.5} size={14} />
- <p className="text-sm">Back</p>
- </div>
- </Link>
- </div>
- <h3 className="mb-2 text-xl text-foreground">Create a {wrapperMeta.label} Wrapper</h3>
- <DocsButton href={wrapperMeta.docsUrl} />
- </div>
-
- {hasRequiredVersion ? (
- <Form id={formId} initialValues={initialValues} onSubmit={onSubmit}>
- {({ handleReset, values, initialValues }: any) => {
- const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)
- return (
- <FormPanel
- disabled={!canCreateWrapper}
- footer={
- <div className="flex px-8 py-4">
- <FormActions
- form={formId}
- isSubmitting={isCreating}
- hasChanges={hasChanges}
- handleReset={handleReset}
- disabled={!canCreateWrapper}
- helper={
- !canCreateWrapper
- ? 'You need additional permissions to create a foreign data wrapper'
- : undefined
- }
- />
- </div>
- }
- >
- <FormSection header={<FormSectionLabel>Wrapper Configuration</FormSectionLabel>}>
- <FormSectionContent loading={false}>
- <Input
- id="wrapper_name"
- label="Wrapper Name"
- error={formErrors.wrapper_name}
- descriptionText={
- (values?.wrapper_name ?? '').length > 0 ? (
- <>
- Your wrapper's server name will be{' '}
- <code className="text-xs">{values.wrapper_name}_server</code>
- </>
- ) : (
- ''
- )
- }
- />
- </FormSectionContent>
- </FormSection>
- <FormSection
- header={<FormSectionLabel>{wrapperMeta.label} Configuration</FormSectionLabel>}
- >
- <FormSectionContent loading={false}>
- {wrapperMeta.server.options
- .filter((option) => !option.hidden)
- .map((option) => (
- <InputField
- key={option.name}
- option={option}
- loading={false}
- error={formErrors[option.name]}
- />
- ))}
- </FormSectionContent>
- </FormSection>
- <FormSection
- header={
- <FormSectionLabel>
- <p>Foreign Tables</p>
- <p className="text-foreground-light mt-2 w-[90%]">
- You can query your data from these foreign tables after the wrapper is
- created
- </p>
- </FormSectionLabel>
- }
- >
- <FormSectionContent loading={false}>
- {newTables.length === 0 ? (
- <div className="flex justify-end translate-y-4">
- <Button type="default" onClick={() => setIsEditingTable(true)}>
- Add foreign table
- </Button>
- </div>
- ) : (
- <div className="space-y-2">
- {newTables.map((table, i) => (
- <div
- key={`${table.schema_name}.${table.table_name}`}
- className="flex items-center justify-between px-4 py-2 border rounded-md border-control"
- >
- <div>
- <p className="text-sm">
- {table.schema_name}.{table.table_name}
- </p>
- <p className="text-sm text-foreground-light">
- Columns:{' '}
- {table.columns.map((column: any) => column.name).join(', ')}
- </p>
- </div>
- <div className="flex items-center space-x-2">
- <Button
- type="default"
- className="px-1"
- icon={<Edit />}
- onClick={() => {
- setIsEditingTable(true)
- setSelectedTableToEdit({ ...table, tableIndex: i })
- }}
- />
- <Button
- type="default"
- className="px-1"
- icon={<Trash />}
- onClick={() => {
- setNewTables((prev) => prev.filter((_, j) => j !== i))
- }}
- />
- </div>
- </div>
- ))}
- </div>
- )}
- {newTables.length > 0 && (
- <div className="flex justify-end">
- <Button type="default" onClick={() => setIsEditingTable(true)}>
- Add foreign table
- </Button>
- </div>
- )}
- {newTables.length === 0 && formErrors.tables && (
- <p className="text-sm text-right text-red-900">{formErrors.tables}</p>
- )}
- </FormSectionContent>
- </FormSection>
- </FormPanel>
- )
- }}
- </Form>
- ) : (
- <Alert_Shadcn_ variant="warning">
- <WarningIcon />
- <AlertTitle_Shadcn_>
- Your extension version is outdated for this wrapper.
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_ className="flex flex-col gap-y-2">
- <p>
- The {wrapperMeta.label} wrapper requires a minimum extension version of{' '}
- {wrapperMeta.minimumExtensionVersion}. You have version{' '}
- {wrappersExtension?.installed_version} installed. Please{' '}
- {databaseNeedsUpgrading && 'upgrade your database then '}update the extension by
- disabling and enabling the <code className="text-xs">wrappers</code> extension to
- create this wrapper.
- </p>
- <p className="text-warning">
- Warning: Before reinstalling the wrapper extension, you must first remove all existing
- wrappers. Afterward, you can recreate the wrappers.
- </p>
- </AlertDescription_Shadcn_>
- <AlertDescription_Shadcn_ className="mt-3">
- <Button asChild type="default">
- <Link
- href={
- databaseNeedsUpgrading
- ? `/project/${ref}/settings/infrastructure`
- : `/project/${ref}/database/extensions?filter=wrappers`
- }
- >
- {databaseNeedsUpgrading ? 'Upgrade database' : 'View wrappers extension'}
- </Link>
- </Button>
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- )}
-
- <WrapperTableEditor
- visible={isEditingTable}
- tables={wrapperMeta.tables}
- onCancel={() => {
- setSelectedTableToEdit(undefined)
- setIsEditingTable(false)
- }}
- onSave={onUpdateTable}
- initialData={selectedTableToEdit}
- />
- </FormsContainer>
- )
-}
-
-export default CreateWrapper
diff --git a/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx b/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx
deleted file mode 100644
index 7e547897e80..00000000000
--- a/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx
+++ /dev/null
@@ -1,398 +0,0 @@
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useQueryClient } from '@tanstack/react-query'
-import { isEmpty } from 'lodash'
-import { ArrowLeft, Edit, Loader, Trash } from 'lucide-react'
-import Link from 'next/link'
-import { useRouter } from 'next/router'
-import { useEffect, useState } from 'react'
-import { toast } from 'sonner'
-
-import { useParams } from 'common'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { DocsButton } from 'components/ui/DocsButton'
-import { FormActions } from 'components/ui/Forms/FormActions'
-import { FormPanel } from 'components/ui/Forms/FormPanel'
-import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'
-import { FormsContainer } from 'components/ui/Forms/FormsContainer'
-import { Loading } from 'components/ui/Loading'
-import { invalidateSchemasQuery } from 'data/database/schemas-query'
-import { useFDWUpdateMutation } from 'data/fdw/fdw-update-mutation'
-import { useFDWsQuery } from 'data/fdw/fdws-query'
-import { getDecryptedValue } from 'data/vault/vault-secret-decrypted-value-query'
-import { useVaultSecretsQuery } from 'data/vault/vault-secrets-query'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { useImmutableValue } from 'hooks/misc/useImmutableValue'
-import { Button, cn, Form, Input } from 'ui'
-import InputField from './InputField'
-import WrapperTableEditor from './WrapperTableEditor'
-import {
- convertKVStringArrayToJson,
- formatWrapperTables,
- getWrapperMetaForWrapper,
- makeValidateRequired,
-} from './Wrappers.utils'
-
-const EditWrapper = () => {
- const formId = 'edit-wrapper-form'
- const router = useRouter()
- const queryClient = useQueryClient()
- const { ref, id } = useParams()
- const { project } = useProjectContext()
-
- const { data, isLoading } = useFDWsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const { data: secrets, isLoading: isSecretsLoading } = useVaultSecretsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const wrappers = data ?? []
- const foundWrapper = wrappers.find((w) => Number(w.id) === Number(id))
- // this call to useImmutableValue should be removed if the redirect after update is also removed
- const wrapper = useImmutableValue(foundWrapper)
- const wrapperMeta = getWrapperMetaForWrapper(wrapper)
-
- const { mutate: updateFDW, isLoading: isSaving } = useFDWUpdateMutation({
- onSuccess: () => {
- toast.success(`Successfully updated ${wrapperMeta?.label} foreign data wrapper`)
- setWrapperTables([])
-
- const hasNewSchema = wrapperTables.some((table) => table.is_new_schema)
- if (hasNewSchema) invalidateSchemasQuery(queryClient, ref)
-
- router.push(`/project/${ref}/integrations/wrappers`)
- },
- })
-
- const [wrapperTables, setWrapperTables] = useState<any[]>([])
- const [isEditingTable, setIsEditingTable] = useState(false)
- const [selectedTableToEdit, setSelectedTableToEdit] = useState()
- const [formErrors, setFormErrors] = useState<{ [k: string]: string }>({})
-
- const canUpdateWrapper = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'wrappers')
-
- const initialValues =
- wrapperMeta !== undefined
- ? {
- wrapper_name: wrapper?.name,
- server_name: wrapper?.server_name,
- ...convertKVStringArrayToJson(wrapper?.server_options ?? []),
- }
- : {}
-
- useEffect(() => {
- if (wrapper?.id) {
- setWrapperTables(formatWrapperTables(wrapper, wrapperMeta))
- }
- }, [wrapper?.id])
-
- if (isLoading) {
- return (
- <div className="flex items-center justify-center w-full h-full">
- <Loading />
- </div>
- )
- }
-
- if (wrapper === undefined || wrapperMeta === undefined) {
- if (isSaving) {
- return (
- <div className="flex flex-col items-center justify-center w-full h-full space-y-4">
- <div className="flex items-center space-x-4">
- <Loader className="animate-spin" size={16} />
- <p className="text-sm">Updating wrapper</p>
- </div>
- </div>
- )
- } else {
- return (
- <div className="flex flex-col items-center justify-center w-full h-full space-y-4">
- <div className="space-y-2 flex flex-col items-center w-[400px]">
- <p>Unknown wrapper</p>
- <p className="text-sm text-center text-foreground-light">
- The wrapper ID {id} cannot be found in your project. Head back to select another
- wrapper.
- </p>
- </div>
- <Button asChild type="default">
- <Link href={`/project/${ref}/integrations/wrappers`}>Head back</Link>
- </Button>
- </div>
- )
- }
- }
-
- const onUpdateTable = (values: any) => {
- setWrapperTables((prev) => {
- // if the new values have tableIndex, we are editing an existing table
- if (values.tableIndex !== undefined) {
- const tableIndex = values.tableIndex
- const wrapperTables = [...prev]
- delete values.tableIndex
- wrapperTables[tableIndex] = values
- return wrapperTables
- }
- return [...prev, values]
- })
- setIsEditingTable(false)
- setSelectedTableToEdit(undefined)
- }
-
- const onSubmit = async (values: any) => {
- const validate = makeValidateRequired(wrapperMeta.server.options)
- const errors: any = validate(values)
-
- const { wrapper_name } = values
- if (wrapper_name.length === 0) errors.name = 'Please provide a name for your wrapper'
- if (wrapperTables.length === 0) errors.tables = 'Please add at least one table'
- if (!isEmpty(errors)) return setFormErrors(errors)
-
- updateFDW({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- wrapper,
- wrapperMeta,
- formState: { ...values, server_name: `${wrapper_name}_server` },
- tables: wrapperTables,
- })
- }
-
- return (
- <FormsContainer className="[&>div]:space-y-0">
- <div className="relative flex items-center justify-between mb-6">
- <div
- className={cn(
- 'transition cursor-pointer',
- 'absolute -left-20 top-1 opacity-75 hover:opacity-100'
- )}
- >
- <Link href={`/project/${ref}/integrations/wrappers`}>
- <div className="flex items-center space-x-2">
- <ArrowLeft strokeWidth={1.5} size={14} />
- <p className="text-sm">Back</p>
- </div>
- </Link>
- </div>
- <h3 className="mb-2 text-xl text-foreground">
- Edit {wrapperMeta.label} wrapper: {wrapper.name}
- </h3>
- <DocsButton href="https://supabase.github.io/wrappers/stripe/" />
- </div>
-
- <Form id={formId} initialValues={initialValues} onSubmit={onSubmit}>
- {({ handleReset, values, initialValues, resetForm }: any) => {
- // [Alaister] although this "technically" is breaking the rules of React hooks
- // it won't error because the hooks are always rendered in the same order
- // eslint-disable-next-line react-hooks/rules-of-hooks
- const [loadingSecrets, setLoadingSecrets] = useState(false)
-
- const initialTables = formatWrapperTables({
- handler: wrapper.handler,
- tables: wrapper?.tables ?? [],
- })
- const hasFormChanges = JSON.stringify(values) !== JSON.stringify(initialValues)
- const hasTableChanges = JSON.stringify(initialTables) !== JSON.stringify(wrapperTables)
- const hasChanges = hasFormChanges || hasTableChanges
-
- const encryptedOptions = wrapperMeta.server.options.filter((option) => option.encrypted)
-
- // [Alaister] although this "technically" is breaking the rules of React hooks
- // it won't error because the hooks are always rendered in the same order
- // eslint-disable-next-line react-hooks/rules-of-hooks
- useEffect(() => {
- const fetchEncryptedValues = async () => {
- setLoadingSecrets(true)
- // If the secrets haven't loaded, escape and run the effect again when they're loaded
- if (isSecretsLoading) {
- return
- }
-
- const res = await Promise.all(
- encryptedOptions.map(async (option) => {
- const secret = secrets?.find(
- (secret) => secret.name === `${wrapper.name}_${option.name}`
- )
- if (secret !== undefined) {
- const value = await getDecryptedValue({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- id: secret.id,
- })
- return { [option.name]: value[0]?.decrypted_secret ?? '' }
- } else {
- return { [option.name]: '' }
- }
- })
- )
- const secretValues = res.reduce((a: any, b: any) => {
- const [key] = Object.keys(b)
- return { ...a, [key]: b[key] }
- }, {})
-
- resetForm({
- values: { ...values, ...secretValues },
- initialValues: { ...initialValues, ...secretValues },
- })
- setLoadingSecrets(false)
- }
-
- if (encryptedOptions.length > 0) fetchEncryptedValues()
- }, [isSecretsLoading])
-
- return (
- <FormPanel
- disabled={!canUpdateWrapper}
- footer={
- <div className="flex px-8 py-4">
- <FormActions
- form={formId}
- isSubmitting={isSaving}
- hasChanges={hasChanges}
- handleReset={() => {
- handleReset()
- setWrapperTables(initialTables)
- }}
- disabled={!canUpdateWrapper}
- helper={
- !canUpdateWrapper
- ? 'You need additional permissions to edit a foreign data wrapper'
- : undefined
- }
- />
- </div>
- }
- >
- <FormSection header={<FormSectionLabel>Wrapper Configuration</FormSectionLabel>}>
- <FormSectionContent loading={false}>
- <Input
- id="wrapper_name"
- label="Wrapper Name"
- error={formErrors.wrapper_name}
- descriptionText={
- values.wrapper_name !== initialValues.wrapper_name ? (
- <>
- Your wrapper's server name will be updated to{' '}
- <code className="text-xs">{values.wrapper_name}_server</code>
- </>
- ) : (
- <>
- Your wrapper's server name is{' '}
- <code className="text-xs">{values.wrapper_name}_server</code>
- </>
- )
- }
- />
- </FormSectionContent>
- </FormSection>
- <FormSection
- header={<FormSectionLabel>{wrapperMeta.label} Configuration</FormSectionLabel>}
- >
- <FormSectionContent loading={false}>
- {wrapperMeta.server.options
- .filter((option) => !option.hidden)
- .map((option) => (
- <InputField
- key={option.name}
- option={option}
- loading={option.encrypted ? loadingSecrets : false}
- error={formErrors[option.name]}
- />
- ))}
- </FormSectionContent>
- </FormSection>
- <FormSection
- header={
- <FormSectionLabel>
- <p>Foreign Tables</p>
- <p className="text-foreground-light mt-2 w-[90%]">
- You can query your data from these foreign tables after the wrapper is created
- </p>
- </FormSectionLabel>
- }
- >
- <FormSectionContent loading={false}>
- {wrapperTables.length === 0 ? (
- <div className="flex justify-end translate-y-4">
- <Button type="default" onClick={() => setIsEditingTable(true)}>
- Add foreign table
- </Button>
- </div>
- ) : (
- <div className="space-y-2">
- {wrapperTables.map((table, i) => {
- const target = table?.table ?? table.object
-
- return (
- <div
- key={`${table.schema_name}.${table.table_name}`}
- className="flex items-center justify-between px-4 py-2 border rounded-md border-control"
- >
- <div>
- <p className="text-sm">
- {table.schema_name}.{table.table_name}{' '}
- </p>
- <p className="text-sm text-foreground-light mt-1">Target: {target}</p>
- <p className="text-sm text-foreground-light">
- Columns:{' '}
- {table.columns.map((column: any) => column.name).join(', ')}
- </p>
- </div>
- <div className="flex items-center space-x-2">
- <Button
- type="default"
- className="px-1"
- icon={<Edit />}
- onClick={() => {
- setIsEditingTable(true)
- setSelectedTableToEdit({ ...table, tableIndex: i })
- }}
- />
- <Button
- type="default"
- className="px-1"
- icon={<Trash />}
- onClick={() => {
- setWrapperTables((prev) => prev.filter((_, j) => j !== i))
- }}
- />
- </div>
- </div>
- )
- })}
- </div>
- )}
- {wrapperTables.length > 0 && (
- <div className="flex justify-end">
- <Button type="default" onClick={() => setIsEditingTable(true)}>
- Add foreign table
- </Button>
- </div>
- )}
- {wrapperTables.length === 0 && formErrors.tables && (
- <p className="text-sm text-right text-red-900">{formErrors.tables}</p>
- )}
- </FormSectionContent>
- </FormSection>
- </FormPanel>
- )
- }}
- </Form>
-
- <WrapperTableEditor
- visible={isEditingTable}
- tables={wrapperMeta.tables}
- onCancel={() => {
- setSelectedTableToEdit(undefined)
- setIsEditingTable(false)
- }}
- onSave={onUpdateTable}
- initialData={selectedTableToEdit}
- />
- </FormsContainer>
- )
-}
-
-export default EditWrapper
diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrapperRow.tsx b/apps/studio/components/interfaces/Database/Wrappers/WrapperRow.tsx
deleted file mode 100644
index ac81ccbad08..00000000000
--- a/apps/studio/components/interfaces/Database/Wrappers/WrapperRow.tsx
+++ /dev/null
@@ -1,185 +0,0 @@
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { partition } from 'lodash'
-import { ChevronUp, Edit, ExternalLink, Trash } from 'lucide-react'
-import Image from 'next/legacy/image'
-import Link from 'next/link'
-
-import { useParams } from 'common'
-import { ButtonTooltip } from 'components/ui/ButtonTooltip'
-import type { FDW } from 'data/fdw/fdws-query'
-import { EditorTablePageLink } from 'data/prefetchers/project.$ref.editor.$id'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { Collapsible } from 'ui'
-import type { WrapperMeta } from './Wrappers.types'
-
-interface WrapperRowProps {
- wrappers: FDW[]
- wrapperMeta: WrapperMeta
- isOpen: boolean
- onOpen: (wrapper: string) => void
- onSelectDelete: (wrapper: FDW) => void
-}
-
-const WrapperRow = ({
- wrappers = [],
- wrapperMeta,
- isOpen,
- onOpen,
- onSelectDelete,
-}: WrapperRowProps) => {
- const { ref } = useParams()
- const canManageWrappers = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'wrappers')
-
- return (
- <>
- <Collapsible
- open={isOpen}
- onOpenChange={() => onOpen(wrapperMeta.name)}
- className={[
- 'bg-surface-100',
- 'hover:bg-overlay-hover',
- 'data-open:bg-selection',
- 'border-default',
- 'hover:border-strong',
- 'data-open:border-strong',
- 'col-span-12 mx-auto',
- '-space-y-px overflow-hidden',
- 'transition border shadow hover:z-50',
- 'first:rounded-tl first:rounded-tr first:!border-t',
- 'last:rounded-bl last:rounded-br last:border-t-0',
- ].join(' ')}
- >
- <Collapsible.Trigger asChild>
- <button
- type="button"
- className="flex items-center justify-between w-full px-6 py-3 rounded group text-foreground"
- >
- <div className="flex items-center gap-3">
- <ChevronUp
- className="transition text-border-stronger data-open-parent:rotate-0 data-closed-parent:rotate-180"
- strokeWidth={2}
- width={14}
- />
- <Image
- src={wrapperMeta.icon}
- width={20}
- height={20}
- alt={`${wrapperMeta.name} wrapper icon`}
- />
- <span className="text-sm capitalize">{wrapperMeta.label}</span>
- </div>
- <div className="flex items-center gap-3">
- <div className="px-3 py-1 text-xs border rounded-md border-strong bg-surface-100 text-foreground">
- {wrappers.length} wrapper{wrappers.length > 1 ? 's' : ''}
- </div>
- </div>
- </button>
- </Collapsible.Trigger>
- <Collapsible.Content>
- <div className="border-t group border-strong bg-surface-100 text-foreground divide-y">
- {wrappers.map((wrapper) => {
- const serverOptions = Object.fromEntries(
- wrapper.server_options.map((option: any) => option.split('='))
- )
- const [encryptedMetadata, visibleMetadata] = partition(
- wrapperMeta.server.options.filter((option) => !option.hidden),
- 'secureEntry'
- )
-
- return (
- <div key={wrapper.id} className="px-6 py-4 flex items-center justify-between">
- <div className="space-y-1 w-3/4">
- <div className="flex items-center space-x-2">
- <p className="text-base">{wrapper.name}</p>
- </div>
- {visibleMetadata.map((metadata) => (
- <div
- key={metadata.name}
- className="flex items-center space-x-2 text-sm text-foreground-light"
- >
- <p>{metadata.label}:</p>
- <p>{serverOptions[metadata.name]}</p>
- </div>
- ))}
- {encryptedMetadata.map((metadata) => (
- <div key={metadata.name} className="flex items-center space-x-2 text-sm">
- <p className="text-foreground-light">{metadata.label}:</p>
- <Link
- href={`/project/${ref}/settings/vault/secrets?search=${wrapper.name}_${metadata.name}`}
- className="transition text-foreground-light hover:text-foreground flex items-center space-x-2"
- >
- <span>Encrypted in Vault</span>
- <ExternalLink size={14} strokeWidth={1.5} />
- </Link>
- </div>
- ))}
- <div className="!mt-3 space-y-1">
- <p className="text-sm text-foreground-light">
- Foreign tables{wrapper.tables && `: (${wrapper.tables.length})`}
- </p>
- <div className="flex flex-wrap gap-2">
- {wrapper.tables ? (
- wrapper.tables.map((table) => (
- <EditorTablePageLink
- key={table.id}
- projectRef={ref}
- id={String(table.id)}
- >
- <div className="text-sm border rounded px-2 py-1 transition bg-surface-200 hover:bg-overlay-hover">
- {table.name}
- </div>
- </EditorTablePageLink>
- ))
- ) : (
- <p className="text-sm text-foreground-light">No tables available</p>
- )}
- </div>
- </div>
- </div>
- <div className="flex items-center gap-x-2">
- <ButtonTooltip
- asChild
- disabled={!canManageWrappers}
- type="default"
- icon={<Edit strokeWidth={1.5} />}
- className="px-1.5 space-x-0"
- tooltip={{
- content: {
- side: 'bottom',
- text: !canManageWrappers
- ? 'You need additional permissions to edit wrappers'
- : 'Edit wrapper',
- },
- }}
- >
- <Link href={`/project/${ref}/integrations/wrappers/${wrapper.id}`}>
- <span className="sr-only">Edit</span>
- </Link>
- </ButtonTooltip>
- <ButtonTooltip
- type="default"
- disabled={!canManageWrappers}
- icon={<Trash strokeWidth={1.5} />}
- className="px-1.5"
- onClick={() => onSelectDelete(wrapper)}
- tooltip={{
- content: {
- side: 'bottom',
- text: !canManageWrappers
- ? 'You need additional permissions to delete wrappers'
- : 'Delete wrapper',
- },
- }}
- />
- </div>
- </div>
- )
- })}
- </div>
- </Collapsible.Content>
- </Collapsible>
- </>
- )
-}
-
-export default WrapperRow
diff --git a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.tsx b/apps/studio/components/interfaces/Database/Wrappers/Wrappers.tsx
deleted file mode 100644
index 76c92a2eb58..00000000000
--- a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { useState } from 'react'
-
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { FDW, useFDWsQuery } from 'data/fdw/fdws-query'
-import DeleteWrapperModal from './DeleteWrapperModal'
-import WrapperRow from './WrapperRow'
-import { WRAPPERS } from './Wrappers.constants'
-import { wrapperMetaComparator } from './Wrappers.utils'
-import WrappersDisabledState from './WrappersDisabledState'
-import WrappersEmptyState from './WrappersEmptyState'
-
-const Wrappers = ({ isEnabled }: { isEnabled: boolean }) => {
- const { project } = useProjectContext()
- const { data } = useFDWsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const [open, setOpen] = useState<string>('')
- const [selectedWrapperToDelete, setSelectedWrapperToDelete] = useState<FDW>()
-
- const wrappers = data ?? []
-
- return (
- <>
- {isEnabled ? (
- <div>
- {wrappers.length === 0 ? (
- <WrappersEmptyState />
- ) : (
- <>
- {WRAPPERS.map((wrapper, i) => {
- const createdWrappers = wrappers.filter((w) => wrapperMetaComparator(wrapper, w))
-
- if (createdWrappers.length > 0) {
- return (
- <WrapperRow
- key={i}
- wrapperMeta={wrapper}
- wrappers={createdWrappers}
- isOpen={open === wrapper.name}
- onOpen={(wrapperName) => {
- if (open !== wrapperName) setOpen(wrapperName)
- else setOpen('')
- }}
- onSelectDelete={setSelectedWrapperToDelete}
- />
- )
- } else {
- return null
- }
- })}
- </>
- )}
- </div>
- ) : (
- <WrappersDisabledState />
- )}
-
- <DeleteWrapperModal
- selectedWrapper={selectedWrapperToDelete}
- onClose={() => setSelectedWrapperToDelete(undefined)}
- />
- </>
- )
-}
-
-export default Wrappers
diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrappersDisabledState.tsx b/apps/studio/components/interfaces/Database/Wrappers/WrappersDisabledState.tsx
deleted file mode 100644
index 61933f017b7..00000000000
--- a/apps/studio/components/interfaces/Database/Wrappers/WrappersDisabledState.tsx
+++ /dev/null
@@ -1,179 +0,0 @@
-import * as Tooltip from '@radix-ui/react-tooltip'
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useTheme } from 'next-themes'
-import Link from 'next/link'
-import { useState } from 'react'
-import { toast } from 'sonner'
-
-import { useParams } from 'common'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { useDatabaseExtensionEnableMutation } from 'data/database-extensions/database-extension-enable-mutation'
-import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { BASE_PATH } from 'lib/constants'
-import { Button } from 'ui'
-import { ExternalLink } from 'lucide-react'
-
-const WrappersDisabledState = () => {
- const { ref } = useParams()
- const { resolvedTheme } = useTheme()
- const { project } = useProjectContext()
-
- const { data } = useDatabaseExtensionsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
- const wrappersExtension = (data ?? []).find((ext) => ext.name === 'wrappers')
- const vaultExtension = (data ?? []).find((ext) => ext.name === 'supabase_vault')
- const isNotAvailable = wrappersExtension === undefined || vaultExtension === undefined
-
- const [isEnabling, setIsEnabling] = useState<boolean>(false)
- const canToggleWrappers = useCheckPermissions(
- PermissionAction.TENANT_SQL_ADMIN_WRITE,
- 'extensions'
- )
-
- const { mutateAsync: enableExtension } = useDatabaseExtensionEnableMutation({ onError: () => {} })
-
- const onEnableWrappers = async () => {
- if (wrappersExtension === undefined || vaultExtension === undefined) return
- if (project === undefined) return console.error('Project is required')
-
- let hasError = false
-
- try {
- setIsEnabling(true)
- await Promise.all([
- enableExtension({
- projectRef: project.ref,
- connectionString: project.connectionString,
- schema: wrappersExtension.schema ?? 'extensions',
- name: wrappersExtension.name,
- version: wrappersExtension.default_version,
- cascade: true,
- }),
- enableExtension({
- projectRef: project.ref,
- connectionString: project.connectionString,
- schema: vaultExtension.schema ?? 'vault',
- name: vaultExtension.name,
- version: vaultExtension.default_version,
- cascade: true,
- }),
- ])
- } catch (error: any) {
- if (!error.message.includes('already exists')) {
- hasError = true
- toast.error(`Failed to enable Wrappers: ${error.message}`)
- }
- } finally {
- setIsEnabling(false)
- if (!hasError) toast.success('Wrappers are now enabled!')
- }
- }
-
- return (
- <div>
- <div
- className="w-full px-12 py-12 bg-no-repeat border rounded-md bg-alternative-200 border-default"
- style={{
- backgroundSize: '45%',
- backgroundPosition: '105% 40%',
- backgroundImage: resolvedTheme?.includes('dark')
- ? `url("${BASE_PATH}/img/wrappers-dark.png")`
- : `url("${BASE_PATH}/img/wrappers-light.png")`,
- }}
- >
- <div className="w-3/5 space-y-8">
- <div className="space-y-2">
- <h4 className="text-lg">Supabase Wrappers</h4>
- <p className="text-sm text-foreground-light">
- Supabase Wrappers is a framework for building Postgres Foreign Data Wrappers (FDW)
- which connect Postgres to external systems. Query your data warehouse or third-party
- APIs directly from your database.
- </p>
- </div>
- {isNotAvailable ? (
- <div className="space-y-4">
- <div className="rounded border border-default px-4 py-2 flex items-center justify-between">
- <div>
- <p className="text-foreground-light text-sm">
- Wrappers is not available for this project yet.
- </p>
- <p className="text-foreground-light text-sm">
- Do reach out to us if you're interested!
- </p>
- </div>
- <div>
- <Button asChild type="primary">
- <Link
- href={`/support/new?ref=${ref}&category=sales&subject=Request%20for%20access%20to%20wrappers`}
- target="_blank"
- rel="noreferrer"
- >
- Contact us
- </Link>
- </Button>
- </div>
- </div>
- <div className="flex items-center space-x-2 my-1 ml-[1px]">
- <Button asChild type="default" icon={<ExternalLink />}>
- <Link
- href="https://supabase.com/docs/guides/database/extensions/wrappers/overview"
- target="_blank"
- rel="noreferrer"
- >
- About Wrappers
- </Link>
- </Button>
- </div>
- </div>
- ) : (
- <div className="flex items-center space-x-2">
- <Button asChild type="default" icon={<ExternalLink />}>
- <Link
- href="https://supabase.com/docs/guides/database/extensions/wrappers/overview"
- target="_blank"
- rel="noreferrer"
- >
- About Wrappers
- </Link>
- </Button>
- <Tooltip.Root delayDuration={0}>
- <Tooltip.Trigger asChild>
- <Button
- type="primary"
- loading={isEnabling}
- disabled={isNotAvailable || isEnabling || !canToggleWrappers}
- onClick={() => onEnableWrappers()}
- >
- Enable Wrappers
- </Button>
- </Tooltip.Trigger>
- {!canToggleWrappers && (
- <Tooltip.Portal>
- <Tooltip.Content side="bottom">
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'rounded bg-alternative py-1 px-2 leading-none shadow',
- 'border border-background',
- ].join(' ')}
- >
- <span className="text-xs text-foreground">
- You need additional permissions to enable Wrappers for this project
- </span>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- )}
- </Tooltip.Root>
- </div>
- )}
- </div>
- </div>
- </div>
- )
-}
-
-export default WrappersDisabledState
diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrappersDropdown.tsx b/apps/studio/components/interfaces/Database/Wrappers/WrappersDropdown.tsx
deleted file mode 100644
index 8d8a262ae00..00000000000
--- a/apps/studio/components/interfaces/Database/Wrappers/WrappersDropdown.tsx
+++ /dev/null
@@ -1,112 +0,0 @@
-import * as Tooltip from '@radix-ui/react-tooltip'
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { Plus } from 'lucide-react'
-import Image from 'next/legacy/image'
-import { useRouter } from 'next/router'
-import { useState } from 'react'
-
-import { useParams } from 'common'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import {
- Button,
- CommandEmpty_Shadcn_,
- CommandGroup_Shadcn_,
- CommandInput_Shadcn_,
- CommandItem_Shadcn_,
- CommandList_Shadcn_,
- Command_Shadcn_,
- PopoverContent_Shadcn_,
- PopoverTrigger_Shadcn_,
- Popover_Shadcn_,
- ScrollArea,
-} from 'ui'
-import { WRAPPERS } from './Wrappers.constants'
-
-interface WrapperDropdownProps {
- buttonText?: string
- align?: 'center' | 'end'
-}
-
-const WrapperDropdown = ({ buttonText = 'Add wrapper', align = 'end' }: WrapperDropdownProps) => {
- const router = useRouter()
- const { ref } = useParams()
- const canManageWrappers = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'wrappers')
- const [open, setOpen] = useState(false)
-
- if (!canManageWrappers) {
- return (
- <Tooltip.Root delayDuration={0}>
- <Tooltip.Trigger asChild>
- <Button disabled type="primary" icon={<Plus strokeWidth={1.5} />}>
- {buttonText}
- </Button>
- </Tooltip.Trigger>
- <Tooltip.Portal>
- <Tooltip.Content side="bottom">
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'rounded bg-alternative py-1 px-2 leading-none shadow',
- 'border border-background',
- ].join(' ')}
- >
- <span className="text-xs text-foreground">
- You need additional permissions to add wrappers
- </span>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- </Tooltip.Root>
- )
- }
-
- return (
- <Popover_Shadcn_ open={open} onOpenChange={setOpen}>
- <PopoverTrigger_Shadcn_ asChild>
- <Button
- type="primary"
- role="combobox"
- aria-expanded={open}
- icon={<Plus className="h-4 w-4 shrink-0" />}
- >
- {buttonText}
- </Button>
- </PopoverTrigger_Shadcn_>
- <PopoverContent_Shadcn_ className="w-[200px] p-0" align={align}>
- <Command_Shadcn_>
- <CommandInput_Shadcn_ placeholder="Search wrappers..." />
- <CommandList_Shadcn_>
- <CommandEmpty_Shadcn_ className="py-3">No wrappers found...</CommandEmpty_Shadcn_>
- <CommandGroup_Shadcn_>
- <ScrollArea className="max-h-[270px] overflow-scroll">
- {WRAPPERS.map((wrapper) => (
- <CommandItem_Shadcn_
- key={wrapper.name}
- value={wrapper.name}
- onSelect={() => {
- setOpen(false)
- router.push(
- `/project/${ref}/integrations/wrappers/new?type=${wrapper.name.toLowerCase()}`
- )
- }}
- className="gap-2 cursor-pointer"
- >
- <Image
- width={20}
- height={20}
- src={wrapper.icon}
- alt={`${wrapper.name} wrapper icon`}
- />
- {wrapper.label}
- </CommandItem_Shadcn_>
- ))}
- </ScrollArea>
- </CommandGroup_Shadcn_>
- </CommandList_Shadcn_>
- </Command_Shadcn_>
- </PopoverContent_Shadcn_>
- </Popover_Shadcn_>
- )
-}
-
-export default WrapperDropdown
diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrappersEmptyState.tsx b/apps/studio/components/interfaces/Database/Wrappers/WrappersEmptyState.tsx
deleted file mode 100644
index 3196e7c2cb9..00000000000
--- a/apps/studio/components/interfaces/Database/Wrappers/WrappersEmptyState.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { useParams } from 'common'
-import Image from 'next/image'
-import Link from 'next/link'
-import { Card } from 'ui'
-import { WRAPPERS } from './Wrappers.constants'
-import CardButton from 'components/ui/CardButton'
-
-const WrappersEmptyState = () => {
- const { ref } = useParams()
-
- return (
- <div className="flex flex-col gap-4">
- <hr />
- <div className="flex flex-col gap-1">
- <h2 className="text-foreground text-xl">No wrappers created yet</h2>
- <p className="prose text-sm">Create a new wrapper by choosing one below</p>
- </div>
-
- <div className="grid sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
- {WRAPPERS.map((wrapper) => (
- <CardButton
- linkHref={`/project/${ref}/integrations/wrappers/new?type=${wrapper.name.toLowerCase()}`}
- title={wrapper.label}
- fixedHeight={false}
- >
- <div className="flex items-center justify-center mt-3 mb-1">
- <Image
- width={40}
- height={40}
- src={wrapper.icon}
- alt={`${wrapper.name} wrapper icon`}
- />
- </div>
- </CardButton>
- ))}
- </div>
- </div>
- )
-}
-
-export default WrappersEmptyState
diff --git a/apps/studio/components/interfaces/Database/index.ts b/apps/studio/components/interfaces/Database/index.ts
index 793792801c0..f5d62dac764 100644
--- a/apps/studio/components/interfaces/Database/index.ts
+++ b/apps/studio/components/interfaces/Database/index.ts
@@ -5,10 +5,6 @@ export { default as RolesList } from './Roles/RolesList'
export { default as Extensions } from './Extensions/Extensions'
-export { default as CreateWrapper } from './Wrappers/CreateWrapper'
-export { default as EditWrapper } from './Wrappers/EditWrapper'
-export { default as Wrappers } from './Wrappers/Wrappers'
-
export { default as PublicationsList } from './Publications/PublicationsList'
export { default as PublicationsTables } from './Publications/PublicationsTables'
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsDisabledState.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsDisabledState.tsx
deleted file mode 100644
index 591e072f817..00000000000
--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsDisabledState.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useState } from 'react'
-
-import EnableExtensionModal from 'components/interfaces/Database/Extensions/EnableExtensionModal'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'
-import { ButtonTooltip } from 'components/ui/ButtonTooltip'
-import { DocsButton } from 'components/ui/DocsButton'
-import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-
-export const CronJobsDisabledState = () => {
- const [showEnableExtensionModal, setShowEnableExtensionModal] = useState(false)
- const { project } = useProjectContext()
- const canToggleExtensions = useCheckPermissions(
- PermissionAction.TENANT_SQL_ADMIN_WRITE,
- 'extensions'
- )
-
- const { data } = useDatabaseExtensionsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const pgCronExtension = (data ?? []).find((ext) => ext.name === 'pg_cron')
-
- if (!pgCronExtension) return null
-
- return (
- <>
- <div className="w-full h-full flex items-center justify-center">
- <ProductEmptyState title="Cron Jobs">
- <div className="text-sm text-foreground-light mb-4 grid gap-2">
- <p>
- Cron jobs in PostgreSQL allow you to schedule and automate tasks such as running SQL
- queries or maintenance routines at specified intervals.
- </p>
- <p>Enable cron jobs in your project.</p>
- </div>
-
- <div className="flex items-center gap-3 mt-4">
- <ButtonTooltip
- type="primary"
- disabled={!canToggleExtensions}
- onClick={() => setShowEnableExtensionModal(true)}
- tooltip={{
- content: {
- side: 'bottom',
- text: !canToggleExtensions
- ? 'You need additional permissions to enable pg_cron for this project'
- : undefined,
- },
- }}
- >
- Enable Cron Jobs
- </ButtonTooltip>
- <DocsButton href="https://supabase.com/docs/guides/database/extensions/pg_cron" />
- </div>
- </ProductEmptyState>
- </div>
-
- <EnableExtensionModal
- visible={showEnableExtensionModal}
- extension={pgCronExtension}
- onCancel={() => setShowEnableExtensionModal(false)}
- />
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsListing.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsListing.tsx
deleted file mode 100644
index 2ae618a7a8c..00000000000
--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsListing.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { useState } from 'react'
-
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
-import { CronJob, useCronJobsQuery } from 'data/database-cron-jobs/database-cron-jobs-query'
-
-import { CronJobCard } from './CronJobCard'
-import DeleteCronJob from './DeleteCronJob'
-import { Sheet, SheetContent } from 'ui'
-import { CreateCronJobSheet } from 'components/interfaces/Integrations/CronJobs/CreateCronJobSheet'
-
-export const CronJobsListing = () => {
- const { project } = useProjectContext()
-
- // used for confirmation prompt in the Create Cron Job Sheet
- const [isClosingCreateCronJobSheet, setIsClosingCreateCronJobSheet] = useState(false)
- const [createCronJobSheetShown, setCreateCronJobSheetShown] = useState<
- Pick<CronJob, 'jobname' | 'schedule' | 'active' | 'command'> | undefined
- >()
- const [cronJobForDeletion, setCronJobForDeletion] = useState<CronJob | undefined>()
-
- const { data: cronJobs, isLoading } = useCronJobsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- if (isLoading) return <GenericSkeletonLoader />
-
- return (
- <>
- <div className="w-full space-y-4">
- {(cronJobs ?? []).length == 0 ? (
- <div className="grid text-center h-full w-full items-center justify-center border border-border rounded-md p-4 border-dashed">
- <p className="text-sm text-foreground">No cron jobs created yet</p>
- <p className="text-sm text-foreground-lighter">
- Create one by clicking "Create a new cron job"
- </p>
- </div>
- ) : (
- <div className="w-full space-y-4">
- {(cronJobs ?? []).map((job) => (
- <CronJobCard
- job={job}
- onEditCronJob={(job) => setCreateCronJobSheetShown(job)}
- onDeleteCronJob={(job) => setCronJobForDeletion(job)}
- />
- ))}
- </div>
- )}
- </div>
-
- <DeleteCronJob
- visible={!!cronJobForDeletion}
- onClose={() => setCronJobForDeletion(undefined)}
- cronJob={cronJobForDeletion!}
- />
-
- <Sheet
- open={!!createCronJobSheetShown}
- onOpenChange={() => setIsClosingCreateCronJobSheet(true)}
- >
- <SheetContent size="default" tabIndex={undefined}>
- <CreateCronJobSheet
- selectedCronJob={createCronJobSheetShown}
- onClose={() => {
- setIsClosingCreateCronJobSheet(false)
- setCreateCronJobSheetShown(undefined)
- }}
- isClosing={isClosingCreateCronJobSheet}
- setIsClosing={setIsClosingCreateCronJobSheet}
- />
- </SheetContent>
- </Sheet>
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/NewCronJobs/CronjobsTab.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Integrations/NewCronJobs/CronjobsTab.tsx
rename to apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.tsx
diff --git a/apps/studio/components/interfaces/Integrations/Landing/Integrations.constants.tsx b/apps/studio/components/interfaces/Integrations/Landing/Integrations.constants.tsx
index 5745c362df6..ff58555f2c3 100644
--- a/apps/studio/components/interfaces/Integrations/Landing/Integrations.constants.tsx
+++ b/apps/studio/components/interfaces/Integrations/Landing/Integrations.constants.tsx
@@ -2,12 +2,12 @@ import { Clock5, Layers, Vault, Webhook } from 'lucide-react'
import Image from 'next/image'
import { ComponentType, ReactNode } from 'react'
-import { WRAPPERS } from 'components/interfaces/Database/Wrappers/Wrappers.constants'
-import { WrapperMeta } from 'components/interfaces/Database/Wrappers/Wrappers.types'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { BASE_PATH } from 'lib/constants'
import dynamic from 'next/dynamic'
import { cn } from 'ui'
+import { WRAPPERS } from '../Wrappers/Wrappers.constants'
+import { WrapperMeta } from '../Wrappers/Wrappers.types'
export type Navigation = {
route: string
@@ -79,15 +79,9 @@ const supabaseIntegrations: IntegrationDefinition[] = [
],
navigate: (id: string, pageId: string = 'overview', childId: string | undefined) => {
if (childId) {
- return dynamic(
- () =>
- import('components/interfaces/Integrations/NewQueues/QueueTab').then(
- (mod) => mod.QueueTab
- ),
- {
- loading: Loading,
- }
- )
+ return dynamic(() => import('../Queues/QueueTab').then((mod) => mod.QueueTab), {
+ loading: Loading,
+ })
}
switch (pageId) {
case 'overview':
@@ -101,15 +95,9 @@ const supabaseIntegrations: IntegrationDefinition[] = [
}
)
case 'queues':
- return dynamic(
- () =>
- import('components/interfaces/Integrations/NewQueues/QueuesTab').then(
- (mod) => mod.QueuesTab
- ),
- {
- loading: Loading,
- }
- )
+ return dynamic(() => import('../Queues/QueuesTab').then((mod) => mod.QueuesTab), {
+ loading: Loading,
+ })
}
return null
},
@@ -151,15 +139,9 @@ const supabaseIntegrations: IntegrationDefinition[] = [
}
)
case 'cron-jobs':
- return dynamic(
- () =>
- import('components/interfaces/Integrations/NewCronJobs/CronjobsTab').then(
- (mod) => mod.CronjobsTab
- ),
- {
- loading: Loading,
- }
- )
+ return dynamic(() => import('../CronJobs/CronJobsTab').then((mod) => mod.CronjobsTab), {
+ loading: Loading,
+ })
}
return null
},
@@ -205,7 +187,7 @@ const supabaseIntegrations: IntegrationDefinition[] = [
case 'keys':
return dynamic(
() =>
- import('components/interfaces/Settings/Vault').then(
+ import('../Vault/Keys/EncryptionKeysManagement').then(
(mod) => mod.EncryptionKeysManagement
),
{
@@ -214,8 +196,7 @@ const supabaseIntegrations: IntegrationDefinition[] = [
)
case 'secrets':
return dynamic(
- () =>
- import('components/interfaces/Settings/Vault').then((mod) => mod.SecretsManagement),
+ () => import('../Vault/Secrets/SecretsManagement').then((mod) => mod.SecretsManagement),
{
loading: Loading,
}
diff --git a/apps/studio/components/interfaces/Integrations/Landing/useInstalledIntegrations.tsx b/apps/studio/components/interfaces/Integrations/Landing/useInstalledIntegrations.tsx
index d7bde8d37b2..8d5696fab5d 100644
--- a/apps/studio/components/interfaces/Integrations/Landing/useInstalledIntegrations.tsx
+++ b/apps/studio/components/interfaces/Integrations/Landing/useInstalledIntegrations.tsx
@@ -1,11 +1,11 @@
import { useMemo } from 'react'
-import { wrapperMetaComparator } from 'components/interfaces/Database/Wrappers/Wrappers.utils'
import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
import { useSchemasQuery } from 'data/database/schemas-query'
import { useFDWsQuery } from 'data/fdw/fdws-query'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
import { EMPTY_ARR } from 'lib/void'
+import { wrapperMetaComparator } from '../Wrappers/Wrappers.utils'
import { INTEGRATIONS } from './Integrations.constants'
export const useInstalledIntegrations = () => {
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/CreateQueueSheet.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/CreateQueueSheet.tsx
deleted file mode 100644
index 9835e9cd3a7..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/CreateQueueSheet.tsx
+++ /dev/null
@@ -1,337 +0,0 @@
-import { zodResolver } from '@hookform/resolvers/zod'
-import { SubmitHandler, useForm } from 'react-hook-form'
-import { toast } from 'sonner'
-import z from 'zod'
-
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
-import { useDatabaseQueueCreateMutation } from 'data/database-queues/database-queues-create-mutation'
-import {
- Badge,
- Button,
- Form_Shadcn_,
- FormControl_Shadcn_,
- FormField_Shadcn_,
- Input,
- Input_Shadcn_,
- RadioGroupStacked,
- RadioGroupStackedItem,
- Separator,
- SheetFooter,
- SheetHeader,
- SheetSection,
- SheetTitle,
-} from 'ui'
-import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
-import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
-import { QUEUE_TYPES } from './Queues.constants'
-
-export interface CreateQueueSheetProps {
- isClosing: boolean
- setIsClosing: (v: boolean) => void
- onClose: () => void
-}
-
-const normalQueueSchema = z.object({
- type: z.literal('basic'),
-})
-
-const partitionedQueueSchema = z.object({
- type: z.literal('partitioned'),
- partitionInterval: z.number(),
- retentionInterval: z.number(),
-})
-
-const unloggedQueueSchema = z.object({
- type: z.literal('unlogged'),
-})
-
-const FormSchema = z.object({
- name: z
- .string()
- .trim()
- .min(1, 'Please provide a name for your queue')
- .max(47, "The name can't be longer than 47 characters"),
- values: z.discriminatedUnion('type', [
- normalQueueSchema,
- partitionedQueueSchema,
- unloggedQueueSchema,
- ]),
-})
-
-export type CreateQueueForm = z.infer<typeof FormSchema>
-export type QueueType = CreateQueueForm['values']
-
-const FORM_ID = 'create-queue-sidepanel'
-
-export const CreateQueueSheet = ({ isClosing, setIsClosing, onClose }: CreateQueueSheetProps) => {
- // const [showEnableExtensionModal, setShowEnableExtensionModal] = useState(false)
- const { mutate: createQueue, isLoading } = useDatabaseQueueCreateMutation()
-
- // const canToggleExtensions = useCheckPermissions(
- // PermissionAction.TENANT_SQL_ADMIN_WRITE,
- // 'extensions'
- // )
-
- const form = useForm<CreateQueueForm>({
- resolver: zodResolver(FormSchema),
- defaultValues: {
- name: '',
- values: {
- type: 'basic',
- },
- },
- })
-
- const { project } = useProjectContext()
- const isEdited = form.formState.isDirty
-
- // if the form hasn't been touched and the user clicked esc or the backdrop, close the sheet
- if (!isEdited && isClosing) {
- onClose()
- }
-
- const onClosePanel = () => {
- if (isEdited) {
- setIsClosing(true)
- } else {
- onClose()
- }
- }
-
- const onSubmit: SubmitHandler<CreateQueueForm> = async ({ name, values }) => {
- let query = `SELECT pgmq.create('${name}');`
- if (values.type === 'partitioned') {
- query = `select from pgmq.create_partitioned('${name}', '${values.partitionInterval}', '${values.retentionInterval}');`
- }
- if (values.type === 'unlogged') {
- query = `SELECT pgmq.create_unlogged('${name}');`
- }
-
- createQueue(
- {
- projectRef: project!.ref,
- connectionString: project?.connectionString,
- query,
- },
- {
- onSuccess: () => {
- toast.success(`Successfully created queue ${name}`)
- onClose()
- },
- }
- )
- }
-
- const { data } = useDatabaseExtensionsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const pgPartmanExtension = (data ?? []).find((ext) => ext.name === 'pg_partman')
- const pgPartmanExtensionInstalled = pgPartmanExtension?.installed_version != undefined
-
- const queueType = form.watch('values.type')
-
- return (
- <>
- <div className="flex flex-col h-full" tabIndex={-1}>
- <SheetHeader>
- <SheetTitle>Create a new queue</SheetTitle>
- </SheetHeader>
-
- <div className="overflow-auto flex-grow">
- <Form_Shadcn_ {...form}>
- <form
- id={FORM_ID}
- className="flex-grow overflow-auto"
- onSubmit={form.handleSubmit(onSubmit)}
- >
- <SheetSection>
- <FormField_Shadcn_
- control={form.control}
- name="name"
- render={({ field }) => (
- <FormItemLayout label="Name" layout="vertical" className="gap-1">
- <FormControl_Shadcn_>
- <Input_Shadcn_ {...field} />
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
- </SheetSection>
- <Separator />
- <SheetSection>
- <FormField_Shadcn_
- control={form.control}
- name="values.type"
- render={({ field }) => (
- <FormItemLayout label="Type" layout="vertical" className="gap-1">
- <FormControl_Shadcn_>
- <RadioGroupStacked
- id="queue_type"
- name="queue_type"
- value={field.value}
- disabled={field.disabled}
- onValueChange={field.onChange}
- >
- {QUEUE_TYPES.map((definition) => (
- <RadioGroupStackedItem
- key={definition.value}
- id={definition.value}
- value={definition.value}
- label=""
- disabled={
- !pgPartmanExtensionInstalled && definition.value === 'partitioned'
- }
- showIndicator={false}
- >
- <div className="flex items-center gap-x-5">
- <div className="text-foreground">{definition.icon}</div>
- <div className="flex flex-col">
- <div className="flex gap-x-2">
- <p className="text-foreground">{definition.label}</p>
- </div>
- <p className="text-foreground-light text-left">
- {definition.description}
- </p>
- </div>
- </div>
- {definition.value === 'partitioned' ? (
- <div className="pt-2 pl-10">
- <Badge variant="warning">COMING SOON</Badge>
- </div>
- ) : null}
- {/* {!pgPartmanExtensionInstalled &&
- definition.value === 'partitioned' ? (
- <div className="w-full flex gap-x-2 pl-11 py-2 items-center">
- <WarningIcon />
- <span className="text-xs">
- <code>pg_partman</code> needs to be installed to use this type
- </span>
- </div>
- ) : null} */}
- </RadioGroupStackedItem>
- ))}
- </RadioGroupStacked>
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
- {/* {!pgPartmanExtensionInstalled && (
- <Admonition
- type="note"
- // @ts-ignore
- title={
- <span>
- Enable <code className="text-xs w-min">pg_partman</code> for partitioned
- queues
- </span>
- }
- description={
- <div className="flex flex-col gap-y-2">
- <span>
- This will allow you to create partitioned queues which can handle a large
- amount of messages
- </span>
- <ButtonTooltip
- type="default"
- className="w-min"
- disabled={!canToggleExtensions}
- onClick={() => setShowEnableExtensionModal(true)}
- tooltip={{
- content: {
- side: 'bottom',
- text: 'You need additional permissions to enable database extensions',
- },
- }}
- >
- Install pg_partman extension
- </ButtonTooltip>
- </div>
- }
- />
- )} */}
- </SheetSection>
- <Separator />
- {queueType === 'partitioned' && (
- <>
- <SheetSection className="flex flex-col gap-3">
- <FormField_Shadcn_
- control={form.control}
- name="values.partitionInterval"
- render={({ field: { ref, ...rest } }) => (
- <FormItemLayout label="Partition interval" className="gap-1">
- <Input
- {...rest}
- type="number"
- placeholder="1000"
- actions={<p className="text-foreground-light pr-2">ms</p>}
- />
- </FormItemLayout>
- )}
- />
- <FormField_Shadcn_
- control={form.control}
- name="values.retentionInterval"
- render={({ field: { ref, ...rest } }) => (
- <FormItemLayout label="Retention interval" className="gap-1">
- <Input
- {...rest}
- type="number"
- placeholder="1000"
- actions={<p className="text-foreground-light pr-2">ms</p>}
- />
- </FormItemLayout>
- )}
- />
- </SheetSection>
- </>
- )}
- </form>
- </Form_Shadcn_>
- </div>
- <SheetFooter>
- <Button
- size="tiny"
- type="default"
- htmlType="button"
- onClick={onClosePanel}
- disabled={isLoading}
- >
- Cancel
- </Button>
- <Button
- size="tiny"
- type="primary"
- form={FORM_ID}
- htmlType="submit"
- disabled={isLoading}
- loading={isLoading}
- >
- Create queue
- </Button>
- </SheetFooter>
- </div>
- <ConfirmationModal
- visible={isClosing}
- title="Discard changes"
- confirmLabel="Discard"
- onCancel={() => setIsClosing(false)}
- onConfirm={() => onClose()}
- >
- <p className="text-sm text-foreground-light">
- There are unsaved changes. Are you sure you want to close the panel? Your changes will be
- lost.
- </p>
- </ConfirmationModal>
- {/* {pgPartmanExtension && (
- <EnableExtensionModal
- visible={showEnableExtensionModal}
- extension={pgPartmanExtension}
- onCancel={() => setShowEnableExtensionModal(false)}
- />
- )} */}
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/Queues.constants.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/Queues.constants.tsx
deleted file mode 100644
index a80a56be71e..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/Queues.constants.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { Rows2, Rows3, Rows4 } from 'lucide-react'
-
-export const QUEUE_TYPES = [
- {
- value: 'basic',
- icon: <Rows4 strokeWidth={1} />,
- label: 'Basic queue',
- description: 'Create a basic queue.',
- },
- {
- value: 'unlogged',
- icon: <Rows2 strokeWidth={1} />,
- label: 'Unlogged queue',
- description:
- 'Creates an unlogged queue which loses all data on database restart. Can be useful when write throughput is more important than durability.',
- },
- {
- value: 'partitioned',
- icon: <Rows3 strokeWidth={1} />,
- label: 'Partitioned queue',
- description: 'Create a partitioned queue which is optimized for large amount of messages',
- },
-] as const
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/QueuesDisabledState.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/QueuesDisabledState.tsx
deleted file mode 100644
index 5de88c73820..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/QueuesDisabledState.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import * as Tooltip from '@radix-ui/react-tooltip'
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useState } from 'react'
-
-import EnableExtensionModal from 'components/interfaces/Database/Extensions/EnableExtensionModal'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'
-import { DocsButton } from 'components/ui/DocsButton'
-import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { Button } from 'ui'
-
-export const QueuesDisabledState = () => {
- const [showEnableExtensionModal, setShowEnableExtensionModal] = useState(false)
- const { project } = useProjectContext()
- const canToggleExtensions = useCheckPermissions(
- PermissionAction.TENANT_SQL_ADMIN_WRITE,
- 'extensions'
- )
-
- const { data } = useDatabaseExtensionsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const pgmqExtension = (data ?? []).find((ext) => ext.name === 'pgmq')
-
- if (!pgmqExtension) return null
-
- return (
- <>
- <div className="w-full h-full flex items-center justify-center">
- <ProductEmptyState title="Queues">
- <div className="text-sm text-foreground-light mb-4 grid gap-2">
- <p>
- Message queues in PostgreSQL allow you to handle asynchronous tasks, manage workloads,
- and enable reliable communication between different parts of your application.
- </p>
- <p>Enable queues in your project.</p>
- </div>
-
- <div className="flex items-center gap-3 mt-4">
- <Tooltip.Root delayDuration={0}>
- <Tooltip.Trigger asChild>
- <Button type="primary" onClick={() => setShowEnableExtensionModal(true)}>
- Enable Queues
- </Button>
- </Tooltip.Trigger>
- {!canToggleExtensions && (
- <Tooltip.Portal>
- <Tooltip.Content side="bottom">
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'rounded bg-alternative py-1 px-2 leading-none shadow',
- 'border border-background',
- ].join(' ')}
- >
- <span className="text-xs text-foreground">
- You need additional permissions to enable pgmq for this project
- </span>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- )}
- </Tooltip.Root>
- <DocsButton href="https://supabase.com/docs/guides/database/extensions/pgmq" />
- </div>
- </ProductEmptyState>
- </div>
-
- <EnableExtensionModal
- visible={showEnableExtensionModal}
- extension={pgmqExtension}
- onCancel={() => setShowEnableExtensionModal(false)}
- />
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/QueuesRows.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/QueuesRows.tsx
deleted file mode 100644
index ca79a1a42d5..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/QueuesRows.tsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import dayjs from 'dayjs'
-import { includes, sortBy } from 'lodash'
-import { ChevronRight, Loader2 } from 'lucide-react'
-import { useRouter } from 'next/router'
-
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import Table from 'components/to-be-cleaned/Table'
-import { useQueuesMetricsQuery } from 'data/database-queues/database-queues-metrics-query'
-import { PostgresQueue } from 'data/database-queues/database-queues-query'
-import { DATETIME_FORMAT } from 'lib/constants'
-
-interface QueuesRowsProps {
- queues: PostgresQueue[]
- filterString: string
-}
-
-const QueueRow = ({ queue }: { queue: PostgresQueue }) => {
- const router = useRouter()
- const { project: selectedProject } = useProjectContext()
-
- const { data: metrics, isLoading } = useQueuesMetricsQuery(
- {
- queueName: queue.queue_name,
- projectRef: selectedProject?.ref,
- connectionString: selectedProject?.connectionString,
- },
- {
- staleTime: 30 * 1000, // 30 seconds, talk with Oli whether this is ok to call every minute
- }
- )
-
- const type = queue.is_partitioned ? 'Partitioned' : queue.is_unlogged ? 'Unlogged' : 'Basic'
-
- return (
- <Table.tr
- key={queue.queue_name}
- onClick={() => {
- router.push(
- `/project/${selectedProject?.ref}/integrations/queues/queues/${queue.queue_name}`
- )
- }}
- >
- <Table.td className="truncate">
- <p title={queue.queue_name}>{queue.queue_name}</p>
- </Table.td>
- <Table.td className="table-cell overflow-auto">
- <p title={type.toLocaleLowerCase()} className="truncate">
- {type}
- </p>
- </Table.td>
- <Table.td className="table-cell">
- <p title={queue.created_at}>{dayjs(queue.created_at).format(DATETIME_FORMAT)}</p>
- </Table.td>
- <Table.td className="table-cell">
- <div className="flex justify-center">
- {isLoading ? (
- <Loader2 className="animate-spin" size={16} />
- ) : (
- <p>
- {metrics?.queue_length} {metrics?.method === 'estimated' ? '(Approximate)' : null}
- </p>
- )}
- </div>
- </Table.td>
- <Table.td>
- <div className="flex items-center justify-end">
- <ChevronRight size="18" />
- </div>
- </Table.td>
- </Table.tr>
- )
-}
-
-export const QueuesRows = ({ queues: fetchedQueues, filterString }: QueuesRowsProps) => {
- const filteredQueues = fetchedQueues.filter((x) =>
- includes(x.queue_name.toLowerCase(), filterString.toLowerCase())
- )
- const queues = sortBy(filteredQueues, (func) => func.queue_name.toLocaleLowerCase())
-
- if (queues.length === 0 && filterString.length > 0) {
- return (
- <Table.tr>
- <Table.td colSpan={5}>
- <p className="text-sm text-foreground">No results found</p>
- <p className="text-sm text-foreground-light">
- Your search for "{filterString}" did not return any results
- </p>
- </Table.td>
- </Table.tr>
- )
- }
-
- return (
- <>
- {queues.map((q) => (
- <QueueRow key={q.queue_name} queue={q} />
- ))}
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/DeleteQueue.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/DeleteQueue.tsx
deleted file mode 100644
index 20c9e6812f8..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/DeleteQueue.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { useRouter } from 'next/router'
-import { toast } from 'sonner'
-
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { useDatabaseQueueDeleteMutation } from 'data/database-queues/database-queues-delete-mutation'
-import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
-
-interface DeleteQueueProps {
- queueName: string
- visible: boolean
- onClose: () => void
-}
-
-const DeleteQueue = ({ queueName, visible, onClose }: DeleteQueueProps) => {
- const { project } = useProjectContext()
- const router = useRouter()
-
- const { mutate: deleteDatabaseQueue, isLoading } = useDatabaseQueueDeleteMutation({
- onSuccess: () => {
- toast.success(`Successfully removed queue ${queueName}`)
- router.push(`/project/${project?.ref}/integrations/queues`)
- onClose()
- },
- })
-
- async function handleDelete() {
- if (!project) return console.error('Project is required')
-
- deleteDatabaseQueue({
- queueName: queueName,
- projectRef: project.ref,
- connectionString: project.connectionString,
- })
- }
-
- if (!queueName) {
- return null
- }
-
- return (
- <TextConfirmModal
- variant="destructive"
- visible={visible}
- onCancel={() => onClose()}
- onConfirm={handleDelete}
- title="Delete this queue"
- loading={isLoading}
- confirmLabel={`Delete queue ${queueName}`}
- confirmPlaceholder="Type in name of queue"
- confirmString={queueName ?? 'Unknown'}
- text={
- <>
- <span>This will delete the queue</span>{' '}
- <span className="text-bold text-foreground">{queueName}</span>
- </>
- }
- alert={{ title: 'You cannot recover this queue and its messages once deleted.' }}
- />
- )
-}
-
-export default DeleteQueue
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/MessageDetailsPanel.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/MessageDetailsPanel.tsx
deleted file mode 100644
index a2c6ead53aa..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/MessageDetailsPanel.tsx
+++ /dev/null
@@ -1,224 +0,0 @@
-import { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown'
-import { isNil, noop } from 'lodash'
-import { Archive, Clock12, Trash2, X } from 'lucide-react'
-import { useState } from 'react'
-
-import { useParams } from 'common'
-import { MonacoEditor } from 'components/grid/components/common/MonacoEditor'
-import { RowAction, RowData } from 'components/interfaces/Auth/Users/UserOverview'
-import { useDatabaseQueueMessageArchiveMutation } from 'data/database-queues/database-queue-messages-archive-mutation'
-import { useDatabaseQueueMessageDeleteMutation } from 'data/database-queues/database-queue-messages-delete-mutation'
-import { PostgresQueueMessage } from 'data/database-queues/database-queue-messages-infinite-query'
-import { useDatabaseQueueMessageReadMutation } from 'data/database-queues/database-queue-messages-read-mutation'
-import dayjs from 'dayjs'
-import { useSelectedProject } from 'hooks/misc/useSelectedProject'
-import { prettifyJSON } from 'lib/helpers'
-import {
- Button,
- ResizablePanel,
- Separator,
- Tabs_Shadcn_,
- TabsContent_Shadcn_,
- TabsList_Shadcn_,
- TabsTrigger_Shadcn_,
-} from 'ui'
-
-export const DATE_FORMAT = 'DD MMM, YYYY HH:mm'
-
-interface MessageDetailsPanelProps {
- selectedMessage: PostgresQueueMessage
- setSelectedMessage: (value: number | null) => void
-}
-
-const tryFormatInitialValue = (value: string) => {
- try {
- const jsonValue = JSON.parse(value)
- return JSON.stringify(jsonValue)
- } catch (err) {
- if (typeof value === 'string') {
- return value.replaceAll(`\"`, `"`)
- } else {
- return JSON.stringify(value)
- }
- }
-}
-
-export const MessageDetailsPanel = ({
- selectedMessage,
- setSelectedMessage,
-}: MessageDetailsPanelProps) => {
- const { id: _id } = useParams()
- const { childId: queueName } = useParams()
- const project = useSelectedProject()
-
- useEscapeKeydown(() => setSelectedMessage(null))
-
- const {
- mutate: archiveMessage,
- isLoading: isLoadingArchive,
- isSuccess: isSuccessArchive,
- } = useDatabaseQueueMessageArchiveMutation()
-
- const {
- mutate: readMessage,
- isLoading: isLoadingRead,
- isSuccess: isSuccessRead,
- } = useDatabaseQueueMessageReadMutation()
-
- const {
- mutate: deleteMessage,
- isLoading: isLoadingDelete,
- isSuccess: isSuccessDelete,
- } = useDatabaseQueueMessageDeleteMutation()
-
- const initialValue = JSON.stringify(selectedMessage?.message)
- const jsonString = prettifyJSON(!isNil(initialValue) ? tryFormatInitialValue(initialValue) : '')
-
- const [view, setView] = useState<'details' | 'suggestion'>('details')
-
- return (
- <ResizablePanel
- defaultSize={30}
- maxSize={45}
- minSize={30}
- collapsible
- onCollapse={() => setSelectedMessage(null)}
- className="bg-studio border-t pointer-events-auto"
- >
- <Button
- type="text"
- className="absolute top-3 right-3 px-1"
- icon={<X />}
- onClick={() => setSelectedMessage(null)}
- />
-
- <Tabs_Shadcn_
- value={view}
- className="flex flex-col h-full"
- onValueChange={(value: any) => {
- setView(value)
- }}
- >
- <TabsList_Shadcn_ className="px-5 flex gap-x-4 min-h-[46px]">
- <TabsTrigger_Shadcn_
- value="details"
- className="px-0 pb-0 h-full text-xs data-[state=active]:bg-transparent !shadow-none"
- >
- Overview
- </TabsTrigger_Shadcn_>
- </TabsList_Shadcn_>
- <TabsContent_Shadcn_ value="details" className="w-full mt-0 overflow-y-auto grow">
- <div className="flex flex-col px-4 py-4 text-sm">
- <RowData property="Message ID" value={`${selectedMessage.msg_id}`} />
- <RowData
- property="Added at"
- value={dayjs(selectedMessage.enqueued_at).format(DATE_FORMAT)}
- />
- <RowData
- property="Available at"
- value={dayjs(selectedMessage.vt).format(DATE_FORMAT)}
- />
- <RowData property="Retries" value={`${selectedMessage.read_ct}`} />
-
- <div>
- <h3 className="text-foreground-light py-1">Payload</h3>
- <MonacoEditor
- key={selectedMessage.msg_id}
- onChange={noop}
- width="100%"
- value={jsonString || 'NULL'}
- language="json"
- readOnly
- />
- </div>
- </div>
- <Separator />
- <div className="flex flex-col px-4 py-4 -space-y-1">
- {!selectedMessage.archived_at ? (
- <>
- <RowAction
- title="Postpone message"
- description="The message will be postponed and won't show up in reads for 60 seconds."
- button={{
- icon: <Clock12 />,
- text: 'Postpone',
- isLoading: isLoadingRead,
- onClick: () => {
- readMessage({
- projectRef: project!.ref,
- connectionString: project?.connectionString,
- queryName: queueName!,
- messageId: selectedMessage.msg_id,
- duration: 60,
- })
- },
- }}
- success={
- isSuccessRead
- ? {
- title: 'Postponed',
- description: 'The message was postponed for 60 seconds.',
- }
- : undefined
- }
- />
- <RowAction
- title="Archive message"
- description="The message will be marked as archived and hidden from future reads by consumers. You can still access the message later."
- button={{
- icon: <Archive />,
- text: 'Archive',
- isLoading: isLoadingArchive,
- type: 'warning',
- onClick: () => {
- archiveMessage({
- projectRef: project!.ref,
- connectionString: project?.connectionString,
- queryName: queueName!,
- messageId: selectedMessage.msg_id,
- })
- },
- }}
- success={
- isSuccessArchive
- ? {
- title: 'Archived',
- description: 'The message was archived successfully.',
- }
- : undefined
- }
- />
- <RowAction
- title="Delete message"
- description="The message cannot be recovered afterwards."
- button={{
- icon: <Trash2 />,
- text: 'Delete',
- type: 'danger',
- isLoading: isLoadingDelete,
- onClick: () => {
- deleteMessage({
- projectRef: project!.ref,
- connectionString: project?.connectionString,
- queueName: queueName!,
- messageId: selectedMessage.msg_id,
- })
- },
- }}
- success={
- isSuccessDelete
- ? {
- title: 'Deleted',
- description: 'The message was deleted successfully.',
- }
- : undefined
- }
- />
- </>
- ) : null}
- </div>
- </TabsContent_Shadcn_>
- </Tabs_Shadcn_>
- </ResizablePanel>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/PurgeQueue.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/PurgeQueue.tsx
deleted file mode 100644
index 5743748e97a..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/PurgeQueue.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { useRouter } from 'next/router'
-import { toast } from 'sonner'
-
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { useDatabaseQueuePurgeMutation } from 'data/database-queues/database-queues-purge-mutation'
-import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
-
-interface PurgeQueueProps {
- queueName: string
- visible: boolean
- onClose: () => void
-}
-
-const PurgeQueue = ({ queueName, visible, onClose }: PurgeQueueProps) => {
- const { project } = useProjectContext()
- const router = useRouter()
-
- const { mutate: purgeDatabaseQueue, isLoading } = useDatabaseQueuePurgeMutation({
- onSuccess: () => {
- toast.success(`Successfully purged queue ${queueName}`)
- router.push(`/project/${project?.ref}/integrations/queues`)
- onClose()
- },
- })
-
- async function handlePurge() {
- if (!project) return console.error('Project is required')
-
- purgeDatabaseQueue({
- queueName: queueName,
- projectRef: project.ref,
- connectionString: project.connectionString,
- })
- }
-
- if (!queueName) {
- return null
- }
-
- return (
- <TextConfirmModal
- variant="warning"
- visible={visible}
- onCancel={() => onClose()}
- onConfirm={handlePurge}
- title="Purge this queue"
- loading={isLoading}
- confirmLabel={`Purge queue ${queueName}`}
- confirmPlaceholder="Type in name of queue"
- confirmString={queueName ?? 'Unknown'}
- text={
- <>
- <span>This will purge the queue</span>{' '}
- <span className="text-bold text-foreground">{queueName}</span>
- </>
- }
- alert={{
- title:
- "This action will delete all messages from the queue. They can't be recovered afterwards.",
- }}
- />
- )
-}
-
-export default PurgeQueue
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/Queue.utils.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/Queue.utils.tsx
deleted file mode 100644
index 3f72dc4ede4..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/Queue.utils.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import { capitalize } from 'lodash'
-
-export const QUEUE_MESSAGE_TYPES = ['archived', 'available', 'scheduled'] as const
-export type QUEUE_MESSAGE_TYPE = (typeof QUEUE_MESSAGE_TYPES)[number]
-
-export const QUEUE_MESSAGE_OPTIONS = QUEUE_MESSAGE_TYPES.map((type) => ({
- id: type,
- name: capitalize(type),
-}))
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/QueueDataGrid.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/QueueDataGrid.tsx
deleted file mode 100644
index c77211a1c7f..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/QueueDataGrid.tsx
+++ /dev/null
@@ -1,219 +0,0 @@
-import dayjs from 'dayjs'
-import { TextSearch } from 'lucide-react'
-import { useRouter } from 'next/router'
-import { parseAsInteger, useQueryState } from 'nuqs'
-import { UIEvent, useMemo, useRef } from 'react'
-import DataGrid, { Column, DataGridHandle, Row } from 'react-data-grid'
-
-import { PostgresQueueMessage } from 'data/database-queues/database-queue-messages-infinite-query'
-import { Badge, Button, ResizableHandle, ResizablePanel, ResizablePanelGroup, cn } from 'ui'
-import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
-import { DATE_FORMAT, MessageDetailsPanel } from './MessageDetailsPanel'
-
-interface QueueDataGridProps {
- isLoading: boolean
- messages: PostgresQueueMessage[]
- showMessageModal: () => void
- fetchNextPage: () => void
-}
-
-function isAtBottom({ currentTarget }: UIEvent<HTMLDivElement>): boolean {
- return currentTarget.scrollTop + 10 >= currentTarget.scrollHeight - currentTarget.clientHeight
-}
-
-const messagesCols = [
- {
- id: 'id',
- name: 'ID',
- description: undefined,
- minWidth: 50,
- width: 70,
- value: (row: PostgresQueueMessage) => (
- <div className="flex items-center gap-1.5">
- <h3 className="text-xs">{row.msg_id}</h3>
- </div>
- ),
- },
- {
- id: 'enqueued_at',
- name: 'Added at',
- description: undefined,
- minWidth: 160,
- width: 180,
- value: (row: PostgresQueueMessage) => (
- <div className="flex items-center gap-1 text-xs">
- {dayjs(row.enqueued_at).format(DATE_FORMAT)}
- </div>
- ),
- },
- {
- id: 'status',
- name: 'Status',
- description: undefined,
- minWidth: 280,
- width: 300,
- value: (row: PostgresQueueMessage) => {
- const isAvailable = new Date() > new Date(row.vt)
-
- if (row.archived_at) {
- return (
- <Badge variant="default">Archived at {dayjs(row.archived_at).format(DATE_FORMAT)}</Badge>
- )
- }
-
- return (
- <Badge variant={isAvailable ? 'brand' : 'warning'}>
- {isAvailable ? 'Available ' : `Available at ${dayjs(row.vt).format(DATE_FORMAT)}`}
- </Badge>
- )
- },
- },
- {
- id: 'retries',
- name: 'Retries',
- description: undefined,
- minWidth: 50,
- width: 70,
- value: (row: PostgresQueueMessage) => <span>{row.read_ct}</span>,
- },
- {
- id: 'payload',
- name: 'Payload',
- description: undefined,
- minWidth: 600,
- value: (row: PostgresQueueMessage) => <span>{JSON.stringify(row.message)}</span>,
- },
-]
-
-const columns = messagesCols.map((col) => {
- const result: Column<PostgresQueueMessage> = {
- key: col.id,
- name: col.name,
- resizable: true,
- minWidth: col.minWidth ?? 120,
- width: col.width,
- headerCellClass: 'first:pl-6 cursor-pointer',
- renderHeaderCell: () => {
- return (
- <div className="flex items-center justify-between font-normal text-xs w-full">
- <div className="flex items-center gap-x-2">
- <p className="!text-foreground">{col.name}</p>
- {col.description && <p className="text-foreground-lighter">{col.description}</p>}
- </div>
- </div>
- )
- },
- renderCell: (props) => {
- const value = col.value(props.row)
-
- return (
- <div
- className={cn(
- 'w-full flex flex-col justify-center font-mono text-xs',
- typeof value === 'number' ? 'text-right' : ''
- )}
- >
- <span>{value}</span>
- </div>
- )
- },
- }
- return result
-})
-
-export const QueueMessagesDataGrid = ({
- isLoading,
- messages,
- showMessageModal,
- fetchNextPage,
-}: QueueDataGridProps) => {
- const gridRef = useRef<DataGridHandle>(null)
- const router = useRouter()
-
- const [selectedMessageId, setSelectedMessageId] = useQueryState('id', parseAsInteger)
-
- const handleScroll = (event: UIEvent<HTMLDivElement>) => {
- if (isLoading || !isAtBottom(event)) return
- fetchNextPage()
- }
-
- const selectedMessage = useMemo(
- () => messages.find((m) => m.msg_id === selectedMessageId),
- [messages, selectedMessageId]
- )
-
- return (
- <div className="relative h-full">
- <DataGrid
- ref={gridRef}
- className="h-full"
- rowHeight={44}
- headerRowHeight={36}
- columns={columns}
- onScroll={handleScroll}
- rows={messages}
- rowClass={(message) => {
- const isSelected = message.msg_id === selectedMessageId
- return [
- `${isSelected ? 'bg-surface-300 dark:bg-surface-300' : 'bg-200'} cursor-pointer`,
- `${isSelected ? '[&>div:first-child]:border-l-4 border-l-secondary [&>div]:border-l-foreground' : ''}`,
- '[&>.rdg-cell]:border-box [&>.rdg-cell]:outline-none [&>.rdg-cell]:shadow-none',
- '[&>.rdg-cell:first-child>div]:ml-4',
- ].join(' ')
- }}
- renderers={{
- renderRow(idx, props) {
- return (
- <Row
- key={props.row.msg_id}
- {...props}
- onClick={() => {
- if (typeof idx === 'number' && idx >= 0) {
- setSelectedMessageId(props.row.msg_id)
- gridRef.current?.scrollToCell({ idx: 0, rowIdx: idx })
- const { id, ...rest } = router.query
- router.push({ ...router, query: { ...rest, id: props.row.msg_id } })
- }
- }}
- />
- )
- },
- noRowsFallback: isLoading ? (
- <div className="absolute top-14 px-6 w-full">
- <GenericSkeletonLoader />
- </div>
- ) : (
- <div className="absolute top-28 px-6 flex flex-col items-center justify-center w-full gap-y-2">
- <TextSearch className="text-foreground-muted" strokeWidth={1} />
- <div className="text-center">
- <p className="text-foreground">No messages found</p>
- <p className="text-foreground-light">
- The selected queue doesn't have any messages.
- </p>
- <Button className="mt-2" onClick={() => showMessageModal()}>
- Add message
- </Button>
- </div>
- </div>
- ),
- }}
- />
- <ResizablePanelGroup
- direction="horizontal"
- className="absolute inset-0 z-10 pointer-events-none"
- autoSaveId="queue-messages-layout-v1"
- >
- <ResizablePanel defaultSize={1} />
- {selectedMessage && (
- <>
- <ResizableHandle withHandle className="pointer-events-auto" />
- <MessageDetailsPanel
- selectedMessage={selectedMessage}
- setSelectedMessage={setSelectedMessageId}
- />
- </>
- )}
- </ResizablePanelGroup>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/QueueFilters.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/QueueFilters.tsx
deleted file mode 100644
index 2fd77da9157..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/QueueFilters.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { FilterPopover } from 'components/ui/FilterPopover'
-import { QUEUE_MESSAGE_OPTIONS, QUEUE_MESSAGE_TYPE } from './Queue.utils'
-
-interface QueueFiltersProps {
- selectedTypes: QUEUE_MESSAGE_TYPE[]
- setSelectedTypes: (value: QUEUE_MESSAGE_TYPE[]) => void
-}
-
-export const QueueFilters = ({ selectedTypes, setSelectedTypes }: QueueFiltersProps) => {
- return (
- <div className="bg-surface-200 py-3 px-6 flex items-center justify-between border-t">
- <div className="flex items-center gap-x-2">
- <FilterPopover
- name={selectedTypes.length === 0 ? 'All types' : 'Types'}
- title="Select types to show"
- buttonType={selectedTypes.length === 0 ? 'dashed' : 'default'}
- options={QUEUE_MESSAGE_OPTIONS} // Ignore user image column
- labelKey="name"
- valueKey="id"
- labelClass="text-xs"
- maxHeightClass="h-[190px]"
- clearButtonText="Reset"
- activeOptions={selectedTypes}
- onSaveFilters={(value) => setSelectedTypes(value as any)}
- />
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/SendMessageModal.tsx b/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/SendMessageModal.tsx
deleted file mode 100644
index af38654151a..00000000000
--- a/apps/studio/components/interfaces/Integrations/NewQueues/SingleQueue/SendMessageModal.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-import { zodResolver } from '@hookform/resolvers/zod'
-import { SubmitHandler, useForm } from 'react-hook-form'
-import z from 'zod'
-
-import { useParams } from 'common'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import CodeEditor from 'components/ui/CodeEditor/CodeEditor'
-import { useDatabaseQueueMessageSendMutation } from 'data/database-queues/database-queue-messages-send-mutation'
-import { useEffect } from 'react'
-import { toast } from 'sonner'
-import { Form_Shadcn_, FormControl_Shadcn_, FormField_Shadcn_, Input, Modal } from 'ui'
-import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
-
-interface SendMessageModalProps {
- visible: boolean
- onClose: () => void
-}
-
-const FormSchema = z.object({
- delay: z.coerce.number().int().gte(0).default(5),
- payload: z.string().refine(
- (val) => {
- try {
- JSON.parse(val)
- } catch {
- return false
- }
- },
- {
- message: 'The payload should be a JSON object',
- }
- ),
-})
-
-export type SendMessageForm = z.infer<typeof FormSchema>
-
-const FORM_ID = 'QUEUES_SEND_MESSAGE_FORM'
-
-export const SendMessageModal = ({ visible, onClose }: SendMessageModalProps) => {
- const { childId: queueName } = useParams()
- const { project } = useProjectContext()
- const form = useForm<SendMessageForm>({
- resolver: zodResolver(FormSchema),
- defaultValues: {
- delay: 1,
- payload: '{}',
- },
- })
-
- const { isLoading, mutate } = useDatabaseQueueMessageSendMutation({
- onSuccess: () => {
- toast.success(`Successfully added a message to the queue.`)
- onClose()
- },
- })
-
- const onSubmit: SubmitHandler<SendMessageForm> = (values) => {
- mutate({
- projectRef: project?.ref!,
- connectionString: project?.connectionString,
- queueName: queueName!,
- payload: values.payload,
- delay: values.delay,
- })
- }
-
- useEffect(() => {
- if (visible) {
- form.reset({ delay: 1, payload: '{}' })
- }
- }, [visible])
-
- return (
- <Modal
- size="medium"
- alignFooter="right"
- header="Add a message to the queue"
- visible={visible}
- loading={isLoading}
- onCancel={onClose}
- confirmText="Add"
- onConfirm={() => {
- const values = form.getValues()
- onSubmit(values)
- }}
- >
- <Modal.Content className="flex flex-col gap-y-4">
- <Form_Shadcn_ {...form}>
- <form
- id={FORM_ID}
- className="flex-grow overflow-auto gap-2 flex flex-col"
- onSubmit={form.handleSubmit(onSubmit)}
- >
- <FormField_Shadcn_
- control={form.control}
- name="delay"
- render={({ field: { ref, ...rest } }) => (
- <FormItemLayout
- label="Delay"
- layout="vertical"
- className="gap-1"
- description="Time in seconds before the message becomes available for reading."
- >
- <FormControl_Shadcn_>
- <Input
- {...rest}
- type="number"
- placeholder="1"
- actions={<p className="text-foreground-light pr-2">sec</p>}
- />
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
- <FormField_Shadcn_
- control={form.control}
- name="payload"
- render={({ field }) => (
- <FormItemLayout label="Message payload" layout="vertical" className="gap-1">
- <FormControl_Shadcn_>
- <CodeEditor
- id="message-payload"
- language="json"
- className="!mb-0 h-32 overflow-hidden rounded border"
- onInputChange={(e: string | undefined) => field.onChange(e)}
- options={{ wordWrap: 'off', contextmenu: false }}
- value={field.value}
- />
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
- </form>
- </Form_Shadcn_>
- </Modal.Content>
- </Modal>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet.tsx b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet.tsx
index 41622dc9eea..9cefe7df052 100644
--- a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet.tsx
+++ b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet.tsx
@@ -1,15 +1,11 @@
import { zodResolver } from '@hookform/resolvers/zod'
-import { useState } from 'react'
import { SubmitHandler, useForm } from 'react-hook-form'
import { toast } from 'sonner'
import z from 'zod'
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import EnableExtensionModal from 'components/interfaces/Database/Extensions/EnableExtensionModal'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
import { useDatabaseQueueCreateMutation } from 'data/database-queues/database-queues-create-mutation'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import {
Badge,
Button,
@@ -37,7 +33,7 @@ export interface CreateQueueSheetProps {
}
const normalQueueSchema = z.object({
- type: z.literal('normal'),
+ type: z.literal('basic'),
})
const partitionedQueueSchema = z.object({
@@ -69,20 +65,21 @@ export type QueueType = CreateQueueForm['values']
const FORM_ID = 'create-queue-sidepanel'
export const CreateQueueSheet = ({ isClosing, setIsClosing, onClose }: CreateQueueSheetProps) => {
- const [showEnableExtensionModal, setShowEnableExtensionModal] = useState(false)
+ // This is for enabling pg_partman extension which will be used for partitioned queues (3rd kind of queue)
+ // const [showEnableExtensionModal, setShowEnableExtensionModal] = useState(false)
const { mutate: createQueue, isLoading } = useDatabaseQueueCreateMutation()
- const canToggleExtensions = useCheckPermissions(
- PermissionAction.TENANT_SQL_ADMIN_WRITE,
- 'extensions'
- )
+ // const canToggleExtensions = useCheckPermissions(
+ // PermissionAction.TENANT_SQL_ADMIN_WRITE,
+ // 'extensions'
+ // )
const form = useForm<CreateQueueForm>({
resolver: zodResolver(FormSchema),
defaultValues: {
name: '',
values: {
- type: 'normal',
+ type: 'basic',
},
},
})
@@ -329,13 +326,13 @@ export const CreateQueueSheet = ({ isClosing, setIsClosing, onClose }: CreateQue
lost.
</p>
</ConfirmationModal>
- {pgPartmanExtension && (
+ {/* {pgPartmanExtension && (
<EnableExtensionModal
visible={showEnableExtensionModal}
extension={pgPartmanExtension}
onCancel={() => setShowEnableExtensionModal(false)}
/>
- )}
+ )} */}
</>
)
}
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/QueueTab.tsx b/apps/studio/components/interfaces/Integrations/Queues/QueueTab.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Integrations/NewQueues/QueueTab.tsx
rename to apps/studio/components/interfaces/Integrations/Queues/QueueTab.tsx
diff --git a/apps/studio/components/interfaces/Integrations/Queues/QueuesDisabledState.tsx b/apps/studio/components/interfaces/Integrations/Queues/QueuesDisabledState.tsx
deleted file mode 100644
index 5de88c73820..00000000000
--- a/apps/studio/components/interfaces/Integrations/Queues/QueuesDisabledState.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import * as Tooltip from '@radix-ui/react-tooltip'
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useState } from 'react'
-
-import EnableExtensionModal from 'components/interfaces/Database/Extensions/EnableExtensionModal'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'
-import { DocsButton } from 'components/ui/DocsButton'
-import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { Button } from 'ui'
-
-export const QueuesDisabledState = () => {
- const [showEnableExtensionModal, setShowEnableExtensionModal] = useState(false)
- const { project } = useProjectContext()
- const canToggleExtensions = useCheckPermissions(
- PermissionAction.TENANT_SQL_ADMIN_WRITE,
- 'extensions'
- )
-
- const { data } = useDatabaseExtensionsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const pgmqExtension = (data ?? []).find((ext) => ext.name === 'pgmq')
-
- if (!pgmqExtension) return null
-
- return (
- <>
- <div className="w-full h-full flex items-center justify-center">
- <ProductEmptyState title="Queues">
- <div className="text-sm text-foreground-light mb-4 grid gap-2">
- <p>
- Message queues in PostgreSQL allow you to handle asynchronous tasks, manage workloads,
- and enable reliable communication between different parts of your application.
- </p>
- <p>Enable queues in your project.</p>
- </div>
-
- <div className="flex items-center gap-3 mt-4">
- <Tooltip.Root delayDuration={0}>
- <Tooltip.Trigger asChild>
- <Button type="primary" onClick={() => setShowEnableExtensionModal(true)}>
- Enable Queues
- </Button>
- </Tooltip.Trigger>
- {!canToggleExtensions && (
- <Tooltip.Portal>
- <Tooltip.Content side="bottom">
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'rounded bg-alternative py-1 px-2 leading-none shadow',
- 'border border-background',
- ].join(' ')}
- >
- <span className="text-xs text-foreground">
- You need additional permissions to enable pgmq for this project
- </span>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- )}
- </Tooltip.Root>
- <DocsButton href="https://supabase.com/docs/guides/database/extensions/pgmq" />
- </div>
- </ProductEmptyState>
- </div>
-
- <EnableExtensionModal
- visible={showEnableExtensionModal}
- extension={pgmqExtension}
- onCancel={() => setShowEnableExtensionModal(false)}
- />
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/Queues/QueuesListing.tsx b/apps/studio/components/interfaces/Integrations/Queues/QueuesListing.tsx
deleted file mode 100644
index eba0a0779b3..00000000000
--- a/apps/studio/components/interfaces/Integrations/Queues/QueuesListing.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import { useEffect, useState } from 'react'
-
-import EnableExtensionModal from 'components/interfaces/Database/Extensions/EnableExtensionModal'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import Table from 'components/to-be-cleaned/Table'
-import AlertError from 'components/ui/AlertError'
-import { FormHeader } from 'components/ui/Forms/FormHeader'
-import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
-import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
-import { useQueuesQuery } from 'data/database-queues/database-queues-query'
-import { Search } from 'lucide-react'
-import { useQueryState } from 'nuqs'
-import { Button, Input, Sheet, SheetContent } from 'ui'
-import { CreateQueueSheet } from './CreateQueueSheet'
-import { QueuesDisabledState } from './QueuesDisabledState'
-import { QueuesRows } from './QueuesRows'
-
-export const QueuesListing = () => {
- const { project } = useProjectContext()
-
- const [showEnableExtensionModal, setShowEnableExtensionModal] = useState(false)
- // used for confirmation prompt in the Create Queue Sheet
- const [isClosingCreateQueueSheet, setIsClosingCreateQueueSheet] = useState(false)
- const [createQueueSheetShown, setCreateQueueSheetShown] = useState(false)
-
- const {
- data: queues,
- error,
- isLoading,
- isError,
- refetch,
- } = useQueuesQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const { data: extensions, isLoading: isLoadingExtensions } = useDatabaseExtensionsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
-
- const pgmqExtension = (extensions ?? []).find((ext) => ext.name === 'pgmq')
- // TODO: Change this to true for local development to work
- const pgmqExtensionInstalled = pgmqExtension?.installed_version
-
- useEffect(() => {
- // refetch the queues after the pgmq extension has been installed
- if (pgmqExtensionInstalled && isError) {
- refetch()
- }
- }, [isError, pgmqExtensionInstalled, refetch])
-
- const [searchQuery, setSearchQuery] = useQueryState('search')
-
- // this avoid showing loading screen when the extension is not installed. Otherwise, we'll have to wait for three
- // retries (which are sure to fail because the extension is not installed)
- if (isLoadingExtensions) return <GenericSkeletonLoader />
- if (!pgmqExtensionInstalled) return <QueuesDisabledState />
- if (isLoading) return <GenericSkeletonLoader />
- if (isError) return <AlertError error={error} subject="Failed to retrieve database queues" />
-
- return (
- <>
- <div className="w-full space-y-4">
- <FormHeader
- title="Queues"
- description="Use message queues to handle asynchronous tasks, manage workloads, and enable reliable communication between different parts of your application."
- />
- {queues.length === 0 ? (
- <div
- className={
- 'border rounded border-default px-20 py-16 flex flex-col items-center justify-center space-y-4 border-dashed'
- }
- >
- <p className="text-sm text-foreground">No queues created yet</p>
- <Button onClick={() => setCreateQueueSheetShown(true)}>Add a new queue</Button>
- </div>
- ) : (
- <div className="w-full space-y-4">
- <div className="flex items-center justify-between flex-wrap">
- <Input
- placeholder="Search for a queue"
- size="small"
- icon={<Search size={14} />}
- value={searchQuery || ''}
- className="w-64"
- onChange={(e) => setSearchQuery(e.target.value)}
- />
-
- <Button onClick={() => setCreateQueueSheetShown(true)}>Create a queue</Button>
- </div>
-
- <Table
- className="table-fixed overflow-x-auto"
- head={
- <>
- <Table.th key="name">Name</Table.th>
- <Table.th key="arguments" className="table-cell">
- Type
- </Table.th>
- <Table.th key="created_at" className="table-cell w-60">
- Created at
- </Table.th>
- <Table.th key="queue_size" className="table-cell">
- <div className="flex justify-center">Size</div>
- </Table.th>
- <Table.th key="buttons" className="table-cell"></Table.th>
- </>
- }
- body={<QueuesRows queues={queues} filterString={searchQuery || ''} />}
- />
- </div>
- )}
- </div>
-
- <Sheet open={createQueueSheetShown} onOpenChange={() => setIsClosingCreateQueueSheet(true)}>
- <SheetContent size="default" tabIndex={undefined}>
- <CreateQueueSheet
- onClose={() => {
- setIsClosingCreateQueueSheet(false)
- setCreateQueueSheetShown(false)
- }}
- isClosing={isClosingCreateQueueSheet}
- setIsClosing={setIsClosingCreateQueueSheet}
- />
- </SheetContent>
- </Sheet>
- {pgmqExtension ? (
- <EnableExtensionModal
- visible={showEnableExtensionModal}
- extension={pgmqExtension}
- onCancel={() => setShowEnableExtensionModal(false)}
- />
- ) : null}
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/Queues/QueuesRows.tsx b/apps/studio/components/interfaces/Integrations/Queues/QueuesRows.tsx
index ae44319e115..ca79a1a42d5 100644
--- a/apps/studio/components/interfaces/Integrations/Queues/QueuesRows.tsx
+++ b/apps/studio/components/interfaces/Integrations/Queues/QueuesRows.tsx
@@ -35,7 +35,9 @@ const QueueRow = ({ queue }: { queue: PostgresQueue }) => {
<Table.tr
key={queue.queue_name}
onClick={() => {
- router.push(`/project/${selectedProject?.ref}/integrations/queues/${queue.queue_name}`)
+ router.push(
+ `/project/${selectedProject?.ref}/integrations/queues/queues/${queue.queue_name}`
+ )
}}
>
<Table.td className="truncate">
diff --git a/apps/studio/components/interfaces/Integrations/NewQueues/QueuesTab.tsx b/apps/studio/components/interfaces/Integrations/Queues/QueuesTab.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Integrations/NewQueues/QueuesTab.tsx
rename to apps/studio/components/interfaces/Integrations/Queues/QueuesTab.tsx
diff --git a/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeySelector.tsx b/apps/studio/components/interfaces/Integrations/Vault/Keys/EncryptionKeySelector.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeySelector.tsx
rename to apps/studio/components/interfaces/Integrations/Vault/Keys/EncryptionKeySelector.tsx
diff --git a/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx b/apps/studio/components/interfaces/Integrations/Vault/Keys/EncryptionKeysManagement.tsx
similarity index 99%
rename from apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx
rename to apps/studio/components/interfaces/Integrations/Vault/Keys/EncryptionKeysManagement.tsx
index 4a2e04fa20e..5d427bcac86 100644
--- a/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx
+++ b/apps/studio/components/interfaces/Integrations/Vault/Keys/EncryptionKeysManagement.tsx
@@ -18,7 +18,7 @@ import { Alert, Button, Form, Input, Listbox, Modal, Separator } from 'ui'
const DEFAULT_KEY_NAME = 'No description provided'
-const EncryptionKeysManagement = () => {
+export const EncryptionKeysManagement = () => {
const { search } = useParams()
const { project } = useProjectContext()
@@ -324,5 +324,3 @@ const EncryptionKeysManagement = () => {
</>
)
}
-
-export default EncryptionKeysManagement
diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsx b/apps/studio/components/interfaces/Integrations/Vault/Secrets/AddNewSecretModal.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsx
rename to apps/studio/components/interfaces/Integrations/Vault/Secrets/AddNewSecretModal.tsx
diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/DeleteSecretModal.tsx b/apps/studio/components/interfaces/Integrations/Vault/Secrets/DeleteSecretModal.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Settings/Vault/Secrets/DeleteSecretModal.tsx
rename to apps/studio/components/interfaces/Integrations/Vault/Secrets/DeleteSecretModal.tsx
diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx b/apps/studio/components/interfaces/Integrations/Vault/Secrets/EditSecretModal.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx
rename to apps/studio/components/interfaces/Integrations/Vault/Secrets/EditSecretModal.tsx
diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/SecretRow.tsx b/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretRow.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Settings/Vault/Secrets/SecretRow.tsx
rename to apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretRow.tsx
diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsx b/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretsManagement.tsx
similarity index 99%
rename from apps/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsx
rename to apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretsManagement.tsx
index f0fc8f56864..6988b6d20d4 100644
--- a/apps/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsx
+++ b/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretsManagement.tsx
@@ -16,7 +16,7 @@ import DeleteSecretModal from './DeleteSecretModal'
import EditSecretModal from './EditSecretModal'
import SecretRow from './SecretRow'
-const SecretsManagement = () => {
+export const SecretsManagement = () => {
const { search } = useParams()
const { project } = useProjectContext()
@@ -190,5 +190,3 @@ const SecretsManagement = () => {
</>
)
}
-
-export default SecretsManagement
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/CreateWrapperSheet.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/CreateWrapperSheet.tsx
index d755eb4cf28..376b7999c8f 100644
--- a/apps/studio/components/interfaces/Integrations/Wrappers/CreateWrapperSheet.tsx
+++ b/apps/studio/components/interfaces/Integrations/Wrappers/CreateWrapperSheet.tsx
@@ -4,16 +4,16 @@ import { Edit, Trash } from 'lucide-react'
import { useState } from 'react'
import { toast } from 'sonner'
-import InputField from 'components/interfaces/Database/Wrappers/InputField'
-import WrapperTableEditor from 'components/interfaces/Database/Wrappers/WrapperTableEditor'
-import { WrapperMeta } from 'components/interfaces/Database/Wrappers/Wrappers.types'
-import { makeValidateRequired } from 'components/interfaces/Database/Wrappers/Wrappers.utils'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'
import { invalidateSchemasQuery } from 'data/database/schemas-query'
import { useFDWCreateMutation } from 'data/fdw/fdw-create-mutation'
import { Button, Form, Input, SheetFooter, SheetHeader, SheetTitle } from 'ui'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
+import InputField from './InputField'
+import { WrapperMeta } from './Wrappers.types'
+import { makeValidateRequired } from './Wrappers.utils'
+import WrapperTableEditor from './WrapperTableEditor'
export interface CreateWrapperSheetProps {
isClosing: boolean
diff --git a/apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/DeleteWrapperModal.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsx
rename to apps/studio/components/interfaces/Integrations/Wrappers/DeleteWrapperModal.tsx
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/EditWrapperSheet.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/EditWrapperSheet.tsx
index b77ffb1e8a3..378a1395345 100644
--- a/apps/studio/components/interfaces/Integrations/Wrappers/EditWrapperSheet.tsx
+++ b/apps/studio/components/interfaces/Integrations/Wrappers/EditWrapperSheet.tsx
@@ -4,14 +4,6 @@ import { Edit, Trash } from 'lucide-react'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
-import InputField from 'components/interfaces/Database/Wrappers/InputField'
-import WrapperTableEditor from 'components/interfaces/Database/Wrappers/WrapperTableEditor'
-import { WrapperMeta } from 'components/interfaces/Database/Wrappers/Wrappers.types'
-import {
- convertKVStringArrayToJson,
- formatWrapperTables,
- makeValidateRequired,
-} from 'components/interfaces/Database/Wrappers/Wrappers.utils'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'
import { invalidateSchemasQuery } from 'data/database/schemas-query'
@@ -21,6 +13,14 @@ import { getDecryptedValue } from 'data/vault/vault-secret-decrypted-value-query
import { useVaultSecretsQuery } from 'data/vault/vault-secrets-query'
import { Button, Form, Input, SheetFooter, SheetHeader, SheetTitle } from 'ui'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
+import InputField from './InputField'
+import { WrapperMeta } from './Wrappers.types'
+import {
+ convertKVStringArrayToJson,
+ formatWrapperTables,
+ makeValidateRequired,
+} from './Wrappers.utils'
+import WrapperTableEditor from './WrapperTableEditor'
export interface EditWrapperSheetProps {
wrapper: FDW
diff --git a/apps/studio/components/interfaces/Database/Wrappers/InputField.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/InputField.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Database/Wrappers/InputField.tsx
rename to apps/studio/components/interfaces/Integrations/Wrappers/InputField.tsx
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/MarkdownContent.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/MarkdownContent.tsx
deleted file mode 100644
index fdecd62b5f7..00000000000
--- a/apps/studio/components/interfaces/Integrations/Wrappers/MarkdownContent.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { useParams } from 'common'
-import { Markdown } from 'components/interfaces/Markdown'
-import { motion } from 'framer-motion'
-import { useEffect, useState } from 'react'
-import { cn } from 'ui'
-
-const CHAR_LIMIT = 500 // Adjust this number as needed
-
-export const MarkdownContent = () => {
- const { id } = useParams()
- const [content, setContent] = useState<string>('')
- const [isExpanded, setIsExpanded] = useState(false)
-
- useEffect(() => {
- import(`static-data/integrations/${id}/overview.md`)
- .then((module) => setContent(String(module.default)))
- .catch((error) => console.error('Error loading markdown:', error))
- }, [id])
-
- const displayContent = isExpanded ? content : content.slice(0, CHAR_LIMIT)
-
- return (
- <div className="px-10">
- <div className="relative">
- <motion.div
- initial={false}
- animate={{ height: isExpanded ? 'auto' : 80 }}
- className="overflow-hidden"
- transition={{ duration: 0.4 }}
- >
- <Markdown content={displayContent} className="!max-w-3xl" />
- </motion.div>
- {!isExpanded && (
- <div
- className={cn(
- 'bottom-0 left-0 right-0 h-24 bg-gradient-to-t from-background-200 to-transparent',
- !isExpanded ? 'absolute' : 'relative'
- )}
- />
- )}
- {content.length > CHAR_LIMIT && (
- <div className={cn('bottom-0 z-10', !isExpanded ? 'absolute' : 'relative mt-3')}>
- <button
- className="text-foreground-light hover:text-foreground underline text-sm"
- onClick={() => setIsExpanded(!isExpanded)}
- >
- {isExpanded ? 'Show less' : 'Read more'}
- </button>
- </div>
- )}
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrapperDynamicColumns.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperDynamicColumns.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Database/Wrappers/WrapperDynamicColumns.tsx
rename to apps/studio/components/interfaces/Integrations/Wrappers/WrapperDynamicColumns.tsx
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx
index de0a81f891d..1ca1738225b 100644
--- a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx
+++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx
@@ -5,14 +5,14 @@ import Link from 'next/link'
import { useState } from 'react'
import { useParams } from 'common'
-import DeleteWrapperModal from 'components/interfaces/Database/Wrappers/DeleteWrapperModal'
-import { formatWrapperTables } from 'components/interfaces/Database/Wrappers/Wrappers.utils'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import type { FDW } from 'data/fdw/fdws-query'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { Badge, Sheet, SheetContent, TableCell, TableRow } from 'ui'
import { INTEGRATIONS } from '../Landing/Integrations.constants'
+import DeleteWrapperModal from './DeleteWrapperModal'
import { EditWrapperSheet } from './EditWrapperSheet'
+import { formatWrapperTables } from './Wrappers.utils'
interface WrapperRowProps {
wrapper: FDW
diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrapperTableEditor.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperTableEditor.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Database/Wrappers/WrapperTableEditor.tsx
rename to apps/studio/components/interfaces/Integrations/Wrappers/WrapperTableEditor.tsx
diff --git a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.constants.ts b/apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.constants.ts
similarity index 100%
rename from apps/studio/components/interfaces/Database/Wrappers/Wrappers.constants.ts
rename to apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.constants.ts
diff --git a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.types.ts b/apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.types.ts
similarity index 100%
rename from apps/studio/components/interfaces/Database/Wrappers/Wrappers.types.ts
rename to apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.types.ts
diff --git a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.utils.ts b/apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.utils.ts
similarity index 100%
rename from apps/studio/components/interfaces/Database/Wrappers/Wrappers.utils.ts
rename to apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.utils.ts
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx
index a3fcb856b18..f84bf45a2d9 100644
--- a/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx
+++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx
@@ -2,8 +2,6 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { HTMLProps, ReactNode, useCallback, useState } from 'react'
import { useParams } from 'common'
-import DeleteWrapperModal from 'components/interfaces/Database/Wrappers/DeleteWrapperModal'
-import { wrapperMetaComparator } from 'components/interfaces/Database/Wrappers/Wrappers.utils'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { FDW, useFDWsQuery } from 'data/fdw/fdws-query'
@@ -12,6 +10,8 @@ import { Sheet, SheetContent } from 'ui'
import { INTEGRATIONS } from '../Landing/Integrations.constants'
import { CreateWrapperSheet } from './CreateWrapperSheet'
import { WrapperTable } from './WrapperTable'
+import DeleteWrapperModal from './DeleteWrapperModal'
+import { wrapperMetaComparator } from './Wrappers.utils'
export const WrappersTab = () => {
const { id } = useParams()
diff --git a/apps/studio/components/interfaces/Settings/Vault/VaultNavTabs.tsx b/apps/studio/components/interfaces/Settings/Vault/VaultNavTabs.tsx
deleted file mode 100644
index 27d3f4b16c7..00000000000
--- a/apps/studio/components/interfaces/Settings/Vault/VaultNavTabs.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import Link from 'next/link'
-import React, { PropsWithChildren } from 'react'
-import { NavMenu, NavMenuItem } from 'ui'
-
-type Props = {
- projRef: string
- activeTab: 'secrets' | 'keys'
-}
-
-const VaultNavTabs = (props: PropsWithChildren<Props>) => {
- return (
- <NavMenu className="mb-4" aria-label="Vault menu">
- <NavMenuItem active={props.activeTab === 'secrets'}>
- <Link href={`/project/${props.projRef}/integrations/vault/secrets`}>
- Secrets Management
- </Link>
- </NavMenuItem>
- <NavMenuItem active={props.activeTab === 'keys'}>
- <Link href={`/project/${props.projRef}/integrations/vault/keys`}>Encryption Keys</Link>
- </NavMenuItem>
- </NavMenu>
- )
-}
-
-export default VaultNavTabs
diff --git a/apps/studio/components/interfaces/Settings/Vault/VaultToggle.tsx b/apps/studio/components/interfaces/Settings/Vault/VaultToggle.tsx
deleted file mode 100644
index b5a53421cb6..00000000000
--- a/apps/studio/components/interfaces/Settings/Vault/VaultToggle.tsx
+++ /dev/null
@@ -1,164 +0,0 @@
-import * as Tooltip from '@radix-ui/react-tooltip'
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useTheme } from 'next-themes'
-import Link from 'next/link'
-import { useState } from 'react'
-import { toast } from 'sonner'
-
-import { useParams } from 'common'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { useDatabaseExtensionEnableMutation } from 'data/database-extensions/database-extension-enable-mutation'
-import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
-import { executeSql } from 'data/sql/execute-sql-query'
-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { BASE_PATH } from 'lib/constants'
-import { Button } from 'ui'
-import { ExternalLink } from 'lucide-react'
-
-const VaultToggle = () => {
- const { ref } = useParams()
- const { resolvedTheme } = useTheme()
- const { project } = useProjectContext()
- const [isEnabling, setIsEnabling] = useState(false)
- const canToggleVault = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'extensions')
-
- const { data } = useDatabaseExtensionsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
- const vaultExtension = (data ?? []).find((ext) => ext.name === 'supabase_vault')
- const isNotAvailable = vaultExtension === undefined
-
- const { mutate: enableExtension } = useDatabaseExtensionEnableMutation({
- onSuccess: () => {
- toast.success(`Vault is now enabled for your project!`)
- },
- onError: (error) => {
- toast.error(`Failed to enable Vault for your project: ${error.message}`)
- setIsEnabling(false)
- },
- })
-
- const onEnableVault = async () => {
- if (vaultExtension === undefined) return
- if (project === undefined) return console.error('Project is required')
-
- setIsEnabling(true)
-
- try {
- await executeSql({
- projectRef: project.ref,
- connectionString: project.connectionString,
- sql: `create schema if not exists ${vaultExtension.schema ?? 'vault'};`,
- })
- } catch (createSchemaError: any) {
- setIsEnabling(false)
- return toast.error(`Failed to create schema: ${createSchemaError.message}`)
- }
-
- enableExtension({
- projectRef: project.ref,
- connectionString: project.connectionString,
- schema: vaultExtension.schema ?? 'vault',
- name: vaultExtension.name,
- version: vaultExtension.default_version,
- cascade: true,
- })
- }
-
- return (
- <div>
- <div
- className="px-12 py-12 w-full bg-studio border rounded bg-no-repeat"
- style={{
- backgroundSize: isNotAvailable ? '50%' : '40%',
- backgroundPosition: '100% 24%',
- backgroundImage: resolvedTheme?.includes('dark')
- ? `url("${BASE_PATH}/img/vault-dark.png")`
- : `url("${BASE_PATH}/img/vault-light.png")`,
- }}
- >
- <div className="w-3/5 space-y-8">
- <div className="space-y-2">
- <h4 className="text-lg">Enable Vault today</h4>
- <p className="text-sm text-foreground-light">
- Supabase Vault is a Postgres extension for managing secrets and encryption inside your
- database without leaking any sensitive information.
- </p>
- </div>
- {isNotAvailable ? (
- <div className="space-y-4">
- <div className="rounded border px-4 py-2 flex items-center justify-between">
- <div>
- <p className="text-foreground-light text-sm">
- Vault is not available for this project yet.
- </p>
- <p className="text-foreground-light text-sm">
- Do reach out to us if you're interested!
- </p>
- </div>
- <div>
- <Button asChild type="primary">
- <Link
- href={`/support/new?ref=${ref}&category=sales&subject=Request%20for%20access%20to%20vault`}
- target="_blank"
- rel="noreferrer"
- >
- Contact us
- </Link>
- </Button>
- </div>
- </div>
- <div className="flex items-center space-x-2 my-1 ml-[1px]">
- <Button asChild type="default" icon={<ExternalLink />}>
- <Link href="https://github.com/supabase/vault" target="_blank" rel="noreferrer">
- About Vault
- </Link>
- </Button>
- </div>
- </div>
- ) : (
- <div className="flex items-center space-x-2">
- <Button asChild type="default" icon={<ExternalLink />}>
- <Link href="https://github.com/supabase/vault" target="_blank" rel="noreferrer">
- About Vault
- </Link>
- </Button>
- <Tooltip.Root delayDuration={0}>
- <Tooltip.Trigger asChild>
- <Button
- type="primary"
- loading={isEnabling}
- disabled={isNotAvailable || isEnabling || !canToggleVault}
- onClick={() => onEnableVault()}
- >
- Enable Vault
- </Button>
- </Tooltip.Trigger>
- {!canToggleVault && (
- <Tooltip.Portal>
- <Tooltip.Content side="bottom">
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'rounded bg-alternative py-1 px-2 leading-none shadow',
- 'border border-background',
- ].join(' ')}
- >
- <span className="text-xs text-foreground">
- You need additional permissions to enable Vault for this project
- </span>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- )}
- </Tooltip.Root>
- </div>
- )}
- </div>
- </div>
- </div>
- )
-}
-
-export default VaultToggle
diff --git a/apps/studio/components/interfaces/Settings/Vault/index.ts b/apps/studio/components/interfaces/Settings/Vault/index.ts
deleted file mode 100644
index c4c4a5ec325..00000000000
--- a/apps/studio/components/interfaces/Settings/Vault/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export { default as VaultToggle } from './VaultToggle'
-export { default as SecretsManagement } from './Secrets/SecretsManagement'
-export { default as EncryptionKeySelector } from './Keys/EncryptionKeySelector'
-export { default as EncryptionKeysManagement } from './Keys/EncryptionKeysManagement'
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
index b958b10054d..45479064d21 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
@@ -74,7 +74,7 @@ export const generateSettingsMenu = (
{
name: 'Vault',
key: 'vault',
- url: isProjectBuilding ? buildingUrl : `/project/${ref}/integrations/vault/secrets`,
+ url: isProjectBuilding ? buildingUrl : `/project/${ref}/integrations/vault/overview`,
items: [],
rightIcon: <ArrowUpRight strokeWidth={1} className="h-4 w-4" />,
label: 'BETA',
diff --git a/apps/studio/data/fdw/fdw-create-mutation.ts b/apps/studio/data/fdw/fdw-create-mutation.ts
index f7a6c41a86a..917b89c1285 100644
--- a/apps/studio/data/fdw/fdw-create-mutation.ts
+++ b/apps/studio/data/fdw/fdw-create-mutation.ts
@@ -4,7 +4,7 @@ import { toast } from 'sonner'
import {
AvailableColumn,
WrapperMeta,
-} from 'components/interfaces/Database/Wrappers/Wrappers.types'
+} from 'components/interfaces/Integrations/Wrappers/Wrappers.types'
import { entityTypeKeys } from 'data/entity-types/keys'
import { foreignTableKeys } from 'data/foreign-tables/keys'
import { pgSodiumKeys } from 'data/pg-sodium-keys/keys'
diff --git a/apps/studio/data/fdw/fdw-delete-mutation.ts b/apps/studio/data/fdw/fdw-delete-mutation.ts
index 79944a68d6a..868422362c7 100644
--- a/apps/studio/data/fdw/fdw-delete-mutation.ts
+++ b/apps/studio/data/fdw/fdw-delete-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'sonner'
-import type { WrapperMeta } from 'components/interfaces/Database/Wrappers/Wrappers.types'
+import type { WrapperMeta } from 'components/interfaces/Integrations/Wrappers/Wrappers.types'
import { entityTypeKeys } from 'data/entity-types/keys'
import { foreignTableKeys } from 'data/foreign-tables/keys'
import { pgSodiumKeys } from 'data/pg-sodium-keys/keys'
diff --git a/apps/studio/data/fdw/fdw-update-mutation.ts b/apps/studio/data/fdw/fdw-update-mutation.ts
index 25226f9b40d..c49c729559f 100644
--- a/apps/studio/data/fdw/fdw-update-mutation.ts
+++ b/apps/studio/data/fdw/fdw-update-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'sonner'
-import type { WrapperMeta } from 'components/interfaces/Database/Wrappers/Wrappers.types'
+import type { WrapperMeta } from 'components/interfaces/Integrations/Wrappers/Wrappers.types'
import { entityTypeKeys } from 'data/entity-types/keys'
import { foreignTableKeys } from 'data/foreign-tables/keys'
import { pgSodiumKeys } from 'data/pg-sodium-keys/keys'