The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(studio): new wrapper form closing bug (#46698)
Francesco Sansalvadore188ae5333318
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsxindex aec304ece77..c52a6df134c 100644--- a/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx+++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx@@ -1,6 +1,7 @@import { PermissionAction } from '@supabase/shared-types/out/constants'import { useParams } from 'common'-import { HTMLProps, ReactNode, useCallback, useState } from 'react'+import { parseAsBoolean, useQueryState } from 'nuqs'+import { useCallback, useState } from 'react'import { Sheet, SheetContent } from 'ui'import { CreateWrapperSheet } from './CreateWrapperSheet'@@ -20,14 +21,18 @@ import { useShortcut } from '@/state/shortcuts/useShortcut'export const WrappersTab = () => {const { id } = useParams()const { data: project } = useSelectedProjectQuery()- const [createWrapperShown, setCreateWrapperShown] = useState(false)++ const [isCreating, setIsCreating] = useQueryState(+ 'new',+ parseAsBoolean.withDefault(false).withOptions({ clearOnDefault: true })+ )const { can: canCreateWrapper } = useAsyncCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE,'wrappers')- useShortcut(SHORTCUT_IDS.LIST_PAGE_NEW_ITEM, () => setCreateWrapperShown(true), {+ useShortcut(SHORTCUT_IDS.LIST_PAGE_NEW_ITEM, () => setIsCreating(true), {label: 'Add new wrapper',enabled: canCreateWrapper,})@@ -40,7 +45,6 @@ export const WrappersTab = () => {const wrappers = data ?? []const wrapperMeta = WRAPPERS.find((w) => w.name === id)- // this contains a collection of all wrapper instances for the wrapper typeconst createdWrappers = wrapperMeta? wrappers.filter((w) => wrapperMetaComparator(wrapperMeta, w)): []@@ -49,47 +53,26 @@ export const WrappersTab = () => {const { confirmOnClose, handleOpenChange, modalProps } = useConfirmOnClose({checkIsDirty: useCallback(() => isDirty, [isDirty]),onClose: useCallback(() => {- setCreateWrapperShown(false)+ setIsCreating(null)setIsDirty(false)- }, []),+ }, [setIsCreating]),})- const Container = useCallback(- ({ ...props }: { children: ReactNode } & HTMLProps<HTMLDivElement>) => (- <div className="w-full p-10">- {props.children}- <Sheet open={!!createWrapperShown} onOpenChange={handleOpenChange}>- <SheetContent size="lg" tabIndex={undefined}>- {wrapperMeta && (- <CreateWrapperSheet- wrapperMeta={wrapperMeta}- onDirty={setIsDirty}- onClose={() => setCreateWrapperShown(false)}- onCloseWithConfirmation={confirmOnClose}- />- )}- </SheetContent>- </Sheet>- </div>- ),- [createWrapperShown, handleOpenChange, wrapperMeta, confirmOnClose]- )-if (!wrapperMeta) {return <div>Missing integration.</div>}- if (createdWrappers.length === 0) {- return (- <Container>- <div className=" w-full h-48 max-w-4xl">+ return (+ <div className="w-full p-10">+ {createdWrappers.length === 0 ? (+ <div className="w-full h-48 max-w-4xl"><div className="border rounded-lg h-full flex flex-col gap-y-2 items-center justify-center"><p className="text-sm text-foreground-light">No {wrapperMeta.label} wrappers have been installed</p><ButtonTooltiptype="default"- onClick={() => setCreateWrapperShown(true)}+ onClick={() => setIsCreating(true)}disabled={!canCreateWrapper}tooltip={{content: {@@ -103,31 +86,45 @@ export const WrappersTab = () => {</ButtonTooltip></div></div>- </Container>- )- }+ ) : (+ <div className="max-w-5xl flex items-center gap-x-2 justify-end mb-4">+ <DocsButton href={wrapperMeta.docsUrl} />+ <ButtonTooltip+ type="primary"+ onClick={() => setIsCreating(true)}+ disabled={!canCreateWrapper}+ tooltip={{+ content: {+ text: !canCreateWrapper+ ? 'You need additional permissions to create a foreign data wrapper'+ : undefined,+ },+ }}+ >+ Add new wrapper+ </ButtonTooltip>+ </div>+ )}++ {createdWrappers.length > 0 && <WrapperTable />}++ <Sheet open={!!isCreating} onOpenChange={handleOpenChange}>+ <SheetContent size="lg" tabIndex={undefined}>+ {wrapperMeta && (+ <CreateWrapperSheet+ wrapperMeta={wrapperMeta}+ onDirty={setIsDirty}+ onClose={() => {+ setIsCreating(null)+ setIsDirty(false)+ }}+ onCloseWithConfirmation={confirmOnClose}+ />+ )}+ </SheetContent>+ </Sheet>- return (- <Container>- <div className="max-w-5xl flex items-center gap-x-2 justify-end mb-4">- <DocsButton href={wrapperMeta.docsUrl} />- <ButtonTooltip- type="primary"- onClick={() => setCreateWrapperShown(true)}- disabled={!canCreateWrapper}- tooltip={{- content: {- text: !canCreateWrapper- ? 'You need additional permissions to create a foreign data wrapper'- : undefined,- },- }}- >- Add new wrapper- </ButtonTooltip>- </div>- <WrapperTable /><DiscardChangesConfirmationDialog {...modalProps} />- </Container>+ </div>)}