Skip to content

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

Chore/connect UI update for session pool mode (#33230)

Joshen Lim257824e31973
diff --git a/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx b/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx
index bce5602468d..807c47a7724 100644
--- a/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx
+++ b/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx
@@ -1,6 +1,10 @@
import { ChevronRight, FileCode, X } from 'lucide-react'
import Link from 'next/link'
+import { useParams } from 'common'
+import Panel from 'components/ui/Panel'
+import { usePoolingConfigurationQuery } from 'data/database/pooling-configuration-query'
+import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
import {
Button,
cn,
@@ -11,6 +15,7 @@ import {
CollapsibleTrigger_Shadcn_,
WarningIcon,
} from 'ui'
+import { Admonition } from 'ui-patterns'
import { ConnectionParameters } from './ConnectionParameters'
import { DirectConnectionIcon, TransactionIcon } from './PoolerIcons'
@@ -105,6 +110,13 @@ export const ConnectionPanel = ({
fileTitle,
onCopyCallback,
}: ConnectionPanelProps) => {
+ const { ref: projectRef } = useParams()
+ const state = useDatabaseSelectorStateSnapshot()
+
+ const { data: poolingInfo } = usePoolingConfigurationQuery({ projectRef })
+ const poolingConfiguration = poolingInfo?.find((x) => x.identifier === state.selectedDatabaseId)
+ const isSessionMode = poolingConfiguration?.pool_mode === 'session'
+
return (
<div className="flex flex-col gap-5 lg:grid lg:grid-cols-2 lg:gap-20 w-full">
<div className="flex flex-col">
@@ -112,27 +124,59 @@ export const ConnectionPanel = ({
<p className="text-sm text-foreground-light mb-4">{description}</p>
<div className="flex flex-col -space-y-px">
{fileTitle && <CodeBlockFileHeader title={fileTitle} />}
- <CodeBlock
- wrapperClassName={cn(
- '[&_pre]:rounded-b-none [&_pre]:px-4 [&_pre]:py-3',
- fileTitle && '[&_pre]:rounded-t-none'
- )}
- language={lang}
- value={connectionString}
- className="[&_code]:text-[12px] [&_code]:text-foreground"
- hideLineNumbers
- onCopyCallback={onCopyCallback}
- />
- {notice && (
- <div className="border px-4 py-1 w-full justify-start rounded-t-none !last:rounded-b group-data-[state=open]:rounded-b-none border-light">
- {notice?.map((text: string) => (
- <p key={text} className="text-xs text-foreground-lighter">
- {text}
- </p>
- ))}
- </div>
+ {type === 'transaction' && isSessionMode ? (
+ <Admonition
+ showIcon={false}
+ type="default"
+ className="[&>h5]:text-xs [&>div]:text-xs"
+ title="Transaction pooler is unavailable as pool mode is set to Session"
+ description="If you'd like to use transaction mode, update your pool mode to Transaction for the connection pooler in your project's Database Settings."
+ >
+ <Button asChild type="default" className="mt-2">
+ <Link
+ href={`/project/${projectRef}/settings/database#connection-pooler`}
+ className="text-xs text-light hover:text-foreground"
+ >
+ Database Settings
+ </Link>
+ </Button>
+ </Admonition>
+ ) : (
+ <>
+ {/* [Joshen] Can probably remove this after Feb 28 */}
+ {type === 'session' && isSessionMode && (
+ <Panel.Notice
+ layout="vertical"
+ className="border rounded mb-2"
+ title="Deprecating Session Mode on Port 6543"
+ description="Please use port 5432 for Session Mode as Supavisor will be deprecating Session Mode on port 6543 on February 28, 2025."
+ href="https://github.com/orgs/supabase/discussions/32755"
+ buttonText="Read the announcement"
+ />
+ )}
+ <CodeBlock
+ wrapperClassName={cn(
+ '[&_pre]:rounded-b-none [&_pre]:px-4 [&_pre]:py-3',
+ fileTitle && '[&_pre]:rounded-t-none'
+ )}
+ language={lang}
+ value={connectionString}
+ className="[&_code]:text-[12px] [&_code]:text-foreground"
+ hideLineNumbers
+ onCopyCallback={onCopyCallback}
+ />
+ {notice && (
+ <div className="border px-4 py-1 w-full justify-start rounded-t-none !last:rounded-b group-data-[state=open]:rounded-b-none border-light">
+ {notice?.map((text: string) => (
+ <p key={text} className="text-xs text-foreground-lighter">
+ {text}
+ </p>
+ ))}
+ </div>
+ )}
+ {parameters.length > 0 && <ConnectionParameters parameters={parameters} />}
+ </>
)}
- {parameters.length > 0 && <ConnectionParameters parameters={parameters} />}
</div>
</div>
<div className="flex flex-col items-end">
diff --git a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
index 357ad0f78af..9e3817a5ff2 100644
--- a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
+++ b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
@@ -11,6 +11,7 @@ import { usePoolingConfigurationQuery } from 'data/database/pooling-configuratio
import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { pluckObjectFields } from 'lib/helpers'
import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
import {
@@ -36,7 +37,6 @@ import {
import { CodeBlockFileHeader, ConnectionPanel } from './ConnectionPanel'
import { getConnectionStrings } from './DatabaseSettings.utils'
import examples, { Example } from './DirectConnectionExamples'
-import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
const StepLabel = ({
number,
diff --git a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
index 379691b2bab..e1a5a7fc8d4 100644
--- a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
@@ -36,6 +36,7 @@ import {
Listbox,
Separator,
} from 'ui'
+import { Admonition } from 'ui-patterns'
import { SESSION_MODE_DESCRIPTION, TRANSACTION_MODE_DESCRIPTION } from '../Database.constants'
import { POOLING_OPTIMIZATIONS } from './ConnectionPooling.constants'
import { useAuthConfigQuery } from 'data/auth/auth-config-query'
@@ -98,7 +99,7 @@ export const ConnectionPooling = () => {
isLoading,
isError,
isSuccess,
- } = usePoolingConfigurationQuery({ projectRef: projectRef })
+ } = usePoolingConfigurationQuery({ projectRef })
const { data: authConfig } = useAuthConfigQuery({ projectRef })
@@ -297,29 +298,32 @@ export const ConnectionPooling = () => {
<>
{field.value === 'transaction' ? (
<FormDescription_Shadcn_ className="col-start-5 col-span-8 flex flex-col gap-y-2">
- <Alert_Shadcn_>
- <AlertTitle_Shadcn_ className="text-foreground">
- Pool mode will be set to transaction permanently on port 6543
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- This will take into effect once saved. You can use session mode by
- pointing the pooler connection to use port 5432.
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
+ <Admonition
+ type="warning"
+ title="Pool mode will be set to transaction permanently on port 6543"
+ description="This will take into effect once saved. If you are using Session mode with port 6543 in your applications, please update to use port 5432 instead before saving."
+ />
</FormDescription_Shadcn_>
) : (
<FormDescription_Shadcn_ className="col-start-5 col-span-8 flex flex-col gap-y-2">
- <Alert_Shadcn_>
- <AlertTitle_Shadcn_ className="text-foreground">
- Set to transaction mode to use both pooling modes concurrently
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- Session mode can be used concurrently with transaction mode by
+ {/* [Joshen] Can probably remove this after Feb 28 */}
+ <Panel.Notice
+ layout="vertical"
+ className="border rounded-lg"
+ title="Deprecating Session Mode on Port 6543"
+ description="On February 28, 2025, Supavisor is deprecating Session Mode on port 6543. Please update your application/database clients to use port 5432 for Session Mode."
+ href="https://github.com/orgs/supabase/discussions/32755"
+ buttonText="Read the announcement"
+ />
+ <Admonition
+ showIcon={false}
+ type="default"
+ title="Set to transaction mode to use both pooling modes concurrently"
+ description="Session mode can be used concurrently with transaction mode by
using 5432 for session and 6543 for transaction. However, by
configuring the pooler mode to session here, you will not be able
- to use transaction mode at the same time.
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
+ to use transaction mode at the same time."
+ />
</FormDescription_Shadcn_>
)}
</>
diff --git a/apps/studio/components/layouts/DefaultLayout.tsx b/apps/studio/components/layouts/DefaultLayout.tsx
index a397f020c8a..2e0bca40b33 100644
--- a/apps/studio/components/layouts/DefaultLayout.tsx
+++ b/apps/studio/components/layouts/DefaultLayout.tsx
@@ -1,11 +1,12 @@
+import { PropsWithChildren } from 'react'
+
+import { useParams } from 'common'
import { AppBannerWrapper } from 'components/interfaces/App'
import { AppBannerContextProvider } from 'components/interfaces/App/AppBannerWrapperContext'
-import { PropsWithChildren, ReactNode } from 'react'
import { LayoutHeader } from './ProjectLayout/LayoutHeader'
-import NavigationBar from './ProjectLayout/NavigationBar/NavigationBar'
import MobileNavigationBar from './ProjectLayout/NavigationBar/MobileNavigationBar'
+import NavigationBar from './ProjectLayout/NavigationBar/NavigationBar'
import { ProjectContextProvider } from './ProjectLayout/ProjectContext'
-import { useParams } from 'common'
export interface DefaultLayoutProps {
title?: string
diff --git a/apps/studio/components/ui/Panel.tsx b/apps/studio/components/ui/Panel.tsx
index fd3724b6372..dbc51b7dfa0 100644
--- a/apps/studio/components/ui/Panel.tsx
+++ b/apps/studio/components/ui/Panel.tsx
@@ -1,6 +1,7 @@
import { Megaphone } from 'lucide-react'
import { forwardRef, PropsWithChildren, ReactNode } from 'react'
-import { Badge, Button, Loading, cn } from 'ui'
+
+import { Badge, Button, cn, Loading } from 'ui'
interface PanelProps {
className?: string
@@ -62,71 +63,78 @@ const PanelNotice = forwardRef<
description?: string
href?: string
buttonText?: string
+ layout?: 'horizontal' | 'vertical'
badgeLabel?: string
}
->(({ className, title, description, href, buttonText, badgeLabel, ...props }, ref) => {
- return (
- <div
- ref={ref}
- {...props}
- className={cn(
- 'relative px-4 md:px-6 py-5 bg-studio flex flex-col lg:flex-row lg:justify-between gap-6 overflow-hidden lg:items-center',
- className
- )}
- >
+>(
+ (
+ {
+ className,
+ title,
+ description,
+ href,
+ buttonText,
+ layout = 'horizontal',
+ badgeLabel,
+ ...props
+ },
+ ref
+ ) => {
+ return (
<div
- className="absolute inset-0 -mt-[5px]"
- style={{
- backgroundImage: `
+ ref={ref}
+ {...props}
+ className={cn(
+ 'relative px-4 md:px-6 py-5 bg-studio flex flex-col lg:flex-row lg:justify-between gap-6 overflow-hidden lg:items-center',
+ layout === 'vertical' && '!flex-col !items-start gap-y-2',
+ className
+ )}
+ >
+ <div
+ className="absolute inset-0 -mt-[5px]"
+ style={{
+ backgroundImage: `
linear-gradient(to right, hsl(var(--background-200)/1) 0%, hsl(var(--background-200)/1) 30%, hsl(var(--background-200)/0) 100%),
linear-gradient(to right, hsl(var(--border-default)/0.33) 1px, transparent 1px),
linear-gradient(to bottom, hsl(var(--border-default)/0.33) 1px, transparent 1px)
`,
- backgroundSize: '100% 100%, 15px 15px, 15px 15px',
- backgroundPosition: '0 0, 0 0, 0 0',
- }}
- ></div>
- <div className="relative flex flex-col gap-1">
- <div className="flex flex-row items-center -space-x-px">
- <Badge
- variant={'default'}
- className="
- rounded-r-none
- pr-2
- flex-shrink-0 gap-1.5 border-dashed bg-opacity-0 bg-surface-400 text-foreground-lighter"
- >
- <Megaphone size={16} strokeWidth={1.2} />
- <span className="text-foreground-lighter">{badgeLabel ?? 'Upcoming change'}</span>
- </Badge>
- <Badge
- variant={'default'}
- className="
- rounded-l-none
- flex-shrink-0 gap-1.5 bg-opacity-0 bg-surface-400 text-foreground-lighter border-l-0"
- >
- <span className="text-foreground text-xs">{title}</span>
- </Badge>
- {/* <span className="font-medium text-foreground text-sm">{title}</span> */}
- </div>
- {description && (
- <div className="text-foreground-light text-sm flex flex-col gap-0">
- <div className="prose text-xs max-w-none [&_p]:mt-2 [&_p]:mb-0">{description}</div>
+ backgroundSize: '100% 100%, 15px 15px, 15px 15px',
+ backgroundPosition: '0 0, 0 0, 0 0',
+ }}
+ />
+ <div className="relative flex flex-col gap-y-2">
+ <div className="flex flex-row items-center -space-x-px">
+ <Badge
+ variant={'default'}
+ className="rounded-r-none pr-2 flex-shrink-0 gap-1.5 border-dashed bg-opacity-0 bg-surface-400 text-foreground-lighter"
+ >
+ <Megaphone size={16} strokeWidth={1.2} />
+ <span className="text-foreground-lighter">{badgeLabel ?? 'Upcoming change'}</span>
+ </Badge>
+ <Badge
+ variant="default"
+ className="rounded-l-none flex-shrink-0 gap-1.5 bg-opacity-0 bg-surface-400 text-foreground-lighter border-l-0"
+ >
+ <span className="text-foreground text-xs">{title}</span>
+ </Badge>
</div>
- )}
- </div>
-
- {href && (
- <div>
+ {description && (
+ <div className="text-foreground-light text-sm flex flex-col gap-0">
+ <div className="prose text-xs max-w-none [&_p]:mt-2 [&_p]:mb-0">{description}</div>
+ </div>
+ )}
+ </div>
+ {href && (
<Button size="tiny" type="default" className="text-xs" asChild>
<a href={href} target="_blank" rel="noreferrer noopener">
{buttonText ?? 'Read the accouncement'}
</a>
</Button>
- </div>
- )}
- </div>
- )
-})
+ )}
+ </div>
+ )
+ }
+)
PanelNotice.displayName = 'PanelNotice'