Skip to content

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

Feat/connection string revamp (#30572)

Jonathan Summers-Muirf650b5ae67eb
diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts b/apps/studio/components/interfaces/Connect/Connect.constants.ts
similarity index 78%
rename from apps/studio/components/interfaces/Home/Connect/Connect.constants.ts
rename to apps/studio/components/interfaces/Connect/Connect.constants.ts
index 80933e20cef..4d94d82a20a 100644
--- a/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts
+++ b/apps/studio/components/interfaces/Connect/Connect.constants.ts
@@ -1,3 +1,63 @@
+import { CodeBlockLang } from 'ui'
+
+export type DatabaseConnectionType =
+ | 'uri'
+ | 'psql'
+ | 'golang'
+ | 'jdbc'
+ | 'dotnet'
+ | 'nodejs'
+ | 'php'
+ | 'python'
+ | 'sqlalchemy'
+
+export const DATABASE_CONNECTION_TYPES: {
+ id: DatabaseConnectionType
+ label: string
+ contentType: 'input' | 'code'
+ lang: CodeBlockLang
+ fileTitle: string | undefined
+}[] = [
+ { id: 'uri', label: 'URI', contentType: 'input', lang: 'bash', fileTitle: undefined },
+ { id: 'psql', label: 'PSQL', contentType: 'code', lang: 'bash', fileTitle: undefined },
+ { id: 'golang', label: 'Golang', contentType: 'code', lang: 'go', fileTitle: '.env' },
+ { id: 'jdbc', label: 'JDBC', contentType: 'input', lang: 'bash', fileTitle: undefined },
+ {
+ id: 'dotnet',
+ label: '.NET',
+ contentType: 'code',
+ lang: 'csharp',
+ fileTitle: 'appsettings.json',
+ },
+ { id: 'nodejs', label: 'Node.js', contentType: 'code', lang: 'js', fileTitle: '.env' },
+ { id: 'php', label: 'PHP', contentType: 'code', lang: 'php', fileTitle: '.env' },
+ { id: 'python', label: 'Python', contentType: 'code', lang: 'python', fileTitle: '.env' },
+ { id: 'sqlalchemy', label: 'SQLAlchemy', contentType: 'code', lang: 'python', fileTitle: '.env' },
+]
+
+export const CONNECTION_PARAMETERS = {
+ host: {
+ key: 'host',
+ description: 'The hostname of your database',
+ },
+ port: {
+ key: 'port',
+ description: 'Port number for the connection',
+ },
+ database: {
+ key: 'database',
+ description: 'Default database name',
+ },
+ user: {
+ key: 'user',
+ description: 'Database user',
+ },
+ pool_mode: {
+ key: 'pool_mode',
+ description: 'Connection pooling behavior',
+ },
+} as const
+
export type ConnectionType = {
key: string
icon: string
@@ -283,6 +343,7 @@ export const ORMS: ConnectionType[] = [
]
export const CONNECTION_TYPES = [
+ { key: 'direct', label: 'Connection String', obj: [] },
{ key: 'frameworks', label: 'App Frameworks', obj: FRAMEWORKS },
{ key: 'mobiles', label: 'Mobile Frameworks', obj: MOBILES },
{ key: 'orms', label: 'ORMs', obj: ORMS },
diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.tsx b/apps/studio/components/interfaces/Connect/Connect.tsx
similarity index 85%
rename from apps/studio/components/interfaces/Home/Connect/Connect.tsx
rename to apps/studio/components/interfaces/Connect/Connect.tsx
index bcab28afdc2..9a4c306e578 100644
--- a/apps/studio/components/interfaces/Home/Connect/Connect.tsx
+++ b/apps/studio/components/interfaces/Connect/Connect.tsx
@@ -3,15 +3,17 @@ import { useParams } from 'common'
import { ExternalLink, Plug } from 'lucide-react'
import { useState } from 'react'
-import { DatabaseConnectionString } from 'components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString'
-import { PoolingModesModal } from 'components/interfaces/Settings/Database/PoolingModesModal'
+import { DatabaseConnectionString } from 'components/interfaces/Connect/DatabaseConnectionString'
+import { DatabaseConnectionString as OldDatabaseConnectionString } from 'components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString'
+
import Panel from 'components/ui/Panel'
import { getAPIKeys, useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
+import { useFlag } from 'hooks/ui/useFlag'
+import { useAppStateSnapshot } from 'state/app-state'
import {
Button,
DIALOG_PADDING_X,
- DIALOG_PADDING_X_SMALL,
DIALOG_PADDING_Y,
Dialog,
DialogContent,
@@ -31,7 +33,9 @@ import ConnectDropdown from './ConnectDropdown'
import ConnectTabContent from './ConnectTabContent'
const Connect = () => {
+ const state = useAppStateSnapshot()
const { ref: projectRef } = useParams()
+ const connectDialogUpdate = useFlag('connectDialogUpdate')
const [connectionObject, setConnectionObject] = useState<ConnectionType[]>(FRAMEWORKS)
const [selectedParent, setSelectedParent] = useState(connectionObject[0].key) // aka nextjs
@@ -145,14 +149,18 @@ const Connect = () => {
return (
<>
- <Dialog>
+ <Dialog open={state.showConnectDialog} onOpenChange={state.setShowConnectDialog}>
<DialogTrigger asChild>
- <Button type="primary" icon={<Plug className="rotate-90" />}>
+ <Button
+ type={connectDialogUpdate ? 'default' : 'primary'}
+ className={cn(connectDialogUpdate && 'rounded-full')}
+ icon={<Plug className="rotate-90" />}
+ >
<span>Connect</span>
</Button>
</DialogTrigger>
<DialogContent className={cn('sm:max-w-5xl p-0')} centered={false}>
- <DialogHeader className="pb-3">
+ <DialogHeader className={DIALOG_PADDING_X}>
<DialogTitle>Connect to your project</DialogTitle>
<DialogDescription>
Get the connection strings and environment variables for your app
@@ -163,10 +171,7 @@ const Connect = () => {
defaultValue="direct"
onValueChange={(value) => handleConnectionType(value)}
>
- <TabsList_Shadcn_ className={cn('flex gap-4', DIALOG_PADDING_X_SMALL)}>
- <TabsTrigger_Shadcn_ key="direct" value="direct" className="px-0">
- Connection String
- </TabsTrigger_Shadcn_>
+ <TabsList_Shadcn_ className={cn('flex gap-x-4', DIALOG_PADDING_X)}>
{CONNECTION_TYPES.map((type) => (
<TabsTrigger_Shadcn_ key={type.key} value={type.key} className="px-0">
{type.label}
@@ -183,6 +188,26 @@ const Connect = () => {
.find((parent) => parent.key === selectedParent)
?.children.find((child) => child.key === selectedChild)?.children.length || 0) > 0
+ if (type.key === 'direct') {
+ return (
+ <TabsContent_Shadcn_
+ key="direct"
+ value="direct"
+ className={cn('!mt-0', 'p-0', 'flex flex-col gap-6')}
+ >
+ <div className={DIALOG_PADDING_Y}>
+ {connectDialogUpdate ? (
+ <DatabaseConnectionString />
+ ) : (
+ <div className="px-7">
+ <OldDatabaseConnectionString appearance="minimal" />
+ </div>
+ )}
+ </div>
+ </TabsContent_Shadcn_>
+ )
+ }
+
return (
<TabsContent_Shadcn_
key={`content-${type.key}`}
@@ -190,7 +215,7 @@ const Connect = () => {
className={cn(DIALOG_PADDING_X, DIALOG_PADDING_Y, '!mt-0')}
>
<div className="flex justify-between">
- <div className="flex items-center gap-5">
+ <div className="flex items-center gap-3">
<ConnectDropdown
state={selectedParent}
updateState={handleParentChange}
@@ -254,17 +279,9 @@ const Connect = () => {
</TabsContent_Shadcn_>
)
})}
- <TabsContent_Shadcn_
- key="direct"
- value="direct"
- className={cn(DIALOG_PADDING_X_SMALL, DIALOG_PADDING_Y, '!mt-0')}
- >
- <DatabaseConnectionString appearance="minimal" />
- </TabsContent_Shadcn_>
</Tabs_Shadcn_>
</DialogContent>
</Dialog>
- <PoolingModesModal />
</>
)
}
diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.types.ts b/apps/studio/components/interfaces/Connect/Connect.types.ts
similarity index 100%
rename from apps/studio/components/interfaces/Home/Connect/Connect.types.ts
rename to apps/studio/components/interfaces/Connect/Connect.types.ts
diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.utils.ts b/apps/studio/components/interfaces/Connect/Connect.utils.ts
similarity index 100%
rename from apps/studio/components/interfaces/Home/Connect/Connect.utils.ts
rename to apps/studio/components/interfaces/Connect/Connect.utils.ts
diff --git a/apps/studio/components/interfaces/Connect/ConnectDropdown.tsx b/apps/studio/components/interfaces/Connect/ConnectDropdown.tsx
new file mode 100644
index 00000000000..3a17f63e659
--- /dev/null
+++ b/apps/studio/components/interfaces/Connect/ConnectDropdown.tsx
@@ -0,0 +1,98 @@
+import { Box, Check, ChevronDown } from 'lucide-react'
+import { useState } from 'react'
+
+import {
+ Button,
+ CommandEmpty_Shadcn_,
+ CommandGroup_Shadcn_,
+ CommandInput_Shadcn_,
+ CommandItem_Shadcn_,
+ CommandList_Shadcn_,
+ Command_Shadcn_,
+ PopoverContent_Shadcn_,
+ PopoverTrigger_Shadcn_,
+ Popover_Shadcn_,
+ cn,
+} from 'ui'
+import { ConnectionIcon } from './ConnectionIcon'
+
+interface ConnectDropdownProps {
+ state: string
+ updateState: (state: string) => void
+ label: string
+ items: any[]
+}
+
+const ConnectDropdown = ({
+ state,
+ updateState,
+ label,
+
+ items,
+}: ConnectDropdownProps) => {
+ const [open, setOpen] = useState(false)
+
+ function onSelectLib(key: string) {
+ updateState(key)
+ setOpen(false)
+ }
+
+ const selectedItem = items.find((item) => item.key === state)
+
+ return (
+ <Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>
+ <div className="flex ">
+ <span className="flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0">
+ {label}
+ </span>
+ <PopoverTrigger_Shadcn_ asChild>
+ <Button
+ size="small"
+ type="default"
+ className="gap-0 rounded-l-none"
+ iconRight={<ChevronDown strokeWidth={1.5} />}
+ >
+ <div className="flex items-center gap-2">
+ {selectedItem?.icon ? (
+ <ConnectionIcon connection={selectedItem.icon} />
+ ) : (
+ <Box size={12} />
+ )}
+ {selectedItem?.label}
+ </div>
+ </Button>
+ </PopoverTrigger_Shadcn_>
+ </div>
+ <PopoverContent_Shadcn_ className="p-0 max-w-48" side="bottom" align="start">
+ <Command_Shadcn_>
+ <CommandInput_Shadcn_ placeholder="Search..." />
+ <CommandList_Shadcn_>
+ <CommandEmpty_Shadcn_>No results found.</CommandEmpty_Shadcn_>
+ <CommandGroup_Shadcn_>
+ {items.map((item) => (
+ <CommandItem_Shadcn_
+ key={item.key}
+ value={item.key}
+ onSelect={() => {
+ onSelectLib(item.key)
+ setOpen(false)
+ }}
+ className="flex gap-2 items-center"
+ >
+ {item.icon ? <ConnectionIcon connection={item.icon} /> : <Box size={12} />}
+ {item.label}
+ <Check
+ size={15}
+ className={cn('ml-auto ', item.key === state ? 'opacity-100' : 'opacity-0')}
+ />
+ </CommandItem_Shadcn_>
+ ))}
+ </CommandGroup_Shadcn_>
+ </CommandList_Shadcn_>
+ </Command_Shadcn_>
+ </PopoverContent_Shadcn_>
+ </Popover_Shadcn_>
+ )
+}
+
+export default ConnectDropdown
diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx b/apps/studio/components/interfaces/Connect/ConnectTabContent.tsx
similarity index 92%
rename from apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx
rename to apps/studio/components/interfaces/Connect/ConnectTabContent.tsx
index 005b806419e..9237c6ecf6c 100644
--- a/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx
+++ b/apps/studio/components/interfaces/Connect/ConnectTabContent.tsx
@@ -1,5 +1,5 @@
import dynamic from 'next/dynamic'
-import { forwardRef, HTMLAttributes } from 'react'
+import { forwardRef, HTMLAttributes, useMemo } from 'react'
import { useParams } from 'common'
import { getConnectionStrings } from 'components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.utils'
@@ -49,16 +49,15 @@ const ConnectTabContentNew = forwardRef<HTMLDivElement, ConnectContentTabProps>(
const connectionStringPoolerTransaction = connectionStringsPooler.uri
const connectionStringPoolerSession = connectionStringsPooler.uri.replace('6543', '5432')
- const ContentFile = dynamic<ConnectContentTabProps>(
- () => import(`./content/${filePath}/content`),
- {
+ const ContentFile = useMemo(() => {
+ return dynamic<ConnectContentTabProps>(() => import(`./content/${filePath}/content`), {
loading: () => (
<div className="p-4 min-h-[331px]">
<GenericSkeletonLoader />
</div>
),
- }
- )
+ })
+ }, [filePath])
return (
<div ref={ref} {...props} className={cn('border rounded-lg', props.className)}>
diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectTabs.tsx b/apps/studio/components/interfaces/Connect/ConnectTabs.tsx
similarity index 81%
rename from apps/studio/components/interfaces/Home/Connect/ConnectTabs.tsx
rename to apps/studio/components/interfaces/Connect/ConnectTabs.tsx
index f5871de3f91..ec7b1b5a61f 100644
--- a/apps/studio/components/interfaces/Home/Connect/ConnectTabs.tsx
+++ b/apps/studio/components/interfaces/Connect/ConnectTabs.tsx
@@ -1,8 +1,7 @@
-import { Tabs_Shadcn_ } from 'ui'
import { FileJson2 } from 'lucide-react'
-import { TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui'
-import { TabsContent_Shadcn_ } from 'ui'
-import React, { ReactNode } from 'react'
+import { isValidElement, ReactNode } from 'react'
+
+import { Tabs_Shadcn_, TabsContent_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui'
interface ConnectTabTriggerProps {
value: string
@@ -22,7 +21,7 @@ interface ConnectTabContentProps {
const ConnectTabs = ({ children }: ConnectFileTabProps) => {
const firstChild = children[0]
- const defaultValue = React.isValidElement(firstChild)
+ const defaultValue = isValidElement(firstChild)
? (firstChild.props as any)?.children[0]?.props?.value || ''
: null
@@ -57,4 +56,4 @@ export const ConnectTabContent = ({ value, children }: ConnectTabContentProps) =
)
}
-export { ConnectTabTrigger, ConnectTabTriggers, ConnectTabs }
+export { ConnectTabs, ConnectTabTrigger, ConnectTabTriggers }
diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectionIcon.tsx b/apps/studio/components/interfaces/Connect/ConnectionIcon.tsx
similarity index 89%
rename from apps/studio/components/interfaces/Home/Connect/ConnectionIcon.tsx
rename to apps/studio/components/interfaces/Connect/ConnectionIcon.tsx
index a79acebc468..fd2452d2961 100644
--- a/apps/studio/components/interfaces/Home/Connect/ConnectionIcon.tsx
+++ b/apps/studio/components/interfaces/Connect/ConnectionIcon.tsx
@@ -1,12 +1,13 @@
-import { BASE_PATH } from 'lib/constants'
-
import { useTheme } from 'next-themes'
import Image from 'next/image'
+
+import { BASE_PATH } from 'lib/constants'
+
interface ConnectionIconProps {
connection: any
}
-const ConnectionIcon = ({ connection }: ConnectionIconProps) => {
+export const ConnectionIcon = ({ connection }: ConnectionIconProps) => {
const { resolvedTheme } = useTheme()
const imageFolder = ['ionic-angular'].includes(connection) ? 'icons/frameworks' : 'libraries'
@@ -28,5 +29,3 @@ const ConnectionIcon = ({ connection }: ConnectionIconProps) => {
/>
)
}
-
-export default ConnectionIcon
diff --git a/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx b/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx
new file mode 100644
index 00000000000..bce5602468d
--- /dev/null
+++ b/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx
@@ -0,0 +1,265 @@
+import { ChevronRight, FileCode, X } from 'lucide-react'
+import Link from 'next/link'
+
+import {
+ Button,
+ cn,
+ CodeBlock,
+ CodeBlockLang,
+ Collapsible_Shadcn_,
+ CollapsibleContent_Shadcn_,
+ CollapsibleTrigger_Shadcn_,
+ WarningIcon,
+} from 'ui'
+import { ConnectionParameters } from './ConnectionParameters'
+import { DirectConnectionIcon, TransactionIcon } from './PoolerIcons'
+
+interface ConnectionPanelProps {
+ type?: 'direct' | 'transaction' | 'session'
+ title: string
+ description: string
+ connectionString: string
+ ipv4Status: {
+ type: 'error' | 'success'
+ title: string
+ description?: string
+ link?: { text: string; url: string }
+ }
+ notice?: string[]
+ parameters?: Array<{
+ key: string
+ value: string
+ description?: string
+ }>
+ contentType?: 'input' | 'code'
+ lang?: CodeBlockLang
+ fileTitle?: string
+ onCopyCallback: () => void
+}
+
+const IPv4StatusIcon = ({ className, active }: { className?: string; active: boolean }) => {
+ return (
+ <div className={cn('relative inline-flex', className)}>
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke-width="1"
+ stroke="currentColor"
+ className="size-6 stroke-foreground-lighter"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ d="M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418"
+ />
+ </svg>
+
+ {!active ? (
+ <div className="absolute -right-1.5 -top-1.5 bg-destructive rounded w-4 h-4 flex items-center justify-center">
+ <X size={10} strokeWidth={4} className="text-white rounded-full" />
+ </div>
+ ) : (
+ <div className="absolute -right-1.5 -top-1.5 bg-brand-500 rounded w-4 h-4 flex items-center justify-center">
+ <svg
+ width="10"
+ height="10"
+ viewBox="0 0 10 10"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M8.33325 2.5L3.74992 7.08333L1.66659 5"
+ stroke="white"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ </div>
+ )}
+ </div>
+ )
+}
+
+export const CodeBlockFileHeader = ({ title }: { title: string }) => {
+ return (
+ <div className="flex items-center justify-between px-4 py-1 bg-surface-100/50 border border-b-0 border-surface rounded-t">
+ <div className="flex items-center gap-2">
+ <FileCode size={12} className="text-foreground-muted" strokeWidth={1.5} />
+ <span className="text-xs text-foreground-light">{title}</span>
+ </div>
+ </div>
+ )
+}
+
+export const ConnectionPanel = ({
+ type = 'direct',
+ title,
+ description,
+ connectionString,
+ ipv4Status,
+ notice,
+ parameters = [],
+ lang = 'bash',
+ fileTitle,
+ onCopyCallback,
+}: ConnectionPanelProps) => {
+ return (
+ <div className="flex flex-col gap-5 lg:grid lg:grid-cols-2 lg:gap-20 w-full">
+ <div className="flex flex-col">
+ <h1 className="text-sm mb-2">{title}</h1>
+ <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>
+ )}
+ {parameters.length > 0 && <ConnectionParameters parameters={parameters} />}
+ </div>
+ </div>
+ <div className="flex flex-col items-end">
+ <div className="flex flex-col -space-y-px w-full">
+ {type !== 'session' && (
+ <>
+ <div className="relative border border-muted px-5 flex items-center gap-3 py-3 first:rounded-t last:rounded-b h-[58px]">
+ <div className="absolute top-2 left-2.5">
+ {type === 'transaction' ? <TransactionIcon /> : <DirectConnectionIcon />}
+ </div>
+ <div className="flex flex-col pl-[52px]">
+ <span className="text-xs text-foreground">
+ {type === 'transaction'
+ ? 'Suitable for a large number of connected clients'
+ : 'Suitable for long-lived, persistent connections'}
+ </span>
+ </div>
+ </div>
+ <div className="border border-muted px-5 flex items-center gap-3 py-3 first:rounded-t last:rounded-b h-[58px]">
+ <div className="flex flex-col pl-[52px]">
+ <span className="text-xs text-foreground">
+ {type === 'transaction'
+ ? 'Pre-warmed connection pool to Postgres'
+ : 'Each client has a dedicated connection to Postgres'}
+ </span>
+ </div>
+ </div>
+ </>
+ )}
+
+ <div className="border border-muted px-5 flex gap-7 items-center py-3 first:rounded-t last:rounded-b">
+ <div className="flex items-center gap-2">
+ <IPv4StatusIcon active={ipv4Status.type === 'success'} />
+ </div>
+ <div className="flex flex-col">
+ <span className="text-xs text-foreground">{ipv4Status.title}</span>
+ {ipv4Status.description && (
+ <span className="text-xs text-foreground-lighter">{ipv4Status.description}</span>
+ )}
+ {ipv4Status.type === 'error' && (
+ <span className="text-xs text-foreground-lighter">
+ Use Session Pooler if on a IPv4 network or purchase IPv4 addon
+ </span>
+ )}
+ {ipv4Status.link && (
+ <div className="mt-2">
+ <Button asChild type="default" size="tiny">
+ <Link
+ href={ipv4Status.link.url}
+ className="text-xs text-light hover:text-foreground"
+ >
+ {ipv4Status.link.text}
+ </Link>
+ </Button>
+ </div>
+ )}
+ </div>
+ </div>
+
+ {type === 'session' && (
+ <div className="border border-muted px-5 flex gap-7 items-center py-3 first:rounded-t last:rounded-b bg-alternative/50">
+ <div className="flex w-6 h-6 rounded items-center justify-center gap-2 flex-shrink-0 bg-surface-100">
+ <WarningIcon />
+ </div>
+ <div className="flex flex-col">
+ <span className="text-xs text-foreground">Only use on a IPv4 network</span>
+ <span className="text-xs text-foreground-lighter">
+ Use Direct Connection if connecting via an IPv6 network
+ </span>
+ </div>
+ </div>
+ )}
+
+ {ipv4Status.type === 'error' && (
+ <Collapsible_Shadcn_ className="group -space-y-px">
+ <CollapsibleTrigger_Shadcn_
+ asChild
+ className="group/collapse w-full justify-start rounded-t-none !last:rounded-b group-data-[state=open]:rounded-b-none border-muted"
+ >
+ <Button
+ type="default"
+ size="tiny"
+ className="text-foreground-lighter !bg-dash-sidebar"
+ icon={
+ <ChevronRight
+ className={cn(
+ 'group-data-[state=open]/collapse:rotate-90 text-foreground-muted transition-transform'
+ )}
+ />
+ }
+ >
+ Some platforms are IPv4-only:
+ </Button>
+ </CollapsibleTrigger_Shadcn_>
+ <CollapsibleContent_Shadcn_ className="bg-dash-sidebar rounded-b border px-3 py-2">
+ <div className="flex flex-col gap-2">
+ <p className="text-xs text-foreground-light max-w-xs">
+ A few major platforms are IPv4-only and may not work with a Direct Connection:
+ </p>
+ <div className="flex gap-4">
+ <div className="text-foreground text-xs">Vercel</div>
+ <div className="text-foreground text-xs">GitHub Actions</div>
+ <div className="text-foreground text-xs">Render</div>
+ <div className="text-foreground text-xs">Retool</div>
+ </div>
+ <p className="text-xs text-foreground-lighter max-w-xs">
+ If you wish to use a Direct Connection with these, please purchase{' '}
+ <Link
+ href={ipv4Status.link?.url ?? '/'}
+ className="text-xs text-light hover:text-foreground"
+ >
+ IPv4 support
+ </Link>
+ .
+ </p>
+ <p className="text-xs text-foreground-lighter max-w-xs">
+ You may also use the{' '}
+ <span className="text-foreground-light">Session Pooler</span> or{' '}
+ <span className="text-foreground-light">Transaction Pooler</span> if you are on
+ a IPv4 network.
+ </p>
+ </div>
+ </CollapsibleContent_Shadcn_>
+ </Collapsible_Shadcn_>
+ )}
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/Connect/ConnectionParameters.tsx b/apps/studio/components/interfaces/Connect/ConnectionParameters.tsx
new file mode 100644
index 00000000000..6a5e4ba1687
--- /dev/null
+++ b/apps/studio/components/interfaces/Connect/ConnectionParameters.tsx
@@ -0,0 +1,91 @@
+import { Check, ChevronRight, Copy } from 'lucide-react'
+import { useState } from 'react'
+
+import { copyToClipboard } from 'lib/helpers'
+import {
+ Button,
+ cn,
+ Collapsible_Shadcn_,
+ CollapsibleContent_Shadcn_,
+ CollapsibleTrigger_Shadcn_,
+ Separator,
+} from 'ui'
+
+interface Parameter {
+ key: string
+ value: string
+ description?: string
+}
+
+interface ConnectionParametersProps {
+ parameters: Parameter[]
+}
+
+export const ConnectionParameters = ({ parameters }: ConnectionParametersProps) => {
+ const [isOpen, setIsOpen] = useState(false)
+ const [copiedMap, setCopiedMap] = useState<Record<string, boolean>>({})
+
+ return (
+ <Collapsible_Shadcn_ open={isOpen} onOpenChange={setIsOpen} className="group -space-y-px">
+ <CollapsibleTrigger_Shadcn_
+ asChild
+ className="w-full justify-start rounded-t-none !last:rounded-b group-data-[state=open]:rounded-b-none border-light px-3"
+ >
+ <Button
+ type="default"
+ size="tiny"
+ className="text-foreground-lighter !bg-dash-sidebar"
+ icon={
+ <ChevronRight
+ className={cn(
+ 'text-foreground-muted transition-transform',
+ isOpen ? 'rotate-90' : ''
+ )}
+ />
+ }
+ >
+ View parameters
+ </Button>
+ </CollapsibleTrigger_Shadcn_>
+ <CollapsibleContent_Shadcn_ className="bg-dash-sidebar rounded-b border font-mono text-sm">
+ <div className="px-4 py-2">
+ {parameters.map((param) => (
+ <div key={param.key} className="py-0.5 group/param">
+ <div className="text-xs flex items-center">
+ <span className="text-foreground-lighter">{param.key}: </span>
+ <span className="ml-1 text-foreground">{param.value}</span>
+ <button
+ onClick={() => {
+ copyToClipboard(param.value, () => {
+ setCopiedMap((prev) => ({ ...prev, [param.key]: true }))
+ setTimeout(() => {
+ setCopiedMap((prev) => ({ ...prev, [param.key]: false }))
+ }, 1000)
+ })
+ }}
+ className={cn(
+ 'text-foreground-lighter',
+ 'ml-2 opacity-0 group-hover/param:opacity-100',
+ 'hover:text-foreground rounded-sm p-1',
+ copiedMap[param.key] && 'opacity-100',
+ 'transition-all'
+ )}
+ >
+ {copiedMap[param.key] ? (
+ <Check size={12} strokeWidth={1.5} />
+ ) : (
+ <Copy size={12} strokeWidth={1.5} />
+ )}
+ </button>
+ </div>
+ </div>
+ ))}
+ </div>
+ <Separator />
+ <div className="text-foreground-muted text-xs px-4 py-1 font-sans">
+ For security reasons, your database password is never shown.
+ </div>
+ </CollapsibleContent_Shadcn_>
+ </Collapsible_Shadcn_>
+ )
+}
diff --git a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
new file mode 100644
index 00000000000..cd489d0dc0b
--- /dev/null
+++ b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
@@ -0,0 +1,477 @@
+import { ChevronDown } from 'lucide-react'
+import { HTMLAttributes, ReactNode, useState } from 'react'
+
+import { useParams } from 'common'
+import { getAddons } from 'components/interfaces/Billing/Subscription/Subscription.utils'
+import AlertError from 'components/ui/AlertError'
+import DatabaseSelector from 'components/ui/DatabaseSelector'
+import ShimmeringLoader from 'components/ui/ShimmeringLoader'
+import { usePoolingConfigurationQuery } from 'data/database/pooling-configuration-query'
+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 { pluckObjectFields } from 'lib/helpers'
+import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
+import {
+ CodeBlock,
+ CollapsibleContent_Shadcn_,
+ CollapsibleTrigger_Shadcn_,
+ Collapsible_Shadcn_,
+ DIALOG_PADDING_X,
+ SelectContent_Shadcn_,
+ SelectItem_Shadcn_,
+ SelectTrigger_Shadcn_,
+ SelectValue_Shadcn_,
+ Select_Shadcn_,
+ Separator,
+ cn,
+} from 'ui'
+import { Admonition } from 'ui-patterns'
+import {
+ CONNECTION_PARAMETERS,
+ DATABASE_CONNECTION_TYPES,
+ DatabaseConnectionType,
+} from './Connect.constants'
+import { CodeBlockFileHeader, ConnectionPanel } from './ConnectionPanel'
+import { getConnectionStrings, getPoolerTld } from './DatabaseSettings.utils'
+import examples, { Example } from './DirectConnectionExamples'
+
+const StepLabel = ({
+ number,
+ children,
+ ...props
+}: { number: number; children: ReactNode } & HTMLAttributes<HTMLDivElement>) => (
+ <div {...props} className={cn('flex items-center gap-2', props.className)}>
+ <div className="flex font-mono text-xs items-center justify-center w-6 h-6 border border-strong rounded-md bg-surface-100">
+ {number}
+ </div>
+ <span>{children}</span>
+ </div>
+)
+
+export const DatabaseConnectionString = () => {
+ const { ref: projectRef } = useParams()
+ const state = useDatabaseSelectorStateSnapshot()
+
+ const [selectedTab, setSelectedTab] = useState<DatabaseConnectionType>('uri')
+
+ const {
+ data: poolingInfo,
+ error: poolingInfoError,
+ isLoading: isLoadingPoolingInfo,
+ isError: isErrorPoolingInfo,
+ isSuccess: isSuccessPoolingInfo,
+ } = usePoolingConfigurationQuery({
+ projectRef,
+ })
+ const poolingConfiguration = poolingInfo?.find((x) => x.identifier === state.selectedDatabaseId)
+
+ const {
+ data: databases,
+ error: readReplicasError,
+ isLoading: isLoadingReadReplicas,
+ isError: isErrorReadReplicas,
+ isSuccess: isSuccessReadReplicas,
+ } = useReadReplicasQuery({ projectRef })
+
+ const error = poolingInfoError || readReplicasError
+ const isLoading = isLoadingPoolingInfo || isLoadingReadReplicas
+ const isError = isErrorPoolingInfo || isErrorReadReplicas
+ const isSuccess = isSuccessPoolingInfo && isSuccessReadReplicas
+
+ const selectedDatabase = (databases ?? []).find(
+ (db) => db.identifier === state.selectedDatabaseId
+ )
+
+ const { data: addons } = useProjectAddonsQuery({ projectRef })
+ const { ipv4: ipv4Addon } = getAddons(addons?.selected_addons ?? [])
+
+ const { mutate: sendEvent } = useSendEventMutation()
+
+ const DB_FIELDS = ['db_host', 'db_name', 'db_port', 'db_user', 'inserted_at']
+ const emptyState = { db_user: '', db_host: '', db_port: '', db_name: '' }
+ const connectionInfo = pluckObjectFields(selectedDatabase || emptyState, DB_FIELDS)
+
+ const handleCopy = (id: string) => {
+ const labelValue = DATABASE_CONNECTION_TYPES.find((type) => type.id === id)?.label
+ sendEvent({
+ category: 'settings',
+ action: 'copy_connection_string',
+ label: labelValue ?? '',
+ })
+ }
+
+ const connectionStrings =
+ isSuccessPoolingInfo && poolingConfiguration !== undefined
+ ? getConnectionStrings(connectionInfo, poolingConfiguration, {
+ projectRef,
+ })
+ : {
+ direct: {
+ uri: '',
+ psql: '',
+ golang: '',
+ jdbc: '',
+ dotnet: '',
+ nodejs: '',
+ php: '',
+ python: '',
+ sqlalchemy: '',
+ },
+ pooler: {
+ uri: '',
+ psql: '',
+ golang: '',
+ jdbc: '',
+ dotnet: '',
+ nodejs: '',
+ php: '',
+ python: '',
+ sqlalchemy: '',
+ },
+ }
+
+ const poolerTld =
+ isSuccessPoolingInfo && poolingConfiguration !== undefined
+ ? getPoolerTld(poolingConfiguration?.connectionString)
+ : 'com'
+
+ // @mildtomato - Possible reintroduce later
+ //
+ // const poolerConnStringSyntax =
+ // isSuccessPoolingInfo && poolingConfiguration !== undefined
+ // ? constructConnStringSyntax(poolingConfiguration?.connectionString, {
+ // selectedTab,
+ // usePoolerConnection: snap.usePoolerConnection,
+ // ref: projectRef as string,
+ // cloudProvider: isProjectLoading ? '' : project?.cloud_provider || '',
+ // region: isProjectLoading ? '' : project?.region || '',
+ // tld: snap.usePoolerConnection ? poolerTld : connectionTld,
+ // portNumber: `[5432 or 6543]`,
+ // })
+ // : []
+ // useEffect(() => {
+ // // if (poolingConfiguration?.pool_mode === 'session') {
+ // // setPoolingMode(poolingConfiguration.pool_mode)
+ // // }
+ // }, [poolingConfiguration?.pool_mode])
+
+ const lang = DATABASE_CONNECTION_TYPES.find((type) => type.id === selectedTab)?.lang ?? 'bash'
+ const contentType =
+ DATABASE_CONNECTION_TYPES.find((type) => type.id === selectedTab)?.contentType ?? 'input'
+
+ const example: Example | undefined = examples[selectedTab as keyof typeof examples]
+
+ const exampleFiles = example?.files
+ const exampleInstallCommands = example?.installCommands
+ const examplePostInstallCommands = example?.postInstallCommands
+ const hasCodeExamples = exampleFiles || exampleInstallCommands
+ const fileTitle = DATABASE_CONNECTION_TYPES.find((type) => type.id === selectedTab)?.fileTitle
+
+ // [Refactor] See if we can do this in an immutable way, technically not a good practice to do this
+ let stepNumber = 0
+
+ return (
+ <div className="flex flex-col">
+ <div className={cn('flex items-center gap-3', DIALOG_PADDING_X)}>
+ <div className="flex">
+ <span className="flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0">
+ Type
+ </span>
+ <Select_Shadcn_
+ value={selectedTab}
+ onValueChange={(connectionType: DatabaseConnectionType) =>
+ setSelectedTab(connectionType)
+ }
+ >
+ <SelectTrigger_Shadcn_ size="small" className="w-auto rounded-l-none">
+ <SelectValue_Shadcn_ />
+ </SelectTrigger_Shadcn_>
+ <SelectContent_Shadcn_>
+ {DATABASE_CONNECTION_TYPES.map((type) => (
+ <SelectItem_Shadcn_ key={type.id} value={type.id}>
+ {type.label}
+ </SelectItem_Shadcn_>
+ ))}
+ </SelectContent_Shadcn_>
+ </Select_Shadcn_>
+ </div>
+ <DatabaseSelector buttonProps={{ size: 'small' }} />
+ </div>
+
+ {isLoading && (
+ <div className="p-7">
+ <ShimmeringLoader className="h-8 w-full" />
+ </div>
+ )}
+
+ {isError && (
+ <div className="p-7">
+ <AlertError error={error} subject="Failed to retrieve database settings" />
+ </div>
+ )}
+
+ {isSuccess && (
+ <div className="flex flex-col divide-y divide-border">
+ {/* // handle non terminal examples */}
+ {hasCodeExamples && (
+ <div className="grid grid-cols-2 gap-x-20 w-full px-7 py-8">
+ <div>
+ <StepLabel number={++stepNumber} className="mb-4">
+ Install the following
+ </StepLabel>
+ {exampleInstallCommands?.map((cmd, i) => (
+ <CodeBlock
+ key={i}
+ className="[&_code]:text-[12px] [&_code]:text-foreground"
+ value={cmd}
+ hideLineNumbers
+ language="bash"
+ >
+ {cmd}
+ </CodeBlock>
+ ))}
+ </div>
+ {exampleFiles && exampleFiles?.length > 0 && (
+ <div>
+ <StepLabel number={++stepNumber} className="mb-4">
+ Add file to project
+ </StepLabel>
+ {exampleFiles?.map((file, i) => (
+ <div key={i}>
+ <CodeBlockFileHeader title={file.name} />
+ <CodeBlock
+ wrapperClassName="[&_pre]:max-h-40 [&_pre]:px-4 [&_pre]:py-3 [&_pre]:rounded-t-none"
+ value={file.content}
+ hideLineNumbers
+ language={lang}
+ className="[&_code]:text-[12px] [&_code]:text-foreground"
+ />
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ )}
+
+ <div>
+ {hasCodeExamples && (
+ <div className="px-7 pt-8">
+ <StepLabel number={++stepNumber}>Choose type of connection</StepLabel>
+ </div>
+ )}
+ <div className="divide-y divide-border-muted [&>div]:px-7 [&>div]:py-8">
+ <ConnectionPanel
+ contentType={contentType}
+ lang={lang}
+ type="direct"
+ title="Direct connection"
+ fileTitle={fileTitle}
+ description="Ideal for applications with persistent, long-lived connections, such as those running on virtual machines or long-standing containers."
+ connectionString={connectionStrings['direct'][selectedTab]}
+ ipv4Status={{
+ type: !ipv4Addon ? 'error' : 'success',
+ title: !ipv4Addon ? 'Not IPv4 compatible' : 'IPv4 compatible',
+ description: ipv4Addon && 'Connections are IPv4 proxied with IPv4 addon.',
+ link: !ipv4Addon
+ ? {
+ text: 'IPv4 addon',
+ url: `/project/${projectRef}/settings/addons?panel=ipv4`,
+ }
+ : {
+ text: 'IPv4 settings',
+ url: `/project/${projectRef}/settings/addons?panel=ipv4`,
+ },
+ }}
+ parameters={[
+ { ...CONNECTION_PARAMETERS.host, value: connectionInfo.db_host },
+ { ...CONNECTION_PARAMETERS.port, value: connectionInfo.db_port },
+ { ...CONNECTION_PARAMETERS.database, value: connectionInfo.db_name },
+ { ...CONNECTION_PARAMETERS.user, value: connectionInfo.db_user },
+ ]}
+ onCopyCallback={() => handleCopy(selectedTab)}
+ />
+ <ConnectionPanel
+ contentType={contentType}
+ lang={lang}
+ type="transaction"
+ title="Transaction pooler"
+ fileTitle={fileTitle}
+ description="Ideal for stateless applications like serverless functions where each interaction with Postgres is brief and isolated."
+ connectionString={connectionStrings['pooler'][selectedTab]}
+ ipv4Status={{
+ type: 'success',
+ title: 'IPv4 compatible',
+ description: 'Transaction pooler connections are IPv4 proxied for free.',
+ }}
+ notice={['Does not support PREPARE statements']}
+ parameters={[
+ {
+ ...CONNECTION_PARAMETERS.host,
+ value: `${projectRef}.pooler.supabase.${poolerTld}`,
+ },
+ {
+ ...CONNECTION_PARAMETERS.port,
+ value: poolingConfiguration?.db_port.toString() ?? '6543',
+ description: 'Port number for transaction pooler',
+ },
+ { ...CONNECTION_PARAMETERS.database, value: connectionInfo.db_name },
+ { ...CONNECTION_PARAMETERS.user, value: connectionInfo.db_user },
+ {
+ ...CONNECTION_PARAMETERS.pool_mode,
+ value: 'transaction',
+ description: 'Each transaction uses a different connection',
+ },
+ ]}
+ onCopyCallback={() => handleCopy(selectedTab)}
+ />
+ {ipv4Addon && (
+ <Admonition
+ type="warning"
+ title="Highly recommended to not use Session Pooler"
+ className="[&>div]:gap-0 px-8 [&>svg]:left-7 border-0 border-b rounded-none border-border-muted !py-4 mb-0"
+ >
+ <p className="text-sm text-foreground-lighter !mb-0">
+ If you are using Session Pooler, we recommend switching to Direct Connection.
+ </p>
+ </Admonition>
+ )}
+
+ <ConnectionPanel
+ contentType={contentType}
+ lang={lang}
+ type="session"
+ title="Session pooler"
+ fileTitle={fileTitle}
+ description="Only recommended as an alternative to Direct Connection, when connecting via an IPv4 network."
+ connectionString={connectionStrings['pooler'][selectedTab].replace('6543', '5432')}
+ ipv4Status={{
+ type: 'success',
+ title: 'IPv4 compatible',
+ description: 'Session pooler connections are IPv4 proxied for free.',
+ }}
+ parameters={[
+ {
+ ...CONNECTION_PARAMETERS.host,
+ value: `${projectRef}.pooler.supabase.${poolerTld}`,
+ },
+ {
+ ...CONNECTION_PARAMETERS.port,
+ value: '5432',
+ description: 'Port number for session pooler',
+ },
+ { ...CONNECTION_PARAMETERS.database, value: connectionInfo.db_name },
+ { ...CONNECTION_PARAMETERS.user, value: connectionInfo.db_user },
+ {
+ ...CONNECTION_PARAMETERS.pool_mode,
+ value: 'session',
+ description: 'Connection is reserved for the entire session',
+ },
+ ]}
+ onCopyCallback={() => handleCopy(selectedTab)}
+ />
+ </div>
+ </div>
+ {examplePostInstallCommands && (
+ <div className="grid grid-cols-2 gap-20 w-full px-7 py-10">
+ <div>
+ <StepLabel number={++stepNumber} className="mb-4">
+ Add the configuration package to read the settings
+ </StepLabel>
+ {examplePostInstallCommands?.map((cmd, i) => (
+ <CodeBlock
+ key={i}
+ className="text-sm"
+ value={cmd}
+ hideLineNumbers
+ language="bash"
+ >
+ {cmd}
+ </CodeBlock>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ )}
+
+ {/* Possibly reintroduce later - @mildtomato */}
+ {/* <Separator />
+ <Collapsible_Shadcn_ className={cn('px-8 pt-5', selectedTab === 'python' && 'pb-5')}>
+ <CollapsibleTrigger_Shadcn_ className="group [&[data-state=open]>div>svg]:!-rotate-180">
+ <div className="flex items-center gap-x-2 w-full">
+ <p className="text-xs text-foreground-light group-hover:text-foreground transition">
+ How to connect to a different database or switch to another user
+ </p>
+ <ChevronDown
+ className="transition-transform duration-200"
+ strokeWidth={1.5}
+ size={14}
+ />
+ </div>
+ </CollapsibleTrigger_Shadcn_>
+ <CollapsibleContent_Shadcn_ className="my-2">
+ <div className="text-foreground-light">
+ <p className="text-xs">
+ You can use the following URI format to switch to a different database or user
+ {snap.usePoolerConnection ? ' when using connection pooling' : ''}.
+ </p>
+ <p className="text-sm tracking-tight text-foreground-lighter">
+ {poolerConnStringSyntax.map((x, idx) => {
+ if (x.tooltip) {
+ return (
+ <Tooltip_Shadcn_ key={`syntax-${idx}`}>
+ <TooltipTrigger_Shadcn_ asChild>
+ <span className="text-foreground text-xs font-mono">{x.value}</span>
+ </TooltipTrigger_Shadcn_>
+ <TooltipContent_Shadcn_ side="bottom">{x.tooltip}</TooltipContent_Shadcn_>
+ </Tooltip_Shadcn_>
+ )
+ } else {
+ return (
+ <span key={`syntax-${idx}`} className="text-xs font-mono">
+ {x.value}
+ </span>
+ )
+ }
+ })}
+ </p>
+ </div>
+ </CollapsibleContent_Shadcn_>
+ </Collapsible_Shadcn_> */}
+
+ {selectedTab === 'python' && (
+ <>
+ <Separator />
+ <Collapsible_Shadcn_ className="px-8 pt-5">
+ <CollapsibleTrigger_Shadcn_ className="group [&[data-state=open]>div>svg]:!-rotate-180">
+ <div className="flex items-center gap-x-2 w-full">
+ <p className="text-xs text-foreground-light group-hover:text-foreground transition">
+ Connecting to SQL Alchemy
+ </p>
+ <ChevronDown
+ className="transition-transform duration-200"
+ strokeWidth={1.5}
+ size={14}
+ />
+ </div>
+ </CollapsibleTrigger_Shadcn_>
+ <CollapsibleContent_Shadcn_ className="my-2">
+ <div className="text-foreground-light text-xs grid gap-2">
+ <p>
+ Please use <code>postgresql://</code> instead of <code>postgres://</code> as your
+ dialect when connecting via SQLAlchemy.
+ </p>
+ <p>
+ Example:
+ <code>create_engine("postgresql+psycopg2://...")</code>
+ </p>
+ <p className="text-sm font-mono tracking-tight text-foreground-lighter"></p>
+ </div>
+ </CollapsibleContent_Shadcn_>
+ </Collapsible_Shadcn_>
+ </>
+ )}
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/Connect/DatabaseSettings.utils.ts b/apps/studio/components/interfaces/Connect/DatabaseSettings.utils.ts
new file mode 100644
index 00000000000..398789c05d7
--- /dev/null
+++ b/apps/studio/components/interfaces/Connect/DatabaseSettings.utils.ts
@@ -0,0 +1,388 @@
+import type { PoolingConfiguration } from 'data/database/pooling-configuration-query'
+
+type ConnectionStrings = {
+ psql: string
+ uri: string
+ golang: string
+ jdbc: string
+ dotnet: string
+ nodejs: string
+ php: string
+ python: string
+ sqlalchemy: string
+}
+
+export const getConnectionStrings = (
+ connectionInfo: {
+ db_user: string
+ db_port: number
+ db_host: string
+ db_name: string
+ },
+ poolingInfo: PoolingConfiguration,
+ metadata: {
+ projectRef?: string
+ pgVersion?: string
+ }
+): {
+ direct: ConnectionStrings
+ pooler: ConnectionStrings
+} => {
+ const isMd5 = poolingInfo.connectionString.includes('options=reference')
+ const { projectRef } = metadata
+ const password = '[YOUR-PASSWORD]'
+
+ // Direct connection variables
+ const directUser = connectionInfo.db_user
+ const directPort = connectionInfo.db_port
+ const directHost = connectionInfo.db_host
+ const directName = connectionInfo.db_name
+
+ // Pooler connection variables
+ const poolerUser = poolingInfo.db_user
+ const poolerPort = poolingInfo.db_port
+ const poolerHost = poolingInfo.db_host
+ const poolerName = poolingInfo.db_name
+
+ // Direct connection strings
+ const directPsqlString = isMd5
+ ? `psql "postgresql://${directUser}:${password}@${directHost}:${directPort}/${directName}"`
+ : `psql -h ${directHost} -p ${directPort} -d ${directName} -U ${directUser}`
+
+ const directUriString = `postgresql://${directUser}:${password}@${directHost}:${directPort}/${directName}`
+
+ const directGolangString = `DATABASE_URL=${poolingInfo.connectionString}`
+
+ const directJdbcString = `jdbc:postgresql://${directHost}:${directPort}/${directName}?user=${directUser}&password=${password}`
+
+ // User Id=${directUser};Password=${password};Server=${directHost};Port=${directPort};Database=${directName}`
+ const directDotNetString = `{
+ "ConnectionStrings": {
+ "DefaultConnection": "Host=${directHost};Database=${directName};Username=${directUser};Password=${password};SSL Mode=Require;Trust Server Certificate=true"
+ }
+}`
+
+ // `User Id=${poolerUser};Password=${password};Server=${poolerHost};Port=${poolerPort};Database=${poolerName}${isMd5 ? `;Options='reference=${projectRef}'` : ''}`
+ const poolerDotNetString = `{
+ "ConnectionStrings": {
+ "DefaultConnection": "User Id=${poolerUser};Password=${password};Server=${poolerHost};Port=${poolerPort};Database=${poolerName}${isMd5 ? `;Options='reference=${projectRef}'` : ''}"
+ }
+}`
+
+ // Pooler connection strings
+ const poolerPsqlString = isMd5
+ ? `psql "postgresql://${poolerUser}:${password}@${poolerHost}:${poolerPort}/${poolerName}?options=reference%3D${projectRef}"`
+ : `psql -h ${poolerHost} -p ${poolerPort} -d ${poolerName} -U ${poolerUser}.${projectRef}`
+
+ const poolerUriString = poolingInfo.connectionString
+
+ const nodejsPoolerUriString = `DATABASE_URL=${poolingInfo.connectionString}`
+
+ const poolerGolangString = `user=${poolerUser}
+password=${password}
+host=${poolerHost}
+port=${poolerPort}
+dbname=${poolerName}${isMd5 ? `options=reference=${projectRef}` : ''}`
+
+ const poolerJdbcString = `jdbc:postgresql://${poolerHost}:${poolerPort}/${poolerName}?user=${poolerUser}${isMd5 ? `&options=reference%3D${projectRef}` : ''}&password=${password}`
+
+ const sqlalchemyString = `user=${directUser}
+password=${password}
+host=${directHost}
+port=${directPort}
+dbname=${directName}`
+
+ const poolerSqlalchemyString = `user=${poolerUser}
+password=${password}
+host=${poolerHost}
+port=${poolerPort}
+dbname=${poolerName}`
+
+ return {
+ direct: {
+ psql: directPsqlString,
+ uri: directUriString,
+ golang: directGolangString,
+ jdbc: directJdbcString,
+ dotnet: directDotNetString,
+ nodejs: nodejsPoolerUriString,
+ php: directGolangString,
+ python: directGolangString,
+ sqlalchemy: sqlalchemyString,
+ },
+ pooler: {
+ psql: poolerPsqlString,
+ uri: poolerUriString,
+ golang: poolerGolangString,
+ jdbc: poolerJdbcString,
+ dotnet: poolerDotNetString,
+ nodejs: nodejsPoolerUriString,
+ php: poolerGolangString,
+ python: poolerGolangString,
+ sqlalchemy: poolerSqlalchemyString,
+ },
+ }
+}
+
+const DB_USER_DESC = 'Database user (e.g postgres)'
+const DB_PASS_DESC = 'Database password'
+const DB_NAME_DESC = 'Database name (e.g postgres)'
+const PROJECT_REF_DESC = "Project's reference ID"
+const PORT_NUMBER_DESC = 'Port number (Use 5432 if using prepared statements)'
+
+// [Joshen] This is to the best of interpreting the syntax from the API response
+// // There's different format for PG13 (depending on authentication method being md5) and PG14
+export const constructConnStringSyntax = (
+ connString: string,
+ {
+ selectedTab,
+ usePoolerConnection,
+ ref,
+ cloudProvider,
+ region,
+ tld,
+ portNumber,
+ }: {
+ selectedTab: 'uri' | 'psql' | 'golang' | 'jdbc' | 'dotnet' | 'nodejs' | 'php' | 'python'
+ usePoolerConnection: boolean
+ ref: string
+ cloudProvider: string
+ region: string
+ tld: string
+ portNumber: string
+ }
+) => {
+ const isMd5 = connString.includes('options=reference')
+ const poolerHostDetails = [
+ { value: cloudProvider.toLocaleLowerCase(), tooltip: 'Cloud provider' },
+ { value: '-0-', tooltip: undefined },
+ { value: region, tooltip: "Project's region" },
+ { value: `.pooler.supabase.${tld}`, tooltip: undefined },
+ ]
+ const dbHostDetails = [
+ { value: 'db.', tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ { value: `.supabase.${tld}`, tooltip: undefined },
+ ]
+
+ if (selectedTab === 'uri' || selectedTab === 'nodejs') {
+ if (isMd5) {
+ return [
+ { value: 'postgresql://', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ { value: ':', tooltip: undefined },
+ { value: '[password]', tooltip: DB_PASS_DESC },
+ { value: '@', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: ':', tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: '/', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: `?options=reference%3D`, tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ ]
+ : []),
+ ]
+ } else {
+ return [
+ { value: 'postgresql://', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: '.', tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ ]
+ : []),
+ { value: ':', tooltip: undefined },
+ { value: '[password]', tooltip: DB_PASS_DESC },
+ { value: '@', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: ':', tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: '/', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ ]
+ }
+ }
+
+ if (selectedTab === 'psql') {
+ if (isMd5) {
+ return [
+ { value: 'psql "postgresql://', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ { value: ':', tooltip: undefined },
+ { value: '[password]', tooltip: DB_PASS_DESC },
+ { value: '@', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: ':', tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: '/', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: '?options=reference%3D', tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ ]
+ : []),
+ ]
+ } else {
+ return [
+ { value: 'psql -h ', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: ' -p ', tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: ' -d ', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ { value: ' -U ', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: '.', tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ ]
+ : []),
+ ]
+ }
+ }
+
+ if (selectedTab === 'golang' || selectedTab === 'php' || selectedTab === 'python') {
+ if (isMd5) {
+ return [
+ { value: 'user=', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ { value: ' password=', tooltip: undefined },
+ { value: '[password]', tooltip: DB_PASS_DESC },
+ { value: ' host=', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: ' port=', tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: ' dbname=', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: ' options=reference=', tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ ]
+ : []),
+ ]
+ } else {
+ return [
+ { value: 'user=', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: '.', tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ ]
+ : []),
+ { value: ' password=', tooltip: undefined },
+ { value: '[password]', tooltip: DB_PASS_DESC },
+ { value: ' host=', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: ' port=', tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: ' dbname=', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ ]
+ }
+ }
+
+ if (selectedTab === 'jdbc') {
+ if (isMd5) {
+ return [
+ { value: 'jdbc:postgresql://', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: ':', tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: '/', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ { value: '?user=', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ { value: '&password=', tooltip: undefined },
+ { value: '[password]', tooltip: DB_PASS_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: '&options=reference%3D', tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ ]
+ : []),
+ ]
+ } else {
+ return [
+ { value: 'jdbc:postgresql://', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: `:`, tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: '/', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ { value: '?user=', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: '.', tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ ]
+ : []),
+ { value: '&password=', tooltip: undefined },
+ { value: '[password]', tooltip: DB_PASS_DESC },
+ ]
+ }
+ }
+
+ if (selectedTab === 'dotnet') {
+ if (isMd5) {
+ return [
+ { value: 'User Id=', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ { value: ';Password=', tooltip: undefined },
+ { value: '[password]', tooltip: DB_PASS_DESC },
+ { value: ';Server=', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: ';Port=', tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: ';Database=', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: ";Options='reference=", tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ { value: "'", tooltip: undefined },
+ ]
+ : []),
+ ]
+ } else {
+ return [
+ { value: 'User Id=', tooltip: undefined },
+ { value: '[user]', tooltip: DB_USER_DESC },
+ ...(usePoolerConnection
+ ? [
+ { value: '.', tooltip: undefined },
+ { value: ref, tooltip: PROJECT_REF_DESC },
+ ]
+ : []),
+ { value: ';Password=', tooltip: undefined },
+ { value: '[password]', tooltip: DB_PASS_DESC },
+ { value: ';Server=', tooltip: undefined },
+ ...(usePoolerConnection ? poolerHostDetails : dbHostDetails),
+ { value: ';Port=', tooltip: undefined },
+ { value: portNumber, tooltip: PORT_NUMBER_DESC },
+ { value: ';Database=', tooltip: undefined },
+ { value: '[db-name]', tooltip: DB_NAME_DESC },
+ ]
+ }
+ }
+
+ return []
+}
+
+export const getPoolerTld = (connString: string) => {
+ try {
+ const segment = connString.split('pooler.supabase.')[1]
+ const tld = segment.split(':6543')[0]
+ return tld
+ } catch {
+ return 'com'
+ }
+}
diff --git a/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx b/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx
new file mode 100644
index 00000000000..80084d1337d
--- /dev/null
+++ b/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx
@@ -0,0 +1,153 @@
+export type Example = {
+ installCommands?: string[]
+ postInstallCommands?: string[]
+ files?: {
+ name: string
+ content: string
+ }[]
+}
+
+const examples = {
+ nodejs: {
+ installCommands: ['npm install postgres'],
+ files: [
+ {
+ name: 'db.js',
+ content: `import postgres from 'postgres'
+
+const connectionString = process.env.DATABASE_URL
+const sql = postgres(connectionString)
+
+export default sql`,
+ },
+ ],
+ },
+ golang: {
+ installCommands: ['go get github.com/jackc/pgx/v5'],
+ files: [
+ {
+ name: 'main.go',
+ content: `package main
+
+import (
+ "context"
+ "log"
+ "os"
+ "github.com/jackc/pgx/v5"
+)
+
+func main() {
+ conn, err := pgx.Connect(context.Background(), os.Getenv("DATABASE_URL"))
+ if err != nil {
+ log.Fatalf("Failed to connect to the database: %v", err)
+ }
+ defer conn.Close(context.Background())
+
+ // Example query to test connection
+ var version string
+ if err := conn.QueryRow(context.Background(), "SELECT version()").Scan(&version); err != nil {
+ log.Fatalf("Query failed: %v", err)
+ }
+
+ log.Println("Connected to:", version)
+}`,
+ },
+ ],
+ },
+ dotnet: {
+ installCommands: [
+ 'dotnet add package Microsoft.Extensions.Configuration.Json --version YOUR_DOTNET_VERSION',
+ ],
+ postInstallCommands: [
+ 'dotnet add package Microsoft.Extensions.Configuration.Json --version YOUR_DOTNET_VERSION',
+ ],
+ },
+ python: {
+ installCommands: ['pip install python-dotenv psycopg2'],
+ files: [
+ {
+ name: 'main.py',
+ content: `import psycopg2
+from dotenv import load_dotenv
+import os
+
+# Load environment variables from .env
+load_dotenv()
+
+# Fetch variables
+USER = os.getenv("user")
+PASSWORD = os.getenv("password")
+HOST = os.getenv("host")
+PORT = os.getenv("port")
+DBNAME = os.getenv("dbname")
+
+# Connect to the database
+try:
+ connection = psycopg2.connect(
+ user=USER,
+ password=PASSWORD,
+ host=HOST,
+ port=PORT,
+ dbname=DBNAME
+ )
+ print("Connection successful!")
+
+ # Create a cursor to execute SQL queries
+ cursor = connection.cursor()
+
+ # Example query
+ cursor.execute("SELECT NOW();")
+ result = cursor.fetchone()
+ print("Current Time:", result)
+
+ # Close the cursor and connection
+ cursor.close()
+ connection.close()
+ print("Connection closed.")
+
+except Exception as e:
+ print(f"Failed to connect: {e}")`,
+ },
+ ],
+ },
+ sqlalchemy: {
+ installCommands: ['pip install python-dotenv sqlalchemy psycopg2'],
+ files: [
+ {
+ name: 'main.py',
+ content: `from sqlalchemy import create_engine
+# from sqlalchemy.pool import NullPool
+from dotenv import load_dotenv
+import os
+
+# Load environment variables from .env
+load_dotenv()
+
+# Fetch variables
+USER = os.getenv("user")
+PASSWORD = os.getenv("password")
+HOST = os.getenv("host")
+PORT = os.getenv("port")
+DBNAME = os.getenv("dbname")
+
+# Construct the SQLAlchemy connection string
+DATABASE_URL = f"postgresql+psycopg2://{USER}:{PASSWORD}@{HOST}:{PORT}/{DBNAME}?sslmode=require"
+
+# Create the SQLAlchemy engine
+engine = create_engine(DATABASE_URL)
+# If using Transaction Pooler or Session Pooler, we want to ensure we disable SQLAlchemy client side pooling -
+# https://docs.sqlalchemy.org/en/20/core/pooling.html#switching-pool-implementations
+# engine = create_engine(DATABASE_URL, poolclass=NullPool)
+
+# Test the connection
+try:
+ with engine.connect() as connection:
+ print("Connection successful!")
+except Exception as e:
+ print(f"Failed to connect: {e}")`,
+ },
+ ],
+ },
+}
+
+export default examples
diff --git a/apps/studio/components/interfaces/Connect/PoolerIcons.tsx b/apps/studio/components/interfaces/Connect/PoolerIcons.tsx
new file mode 100644
index 00000000000..945052bbeb9
--- /dev/null
+++ b/apps/studio/components/interfaces/Connect/PoolerIcons.tsx
@@ -0,0 +1,485 @@
+import { AnimatePresence, motion } from 'framer-motion'
+import { Fragment, useEffect, useState } from 'react'
+
+import { Database } from 'icons'
+import { cn } from 'ui'
+
+// Add overall icon dimension controls
+const ICON_WIDTH = 48
+const ICON_HEIGHT = 96
+
+// Add these to your existing constants section
+const LINE_WIDTH = 2 // SVG container width
+const LINE_STROKE_WIDTH = 1 // Width of the actual line
+const LINE_OFFSET = 1 // For centering the line in container
+
+const FlowingLine = ({
+ x,
+ y1,
+ y2,
+ isActive,
+}: {
+ x: number
+ y1: number
+ y2: number
+ isActive: boolean
+}) => {
+ return (
+ <AnimatePresence>
+ {isActive && (
+ <svg
+ width={LINE_WIDTH}
+ height={y2 - y1 + 6}
+ viewBox={`0 0 ${LINE_WIDTH} ${y2 - y1 + 6}`}
+ style={{ position: 'absolute', left: x - LINE_OFFSET, top: y1 - 3 }}
+ >
+ <motion.line
+ x1="1"
+ y1="3"
+ x2="1"
+ y2={y2 - y1 + 3}
+ stroke="hsl(var(--foreground-default) / 0.6)"
+ strokeWidth={LINE_STROKE_WIDTH}
+ strokeLinecap="round"
+ initial={{ pathLength: 0, opacity: 0 }}
+ animate={{ pathLength: 1, opacity: 1 }}
+ exit={{ pathLength: 0, opacity: 0 }}
+ transition={{ duration: 0.2 }}
+ />
+ <defs>
+ <motion.linearGradient
+ id={`lineGradient-${x}-${y1}-${y2}`}
+ gradientUnits="userSpaceOnUse"
+ x1="2"
+ y1="-20"
+ x2="2"
+ y2={y2 - y1 + 26}
+ animate={{
+ y1: [-20, y2 - y1 + 26],
+ y2: [0, y2 - y1 + 46],
+ }}
+ transition={{
+ duration: 1,
+ repeat: Infinity,
+ ease: 'linear',
+ repeatDelay: 0,
+ }}
+ >
+ <stop offset="0" stopColor="hsl(var(--foreground-default) / 0.6)" stopOpacity="0" />
+ <stop offset="0.8" stopColor="hsl(var(--foreground-default))" />
+ <stop offset="1" stopColor="hsl(var(--foreground-default) / 0.6)" stopOpacity="0" />
+ </motion.linearGradient>
+ </defs>
+ <motion.line
+ x1="2"
+ y1="3"
+ x2="2"
+ y2={y2 - y1 + 3}
+ stroke={`url(#lineGradient-${x}-${y1}-${y2})`}
+ strokeWidth={LINE_STROKE_WIDTH}
+ strokeLinecap="round"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.2 }}
+ />
+ </svg>
+ )}
+ </AnimatePresence>
+ )
+}
+
+const TopRect = ({ isActive }: { isActive: boolean }) => (
+ <motion.rect
+ width={RECT_WIDTH}
+ height={3}
+ className={cn(
+ 'fill-background-surface-200 stroke-border-stronger stroke-[1]',
+ isActive && 'stroke-foreground/40'
+ )}
+ x={RECT_X}
+ y={TOP_RECT_Y}
+ rx="1.5"
+ animate={{
+ boxShadow: isActive ? '0 0 8px #86efac' : '0 0 0px #86efac',
+ }}
+ transition={{ duration: 0.2 }}
+ />
+)
+
+const BottomRect = ({ isActive }: { isActive: boolean }) => (
+ <g>
+ <motion.rect
+ width={RECT_WIDTH}
+ height={32}
+ className={cn(
+ 'stroke-brand-500 fill-brand-300 stroke-[1] transition-all',
+ isActive && 'fill-brand-400 stroke-brand',
+ 'flex items-center justify-center'
+ )}
+ x={RECT_X}
+ y={BOTTOM_RECT_Y}
+ rx="4"
+ animate={{
+ fill: isActive ? '#2563eb' : '#1e40af',
+ stroke: '#93c5fd',
+ boxShadow: isActive ? '0 0 8px #93c5fd' : '0 0 0px #93c5fd',
+ }}
+ transition={{ duration: 0.2 }}
+ />
+ <Database
+ size={21}
+ className={cn('w-4 h-4 text-brand-500 transition-all', isActive && 'text-brand')}
+ x={RECT_X + RECT_WIDTH / 6} // Center horizontally (8 is half of icon width)
+ y={BOTTOM_RECT_Y + 5.5} // Center vertically (16 is half of rect height, 8 is half of icon height)
+ strokeWidth={1}
+ />
+ </g>
+)
+
+// Update existing constants to use these dimensions
+const TOP_LINE_START = ICON_HEIGHT * 0.18 // 20% from top
+const TOP_LINE_END = ICON_HEIGHT * 0.28 // 48% from top
+const BOTTOM_LINE_START = ICON_HEIGHT * 0.4 // 65% from top
+const BOTTOM_LINE_END = ICON_HEIGHT * 0.59 // 80% from top
+
+// Update rect positions and dimensions
+const TOP_RECT_Y = ICON_HEIGHT * 0.32 // 55% from top
+const BOTTOM_RECT_Y = ICON_HEIGHT * 0.64 // 85% from top
+const RECT_X = ICON_WIDTH * 0.17 // ~17% from left
+const RECT_WIDTH = ICON_WIDTH * 0.67 // ~67% of total width
+
+// Update circle positions
+const CIRCLE_Y = ICON_HEIGHT * 0.13 // 13% from top
+const CIRCLE_SPACING = ICON_WIDTH * 0.25 // 25% of width
+const CIRCLE_START_X = ICON_WIDTH * 0.25 // 25% from left
+const CIRCLE_RADIUS = ICON_WIDTH * 0.055 // ~3.8% of width
+
+// Static circle for SessionIcon
+const ConnectionDot = ({ index, isActive }: { index: number; isActive: boolean }) => (
+ <circle
+ cx={CIRCLE_START_X + index * CIRCLE_SPACING}
+ cy={CIRCLE_Y}
+ r={CIRCLE_RADIUS}
+ className={isActive ? 'fill-foreground' : 'fill-foreground-lighter'}
+ />
+)
+
+export const TransactionIcon = () => {
+ const [dots, setDots] = useState([false, false, false])
+ const [lines, setLines] = useState([false, false, false])
+ const [bottomLineActive, setBottomLineActive] = useState(false)
+
+ useEffect(() => {
+ // Watch lines state and update bottomLineActive accordingly
+ setBottomLineActive(lines.some(Boolean))
+ }, [lines])
+
+ useEffect(() => {
+ const animateDot = (index: number) => {
+ // Clear previous state
+ setDots((prev) => {
+ const newState = [...prev]
+ newState[index] = false
+ return newState
+ })
+ setLines((prev) => {
+ const newState = [...prev]
+ newState[index] = false
+ return newState
+ })
+
+ // Step 1: Animate dot in
+ setTimeout(() => {
+ setDots((prev) => {
+ const newState = [...prev]
+ newState[index] = true
+ return newState
+ })
+ }, 0)
+
+ // Step 2: After dot is in, wait, then show line
+ setTimeout(() => {
+ setLines((prev) => {
+ const newState = [...prev]
+ newState[index] = true
+ return newState
+ })
+ }, 400) // Wait 400ms after dot appears before showing line
+
+ // Step 3: Clear everything
+ setTimeout(() => {
+ setDots((prev) => {
+ const newState = [...prev]
+ newState[index] = false
+ return newState
+ })
+ setLines((prev) => {
+ const newState = [...prev]
+ newState[index] = false
+ return newState
+ })
+ }, 1000) // Total animation duration
+ }
+
+ // Initial staggered animation
+ setTimeout(() => animateDot(0), 0)
+ setTimeout(() => animateDot(1), 200)
+ setTimeout(() => animateDot(2), 400)
+
+ // Set up intervals for continuous animation
+ const intervals = [0, 1, 2].map((index) =>
+ setInterval(() => animateDot(index), 3000 + index * 200)
+ )
+
+ return () => intervals.forEach(clearInterval)
+ }, [])
+
+ return (
+ <div
+ style={{ position: 'relative', width: ICON_WIDTH, height: ICON_HEIGHT }}
+ // className="bg-surface-200"
+ >
+ <svg width={ICON_WIDTH} height={ICON_HEIGHT} viewBox={`0 0 ${ICON_WIDTH} ${ICON_HEIGHT}`}>
+ {[0, 1, 2].map((index) => (
+ <Fragment key={index}>
+ <AnimatePresence>
+ {dots[index] && (
+ <motion.circle
+ cx={CIRCLE_START_X + index * CIRCLE_SPACING}
+ cy={CIRCLE_Y}
+ r={CIRCLE_RADIUS}
+ className={'fill-foreground'}
+ initial={{
+ scale: 0,
+ x: [-8, -5, -2][index],
+ y: -10,
+ }}
+ animate={{
+ scale: 1,
+ x: 0,
+ y: 0,
+ }}
+ exit={{
+ scale: 0,
+ x: [8, 5, 2][index],
+ y: -10,
+ }}
+ transition={{
+ type: 'spring',
+ stiffness: 500,
+ damping: 30,
+ }}
+ />
+ )}
+ </AnimatePresence>
+ </Fragment>
+ ))}
+ <TopRect isActive={bottomLineActive} />
+ <BottomRect isActive={true} />
+ </svg>
+ {[0, 1, 2].map((index) => (
+ <FlowingLine
+ key={index}
+ x={CIRCLE_START_X + index * CIRCLE_SPACING}
+ y1={TOP_LINE_START}
+ y2={TOP_LINE_END}
+ isActive={lines[index]}
+ />
+ ))}
+ <FlowingLine
+ x={CIRCLE_START_X + 0.5 * CIRCLE_SPACING}
+ y1={BOTTOM_LINE_START}
+ y2={BOTTOM_LINE_END}
+ isActive={true}
+ />
+ <FlowingLine
+ x={CIRCLE_START_X + 1.5 * CIRCLE_SPACING}
+ y1={BOTTOM_LINE_START}
+ y2={BOTTOM_LINE_END}
+ isActive={true}
+ />
+ </div>
+ )
+}
+
+export const SessionIcon = () => {
+ const [topLineStates, setTopLineStates] = useState([false, false, false])
+ const [bottomLineStates, setBottomLineStates] = useState([false, false, false])
+
+ useEffect(() => {
+ // Function to animate a single dot
+ const animateDot = (index: number) => {
+ setTopLineStates((prev) => {
+ const newState = [...prev]
+ newState[index] = true
+ return newState
+ })
+
+ setTimeout(() => {
+ setBottomLineStates((prev) => {
+ const newState = [...prev]
+ newState[index] = true
+ return newState
+ })
+ }, 300)
+
+ setTimeout(() => {
+ setTopLineStates((prev) => {
+ const newState = [...prev]
+ newState[index] = false
+ return newState
+ })
+ setBottomLineStates((prev) => {
+ const newState = [...prev]
+ newState[index] = false
+ return newState
+ })
+ }, 5000)
+ }
+
+ // Start initial animations immediately with slight delays
+ setTimeout(() => animateDot(0), 100)
+ setTimeout(() => animateDot(1), 1500)
+ setTimeout(() => animateDot(2), 3000)
+
+ // Set up intervals for subsequent animations
+ const intervals = [0, 1, 2].map((index) =>
+ setInterval(() => animateDot(index), Math.random() * 3000 + 8000)
+ )
+
+ return () => intervals.forEach(clearInterval)
+ }, [])
+
+ return (
+ <div
+ style={{ position: 'relative', width: ICON_WIDTH, height: ICON_HEIGHT }}
+ // className="bg-surface-200"
+ >
+ <svg width={ICON_WIDTH} height={ICON_HEIGHT} viewBox={`0 0 ${ICON_WIDTH} ${ICON_HEIGHT}`}>
+ {[0, 1, 2].map((index) => (
+ <g key={index}>
+ <ConnectionDot index={index} isActive={topLineStates[index]} />
+ </g>
+ ))}
+ <TopRect isActive={topLineStates.some((state) => state)} />
+ <BottomRect isActive={bottomLineStates.some((state) => state)} />
+ </svg>
+ {[0, 1, 2].map((index) => (
+ <Fragment key={index}>
+ <FlowingLine
+ x={CIRCLE_START_X + index * CIRCLE_SPACING}
+ y1={TOP_LINE_START}
+ y2={TOP_LINE_END}
+ isActive={topLineStates[index]}
+ />
+ <FlowingLine
+ x={CIRCLE_START_X + index * CIRCLE_SPACING}
+ y1={BOTTOM_LINE_START}
+ y2={BOTTOM_LINE_END}
+ isActive={bottomLineStates[index]}
+ />
+ </Fragment>
+ ))}
+ </div>
+ )
+}
+
+export const DirectConnectionIcon = () => {
+ const [dots, setDots] = useState([false, false, false])
+ const [lines, setLines] = useState([false, false, false])
+
+ useEffect(() => {
+ // Function to animate a single dot
+ const animateDot = (index: number) => {
+ setDots((prev) => {
+ const newState = [...prev]
+ newState[index] = true
+ return newState
+ })
+ setLines((prev) => {
+ const newState = [...prev]
+ newState[index] = true
+ return newState
+ })
+
+ // Clear after 2.5s
+ setTimeout(() => {
+ setDots((prev) => {
+ const newState = [...prev]
+ newState[index] = false
+ return newState
+ })
+ setLines((prev) => {
+ const newState = [...prev]
+ newState[index] = false
+ return newState
+ })
+ }, 2500)
+ }
+
+ // Initial staggered animation
+ // Start initial animations immediately with slight delays
+ setTimeout(() => animateDot(0), 100)
+ setTimeout(() => animateDot(1), 1500)
+ setTimeout(() => animateDot(2), 3000)
+
+ // Set up intervals for continuous animation
+ const intervals = [0, 1, 2].map((index) =>
+ setInterval(() => animateDot(index), Math.random() * 3000 + 8000)
+ )
+
+ return () => intervals.forEach(clearInterval)
+ }, [])
+
+ return (
+ <div style={{ position: 'relative', width: ICON_WIDTH, height: ICON_HEIGHT }}>
+ <svg width={ICON_WIDTH} height={ICON_HEIGHT} viewBox={`0 0 ${ICON_WIDTH} ${ICON_HEIGHT}`}>
+ {[0, 1, 2].map((index) => (
+ <Fragment key={index}>
+ <AnimatePresence>
+ {dots[index] && (
+ <motion.circle
+ cx={CIRCLE_START_X + index * CIRCLE_SPACING}
+ cy={CIRCLE_Y}
+ r={CIRCLE_RADIUS}
+ className={'fill-foreground'}
+ initial={{
+ scale: 0,
+ x: [-8, -5, -2][index],
+ y: -10,
+ }}
+ animate={{
+ scale: 1,
+ x: 0,
+ y: 0,
+ }}
+ exit={{
+ scale: 0,
+ x: [8, 5, 2][index],
+ y: -10,
+ }}
+ transition={{
+ type: 'spring',
+ stiffness: 500,
+ damping: 30,
+ }}
+ />
+ )}
+ </AnimatePresence>
+ </Fragment>
+ ))}
+ <BottomRect isActive={lines.some((state) => state)} />
+ </svg>
+ {[0, 1, 2].map((index) => (
+ <FlowingLine
+ key={index}
+ x={CIRCLE_START_X + index * CIRCLE_SPACING}
+ y1={TOP_LINE_START}
+ y2={BOTTOM_LINE_END}
+ isActive={lines[index]}
+ />
+ ))}
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/Home/Connect/content/androidkotlin/supabasekt/content.tsx b/apps/studio/components/interfaces/Connect/content/androidkotlin/supabasekt/content.tsx
similarity index 93%
rename from apps/studio/components/interfaces/Home/Connect/content/androidkotlin/supabasekt/content.tsx
rename to apps/studio/components/interfaces/Connect/content/androidkotlin/supabasekt/content.tsx
index bcb90e3c9a5..9e1be901e59 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/androidkotlin/supabasekt/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/androidkotlin/supabasekt/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTriggers,
ConnectTabTrigger,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/astro/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/astro/supabasejs/content.tsx
similarity index 91%
rename from apps/studio/components/interfaces/Home/Connect/content/astro/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/astro/supabasejs/content.tsx
index a88f865dde2..1ce13c63f32 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/astro/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/astro/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTriggers,
ConnectTabTrigger,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/drizzle/content.tsx b/apps/studio/components/interfaces/Connect/content/drizzle/content.tsx
similarity index 92%
rename from apps/studio/components/interfaces/Home/Connect/content/drizzle/content.tsx
rename to apps/studio/components/interfaces/Connect/content/drizzle/content.tsx
index de06febc660..5f33d70a759 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/drizzle/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/drizzle/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ connectionStringPooler }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/exporeactnative/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/exporeactnative/supabasejs/content.tsx
similarity index 94%
rename from apps/studio/components/interfaces/Home/Connect/content/exporeactnative/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/exporeactnative/supabasejs/content.tsx
index 00fc5873977..fdae1dcdba1 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/exporeactnative/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/exporeactnative/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/flutter/supabaseflutter/content.tsx b/apps/studio/components/interfaces/Connect/content/flutter/supabaseflutter/content.tsx
similarity index 93%
rename from apps/studio/components/interfaces/Home/Connect/content/flutter/supabaseflutter/content.tsx
rename to apps/studio/components/interfaces/Connect/content/flutter/supabaseflutter/content.tsx
index 8ae2c76a4d0..2eb7d6651ee 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/flutter/supabaseflutter/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/flutter/supabaseflutter/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTriggers,
ConnectTabTrigger,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/ionicangular/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/ionicangular/supabasejs/content.tsx
similarity index 96%
rename from apps/studio/components/interfaces/Home/Connect/content/ionicangular/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/ionicangular/supabasejs/content.tsx
index 4a51e5f27a1..3beda75cbd0 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/ionicangular/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/ionicangular/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTriggers,
ConnectTabTrigger,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/ionicreact/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/ionicreact/supabasejs/content.tsx
similarity index 95%
rename from apps/studio/components/interfaces/Home/Connect/content/ionicreact/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/ionicreact/supabasejs/content.tsx
index 193a6e6719d..0971e6979bc 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/ionicreact/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/ionicreact/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTriggers,
ConnectTabTrigger,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/nextjs/app/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx
similarity index 96%
rename from apps/studio/components/interfaces/Home/Connect/content/nextjs/app/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx
index 2ff11fda1fc..e6d1be4fc26 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/nextjs/app/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/nextjs/pages/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/nextjs/pages/supabasejs/content.tsx
similarity index 93%
rename from apps/studio/components/interfaces/Home/Connect/content/nextjs/pages/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/nextjs/pages/supabasejs/content.tsx
index f22c1474db0..5ad87160931 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/nextjs/pages/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/nextjs/pages/supabasejs/content.tsx
@@ -1,12 +1,12 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
+import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
import {
+ ConnectTabContent,
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
- ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
-import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
+} from 'components/interfaces/Connect/ConnectTabs'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
return (
diff --git a/apps/studio/components/interfaces/Home/Connect/content/nuxt/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/nuxt/supabasejs/content.tsx
similarity index 92%
rename from apps/studio/components/interfaces/Home/Connect/content/nuxt/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/nuxt/supabasejs/content.tsx
index 6b0428be949..b07237bad6e 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/nuxt/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/nuxt/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/prisma/content.tsx b/apps/studio/components/interfaces/Connect/content/prisma/content.tsx
similarity index 89%
rename from apps/studio/components/interfaces/Home/Connect/content/prisma/content.tsx
rename to apps/studio/components/interfaces/Connect/content/prisma/content.tsx
index 1094ad05e24..56c5371b9db 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/prisma/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/prisma/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ connectionStringPooler }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/react/create-react-app/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/react/create-react-app/supabasejs/content.tsx
similarity index 93%
rename from apps/studio/components/interfaces/Home/Connect/content/react/create-react-app/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/react/create-react-app/supabasejs/content.tsx
index de20afa3284..c5b84f69027 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/react/create-react-app/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/react/create-react-app/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/react/vite/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/react/vite/supabasejs/content.tsx
similarity index 93%
rename from apps/studio/components/interfaces/Home/Connect/content/react/vite/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/react/vite/supabasejs/content.tsx
index f7b0c82ff92..465d8bf0978 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/react/vite/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/react/vite/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/refine/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/refine/supabasejs/content.tsx
similarity index 95%
rename from apps/studio/components/interfaces/Home/Connect/content/refine/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/refine/supabasejs/content.tsx
index 6c5cd2ea118..c87fdff6bda 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/refine/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/refine/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/remix/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/remix/supabasejs/content.tsx
similarity index 94%
rename from apps/studio/components/interfaces/Home/Connect/content/remix/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/remix/supabasejs/content.tsx
index 4487cf53afd..324eac69426 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/remix/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/remix/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTriggers,
ConnectTabTrigger,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/solidjs/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/solidjs/supabasejs/content.tsx
similarity index 92%
rename from apps/studio/components/interfaces/Home/Connect/content/solidjs/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/solidjs/supabasejs/content.tsx
index 9ab97360e6f..9cd17ddd257 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/solidjs/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/solidjs/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/sveltekit/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/sveltekit/supabasejs/content.tsx
similarity index 93%
rename from apps/studio/components/interfaces/Home/Connect/content/sveltekit/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/sveltekit/supabasejs/content.tsx
index 7b058645c07..5f326bfb8e1 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/sveltekit/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/sveltekit/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTriggers,
ConnectTabTrigger,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/swift/supabaseswift/content.tsx b/apps/studio/components/interfaces/Connect/content/swift/supabaseswift/content.tsx
similarity index 92%
rename from apps/studio/components/interfaces/Home/Connect/content/swift/supabaseswift/content.tsx
rename to apps/studio/components/interfaces/Connect/content/swift/supabaseswift/content.tsx
index 43ced097a49..83b5c4f0a39 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/swift/supabaseswift/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/swift/supabaseswift/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTriggers,
ConnectTabTrigger,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/content/vuejs/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/vuejs/supabasejs/content.tsx
similarity index 92%
rename from apps/studio/components/interfaces/Home/Connect/content/vuejs/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Connect/content/vuejs/supabasejs/content.tsx
index 5ab61da9c8a..9f10023c135 100644
--- a/apps/studio/components/interfaces/Home/Connect/content/vuejs/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/vuejs/supabasejs/content.tsx
@@ -1,11 +1,11 @@
-import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
import {
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
ConnectTabContent,
-} from 'components/interfaces/Home/Connect/ConnectTabs'
+} from 'components/interfaces/Connect/ConnectTabs'
import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectDropdown.tsx b/apps/studio/components/interfaces/Home/Connect/ConnectDropdown.tsx
deleted file mode 100644
index 7f4217fb52a..00000000000
--- a/apps/studio/components/interfaces/Home/Connect/ConnectDropdown.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-import { Box, Check, ChevronDown } from 'lucide-react'
-import { useState } from 'react'
-import {
- Button,
- CommandEmpty_Shadcn_,
- CommandGroup_Shadcn_,
- CommandInput_Shadcn_,
- CommandItem_Shadcn_,
- CommandList_Shadcn_,
- Command_Shadcn_,
- PopoverContent_Shadcn_,
- PopoverTrigger_Shadcn_,
- Popover_Shadcn_,
- cn,
-} from 'ui'
-import ConnectionIcon from './ConnectionIcon'
-
-interface ConnectDropdownProps {
- state: string
- updateState: (state: string) => void
- label: string
- items: any[]
-}
-
-const ConnectDropdown = ({
- state,
- updateState,
- label,
-
- items,
-}: ConnectDropdownProps) => {
- const [open, setOpen] = useState(false)
-
- function onSelectLib(key: string) {
- updateState(key)
- setOpen(false)
- }
-
- const selectedItem = items.find((item) => item.key === state)
-
- return (
- <>
- <Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>
- <div className="flex ">
- <span className="flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0">
- {label}
- </span>
- <PopoverTrigger_Shadcn_ asChild>
- <Button size="small" type="default" className="gap-0 rounded-l-none">
- <div className="flex items-center gap-2">
- {selectedItem?.icon ? (
- <ConnectionIcon connection={selectedItem.icon} />
- ) : (
- <Box size={12} />
- )}
- {selectedItem?.label}
- <ChevronDown className="text-muted" strokeWidth={1} size={12} />
- </div>
- </Button>
- </PopoverTrigger_Shadcn_>
- </div>
- <PopoverContent_Shadcn_ className="p-0 max-w-48" side="bottom" align="start">
- <Command_Shadcn_>
- <CommandInput_Shadcn_ placeholder="Search..." />
- <CommandList_Shadcn_>
- <CommandEmpty_Shadcn_>No results found.</CommandEmpty_Shadcn_>
- <CommandGroup_Shadcn_>
- {items.map((item) => (
- <CommandItem_Shadcn_
- key={item.key}
- value={item.key}
- onSelect={() => {
- onSelectLib(item.key)
- setOpen(false)
- }}
- className="flex gap-2 items-center"
- >
- {item.icon ? <ConnectionIcon connection={item.icon} /> : <Box size={12} />}
- {item.label}
- <Check
- size={15}
- className={cn('ml-auto ', item.key === state ? 'opacity-100' : 'opacity-0')}
- />
- </CommandItem_Shadcn_>
- ))}
- </CommandGroup_Shadcn_>
- </CommandList_Shadcn_>
- </Command_Shadcn_>
- </PopoverContent_Shadcn_>
- </Popover_Shadcn_>
- </>
- )
-}
-
-export default ConnectDropdown
diff --git a/apps/studio/components/interfaces/Settings/Database/ConnectionStringMoved.tsx b/apps/studio/components/interfaces/Settings/Database/ConnectionStringMoved.tsx
new file mode 100644
index 00000000000..3852592b862
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/Database/ConnectionStringMoved.tsx
@@ -0,0 +1,53 @@
+import { Button } from 'ui'
+import { Plug, GitBranch, ChevronsUpDown, Pointer } from 'lucide-react'
+
+export const ConnectionStringMoved = () => {
+ return (
+ <div className="w-full flex flex-col xl:flex-row border py-10 pl-10 rounded-md">
+ <div className="flex flex-col gap-0 z-[2]">
+ <p className="text-sm text-foreground">Connection string has moved</p>
+ <p className="text-sm text-foreground-lighter">
+ You can find Project connect details by clicking 'Connect' in the top bar
+ </p>
+ </div>
+ <div className="relative grow flex flex-col -space-y-px">
+ <div className="w-full h-3">
+ <div className="bg-gradient-to-t from-background-surface-300 via-[25%] to-background-200 to-[100%] h-full w-full" />
+ </div>
+ <div className="flex justify-end relative">
+ <div className="bg-dash-sidebar border-b border-t border-t-border-muted py-2 px-10 flex gap-3 relative overflow-hidden">
+ <Button
+ type="text"
+ size="tiny"
+ className="rounded-full pointer-events-none opacity-50"
+ iconRight={<ChevronsUpDown size={12} strokeWidth={1.5} />}
+ >
+ Project name
+ </Button>
+ <Button
+ type="default"
+ size="tiny"
+ className="rounded-full pointer-events-none ring-1 ring-foreground-muted/20"
+ icon={<Plug size={12} className="rotate-90" />}
+ >
+ Connect
+ </Button>
+ <Button
+ type="text"
+ size="tiny"
+ className="rounded-full pointer-events-none -mr-20 opacity-50"
+ icon={<GitBranch size={12} />}
+ >
+ Enable Branching
+ </Button>
+ </div>
+ <Pointer
+ className=" absolute top-7 right-[110px] text-foreground-light fill-background"
+ strokeWidth={1}
+ />
+ </div>
+ <div className="absolute -inset-2 bg-gradient-to-l from-transparent via-background-200 via-[95%] to-background-200 to-[100%] z-[1]" />
+ </div>
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx
index ebfa5449d43..14793602a19 100644
--- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx
@@ -56,6 +56,9 @@ interface DatabaseConnectionStringProps {
appearance: 'default' | 'minimal'
}
+/**
+ * @deprecated Will be removed once `connectDialogUpdate` flag is persisted
+ */
export const DatabaseConnectionString = ({ appearance }: DatabaseConnectionStringProps) => {
const project = useSelectedProject()
const { ref: projectRef, connectionString } = useParams()
diff --git a/apps/studio/components/layouts/AppLayout/OrganizationDropdown.tsx b/apps/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
index e870b080122..039c9ff5d81 100644
--- a/apps/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
+++ b/apps/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
@@ -50,14 +50,12 @@ const OrganizationDropdown = ({ isNewNav = false }: OrganizationDropdownProps) =
<div className="flex items-center">
<Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>
<PopoverTrigger_Shadcn_ asChild>
- <div className="flex items-center space-x-2 cursor-pointer">
- <Button type="text" className="pr-2" iconRight={<ChevronsUpDown />}>
- <div className="flex items-center space-x-2">
- <p className={isNewNav ? 'text-sm' : 'text-xs'}>{orgName}</p>
- {isSuccess && <Badge variant="default">{subscription?.plan.name}</Badge>}
- </div>
- </Button>
- </div>
+ <Button type="text" className="pr-2" iconRight={<ChevronsUpDown />}>
+ <div className="flex items-center space-x-2">
+ <p className={isNewNav ? 'text-sm' : 'text-xs'}>{orgName}</p>
+ {isSuccess && <Badge variant="default">{subscription?.plan.name}</Badge>}
+ </div>
+ </Button>
</PopoverTrigger_Shadcn_>
<PopoverContent_Shadcn_ className="p-0" side="bottom" align="start">
<Command_Shadcn_>
diff --git a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx
index 5e477b21b4a..e2d465bcaa6 100644
--- a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx
+++ b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx
@@ -117,58 +117,56 @@ const ProjectDropdown = ({ isNewNav = false }: ProjectDropdownProps) => {
}
return IS_PLATFORM ? (
- <div className="flex items-center px-2">
- <Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>
- <PopoverTrigger_Shadcn_ asChild>
- <Button type="text" className="pr-2" iconRight={<ChevronsUpDown />}>
- <div className="flex items-center space-x-2">
- <p className={isNewNav ? 'text-sm' : 'text-xs'}>{selectedProject?.name}</p>
- </div>
- </Button>
- </PopoverTrigger_Shadcn_>
- <PopoverContent_Shadcn_ className="p-0" side="bottom" align="start">
- <Command_Shadcn_>
- <CommandInput_Shadcn_ placeholder="Find project..." />
- <CommandList_Shadcn_>
- <CommandEmpty_Shadcn_>No projects found</CommandEmpty_Shadcn_>
- <CommandGroup_Shadcn_>
- <ScrollArea className={(projects || []).length > 7 ? 'h-[210px]' : ''}>
- {projects?.map((project) => (
- <ProjectLink key={project.ref} project={project} setOpen={setOpen} />
- ))}
- </ScrollArea>
- </CommandGroup_Shadcn_>
- {projectCreationEnabled && (
- <>
- <CommandSeparator_Shadcn_ />
- <CommandGroup_Shadcn_>
- <CommandItem_Shadcn_
- className="cursor-pointer w-full"
- onSelect={() => {
+ <Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>
+ <PopoverTrigger_Shadcn_ asChild>
+ <Button type="text" className="pr-2" iconRight={<ChevronsUpDown />}>
+ <div className="flex items-center space-x-2">
+ <p className={isNewNav ? 'text-sm' : 'text-xs'}>{selectedProject?.name}</p>
+ </div>
+ </Button>
+ </PopoverTrigger_Shadcn_>
+ <PopoverContent_Shadcn_ className="p-0" side="bottom" align="start">
+ <Command_Shadcn_>
+ <CommandInput_Shadcn_ placeholder="Find project..." />
+ <CommandList_Shadcn_>
+ <CommandEmpty_Shadcn_>No projects found</CommandEmpty_Shadcn_>
+ <CommandGroup_Shadcn_>
+ <ScrollArea className={(projects || []).length > 7 ? 'h-[210px]' : ''}>
+ {projects?.map((project) => (
+ <ProjectLink key={project.ref} project={project} setOpen={setOpen} />
+ ))}
+ </ScrollArea>
+ </CommandGroup_Shadcn_>
+ {projectCreationEnabled && (
+ <>
+ <CommandSeparator_Shadcn_ />
+ <CommandGroup_Shadcn_>
+ <CommandItem_Shadcn_
+ className="cursor-pointer w-full"
+ onSelect={() => {
+ setOpen(false)
+ router.push(`/new/${selectedOrganization?.slug}`)
+ }}
+ onClick={() => setOpen(false)}
+ >
+ <Link
+ href={`/new/${selectedOrganization?.slug}`}
+ onClick={() => {
setOpen(false)
- router.push(`/new/${selectedOrganization?.slug}`)
}}
- onClick={() => setOpen(false)}
+ className="w-full flex items-center gap-2"
>
- <Link
- href={`/new/${selectedOrganization?.slug}`}
- onClick={() => {
- setOpen(false)
- }}
- className="w-full flex items-center gap-2"
- >
- <Plus size={14} strokeWidth={1.5} />
- <p>New project</p>
- </Link>
- </CommandItem_Shadcn_>
- </CommandGroup_Shadcn_>
- </>
- )}
- </CommandList_Shadcn_>
- </Command_Shadcn_>
- </PopoverContent_Shadcn_>
- </Popover_Shadcn_>
- </div>
+ <Plus size={14} strokeWidth={1.5} />
+ <p>New project</p>
+ </Link>
+ </CommandItem_Shadcn_>
+ </CommandGroup_Shadcn_>
+ </>
+ )}
+ </CommandList_Shadcn_>
+ </Command_Shadcn_>
+ </PopoverContent_Shadcn_>
+ </Popover_Shadcn_>
) : (
<Button type="text">
<span className={isNewNav ? 'text-sm' : 'text-xs'}>{selectedProject?.name}</span>
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
index 66cc136d935..6808d0d3779 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
@@ -1,6 +1,7 @@
import Link from 'next/link'
import { useMemo } from 'react'
+import Connect from 'components/interfaces/Connect/Connect'
import { useParams } from 'common'
import AssistantButton from 'components/layouts/AppLayout/AssistantButton'
import BranchDropdown from 'components/layouts/AppLayout/BranchDropdown'
@@ -12,19 +13,40 @@ import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-que
import { useOrgUsageQuery } from 'data/usage/org-usage-query'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
+import { useFlag } from 'hooks/ui/useFlag'
import { IS_PLATFORM } from 'lib/constants'
-import { Badge } from 'ui'
+import { Badge, cn } from 'ui'
import BreadcrumbsView from './BreadcrumbsView'
import { FeedbackDropdown } from './FeedbackDropdown'
import HelpPopover from './HelpPopover'
import NotificationsPopoverV2 from './NotificationsPopoverV2/NotificationsPopover'
+const LayoutHeaderDivider = () => (
+ <span className="text-border-stronger">
+ <svg
+ viewBox="0 0 24 24"
+ width="16"
+ height="16"
+ stroke="currentColor"
+ strokeWidth="1"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ fill="none"
+ shapeRendering="geometricPrecision"
+ >
+ <path d="M16 3.549L7.12 20.600" />
+ </svg>
+ </span>
+)
+
const LayoutHeader = ({ customHeaderComponents, breadcrumbs = [], headerBorder = true }: any) => {
const { ref: projectRef } = useParams()
const selectedProject = useSelectedProject()
const selectedOrganization = useSelectedOrganization()
const isBranchingEnabled = selectedProject?.is_branch_enabled === true
+ const connectDialogUpdate = useFlag('connectDialogUpdate')
+
const { data: subscription } = useOrgSubscriptionQuery({
orgSlug: selectedOrganization?.slug,
})
@@ -45,67 +67,40 @@ const LayoutHeader = ({ customHeaderComponents, breadcrumbs = [], headerBorder =
return (
<div
- className={`flex h-12 max-h-12 min-h-12 items-center bg-dash-sidebar ${
+ className={cn(
+ 'flex h-12 max-h-12 min-h-12 items-center bg-dash-sidebar',
headerBorder ? 'border-b border-default' : ''
- }`}
+ )}
>
<div className="flex items-center justify-between py-2 px-3 flex-1">
<div className="flex items-center text-sm">
- {/* Organization is selected */}
{projectRef && (
<>
- <OrganizationDropdown />
+ <div className="flex items-center">
+ <OrganizationDropdown />
+ <LayoutHeaderDivider />
+ <ProjectDropdown />
- {projectRef && (
- <>
- <span className="text-border-stronger">
- <svg
- viewBox="0 0 24 24"
- width="16"
- height="16"
- stroke="currentColor"
- strokeWidth="1"
- strokeLinecap="round"
- strokeLinejoin="round"
- fill="none"
- shapeRendering="geometricPrecision"
- >
- <path d="M16 3.549L7.12 20.600"></path>
- </svg>
- </span>
+ {exceedingLimits && (
+ <div className="ml-2">
+ <Link href={`/org/${selectedOrganization?.slug}/usage`}>
+ <Badge variant="destructive">Exceeding usage limits</Badge>
+ </Link>
+ </div>
+ )}
- <ProjectDropdown />
+ {selectedProject && isBranchingEnabled && (
+ <>
+ <LayoutHeaderDivider />
+ <BranchDropdown />
+ </>
+ )}
+ </div>
- {exceedingLimits && (
- <div className="ml-2">
- <Link href={`/org/${selectedOrganization?.slug}/usage`}>
- <Badge variant="destructive">Exceeding usage limits</Badge>
- </Link>
- </div>
- )}
- </>
- )}
-
- {selectedProject && (
- <>
- <span className="text-border-stronger">
- <svg
- viewBox="0 0 24 24"
- width="16"
- height="16"
- stroke="currentColor"
- strokeWidth="1"
- strokeLinecap="round"
- strokeLinejoin="round"
- fill="none"
- shapeRendering="geometricPrecision"
- >
- <path d="M16 3.549L7.12 20.600"></path>
- </svg>
- </span>
- {isBranchingEnabled ? <BranchDropdown /> : <EnableBranchingButton />}
- </>
- )}
+ <div className="ml-3 flex items-center gap-x-3">
+ {!isBranchingEnabled && <EnableBranchingButton />}
+ {connectDialogUpdate && <Connect />}
+ </div>
</>
)}
@@ -113,16 +108,14 @@ const LayoutHeader = ({ customHeaderComponents, breadcrumbs = [], headerBorder =
<BreadcrumbsView defaultValue={breadcrumbs} />
</div>
<div className="flex items-center gap-x-2">
- <div className="flex items-center gap-x-2">
- {customHeaderComponents && customHeaderComponents}
- {IS_PLATFORM && (
- <>
- <FeedbackDropdown />
- <NotificationsPopoverV2 />
- <HelpPopover />
- </>
- )}
- </div>
+ {customHeaderComponents && customHeaderComponents}
+ {IS_PLATFORM && (
+ <>
+ <FeedbackDropdown />
+ <NotificationsPopoverV2 />
+ <HelpPopover />
+ </>
+ )}
</div>
</div>
{!!projectRef && (
diff --git a/apps/studio/components/ui/DatabaseSelector.tsx b/apps/studio/components/ui/DatabaseSelector.tsx
index 832bdae9b11..72dc0c795d9 100644
--- a/apps/studio/components/ui/DatabaseSelector.tsx
+++ b/apps/studio/components/ui/DatabaseSelector.tsx
@@ -1,11 +1,18 @@
-import { useParams } from 'common'
import { noop } from 'lodash'
import { Check, ChevronDown, Loader2, Plus } from 'lucide-react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useState } from 'react'
+
+import { useParams } from 'common'
+import { Markdown } from 'components/interfaces/Markdown'
+import { REPLICA_STATUS } from 'components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants'
+import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
+import { formatDatabaseID, formatDatabaseRegion } from 'data/read-replicas/replicas.utils'
+import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
import {
Button,
+ ButtonProps,
CommandGroup_Shadcn_,
CommandItem_Shadcn_,
CommandList_Shadcn_,
@@ -19,28 +26,27 @@ import {
Tooltip_Shadcn_,
cn,
} from 'ui'
-
-import { Markdown } from 'components/interfaces/Markdown'
-import { REPLICA_STATUS } from 'components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants'
-import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
-import { formatDatabaseID, formatDatabaseRegion } from 'data/read-replicas/replicas.utils'
-import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
+import { useAppStateSnapshot } from 'state/app-state'
interface DatabaseSelectorProps {
variant?: 'regular' | 'connected-on-right' | 'connected-on-left' | 'connected-on-both'
additionalOptions?: { id: string; name: string }[]
onSelectId?: (id: string) => void // Optional callback
+
+ buttonProps?: ButtonProps
}
const DatabaseSelector = ({
variant = 'regular',
additionalOptions = [],
onSelectId = noop,
+ buttonProps,
}: DatabaseSelectorProps) => {
const router = useRouter()
const { ref: projectRef } = useParams()
const [open, setOpen] = useState(false)
+ const appState = useAppStateSnapshot()
const state = useDatabaseSelectorStateSnapshot()
const selectedDatabaseId = state.selectedDatabaseId
@@ -59,19 +65,23 @@ const DatabaseSelector = ({
return (
<Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>
<PopoverTrigger_Shadcn_ asChild>
- <div className="flex items-center space-x-2 cursor-pointer">
+ <div className="flex cursor-pointer">
+ <span className="flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0">
+ Source
+ </span>
<Button
type="default"
+ icon={isLoading && <Loader2 className="animate-spin" />}
+ iconRight={<ChevronDown strokeWidth={1.5} size={12} />}
+ {...buttonProps}
className={cn(
- 'pr-2',
+ 'pr-2 rounded-l-none',
variant === 'connected-on-right' && 'rounded-r-none',
variant === 'connected-on-left' && 'rounded-l-none border-l-0',
- variant === 'connected-on-both' && 'rounded-none border-x-0'
+ variant === 'connected-on-both' && 'rounded-none border-x-0',
+ buttonProps?.className
)}
- icon={isLoading && <Loader2 className="animate-spin" />}
- iconRight={<ChevronDown className="text-foreground-light" strokeWidth={2} size={12} />}
>
- <span className="text-foreground-muted mr-1">source</span>
{selectedAdditionalOption ? (
<span>{selectedAdditionalOption.name}</span>
) : (
@@ -193,7 +203,11 @@ const DatabaseSelector = ({
>
<Link
href={`/project/${projectRef}/settings/infrastructure`}
- onClick={() => setOpen(false)}
+ onClick={() => {
+ setOpen(false)
+ // [Joshen] This is used in the Connect UI which is available across all pages
+ appState.setShowConnectDialog(false)
+ }}
className="w-full flex items-center gap-2"
>
<Plus size={14} strokeWidth={1.5} />
diff --git a/apps/studio/components/ui/Panel.tsx b/apps/studio/components/ui/Panel.tsx
index 0c8f51213ab..028fb3f5ba7 100644
--- a/apps/studio/components/ui/Panel.tsx
+++ b/apps/studio/components/ui/Panel.tsx
@@ -117,7 +117,9 @@ const PanelNotice = forwardRef<
{href && (
<div>
<Button size="tiny" type="default" className="text-xs" asChild>
- <a href={href}>{buttonText ?? 'Read the accouncement'}</a>
+ <a href={href} target="_blank" rel="noreferrer noopener">
+ {buttonText ?? 'Read the accouncement'}
+ </a>
</Button>
</div>
)}
diff --git a/apps/studio/lib/constants/telemetry.ts b/apps/studio/lib/constants/telemetry.ts
index 87f03cf95b9..2030c342b8d 100644
--- a/apps/studio/lib/constants/telemetry.ts
+++ b/apps/studio/lib/constants/telemetry.ts
@@ -4,6 +4,7 @@
export enum TELEMETRY_EVENTS {
FEATURE_PREVIEWS = 'Dashboard UI Feature Previews',
AI_ASSISTANT_V2 = 'AI Assistant V2',
+ CONNECT_UI = 'Connect UI',
CRON_JOBS = 'Cron Jobs',
}
@@ -48,4 +49,5 @@ export enum TELEMETRY_VALUES {
CRON_JOB_UPDATE_CLICKED = 'cron-job-update-clicked',
CRON_JOB_CREATE_CLICKED = 'cron-job-create-clicked',
CRON_JOBS_VIEW_PREVIOUS_RUNS = 'view-previous-runs-clicked',
+ COPY_CONNECTION_STRING = 'copy-connection-string',
}
diff --git a/apps/studio/pages/project/[ref]/index.tsx b/apps/studio/pages/project/[ref]/index.tsx
index 836b11b3f7a..b30d2e4dce7 100644
--- a/apps/studio/pages/project/[ref]/index.tsx
+++ b/apps/studio/pages/project/[ref]/index.tsx
@@ -1,8 +1,8 @@
import { useEffect, useRef } from 'react'
import { useParams } from 'common'
+import Connect from 'components/interfaces/Connect/Connect'
import { ClientLibrary, ExampleProject } from 'components/interfaces/Home'
-import Connect from 'components/interfaces/Home/Connect/Connect'
import { CLIENT_LIBRARIES, EXAMPLE_PROJECTS } from 'components/interfaces/Home/Home.constants'
import ProjectUsageSection from 'components/interfaces/Home/ProjectUsageSection'
import { SecurityStatus } from 'components/interfaces/Home/SecurityStatus'
@@ -13,6 +13,7 @@ import { ComputeBadgeWrapper } from 'components/ui/ComputeBadgeWrapper'
import ProjectUpgradeFailedBanner from 'components/ui/ProjectUpgradeFailedBanner'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { useIsOrioleDb, useSelectedProject } from 'hooks/misc/useSelectedProject'
+import { useFlag } from 'hooks/ui/useFlag'
import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
import { useAppStateSnapshot } from 'state/app-state'
import type { NextPageWithLayout } from 'types'
@@ -28,6 +29,8 @@ import {
} from 'ui'
const Home: NextPageWithLayout = () => {
+ const connectDialogUpdate = useFlag('connectDialogUpdate')
+
const organization = useSelectedOrganization()
const project = useSelectedProject()
@@ -87,7 +90,9 @@ const Home: NextPageWithLayout = () => {
<div className="flex items-center gap-x-3">
{project?.status === PROJECT_STATUS.ACTIVE_HEALTHY && <SecurityStatus />}
{IS_PLATFORM && project?.status === PROJECT_STATUS.ACTIVE_HEALTHY && <ServiceStatus />}
- {IS_PLATFORM && project?.status === PROJECT_STATUS.ACTIVE_HEALTHY && <Connect />}
+ {IS_PLATFORM &&
+ project?.status === PROJECT_STATUS.ACTIVE_HEALTHY &&
+ !connectDialogUpdate && <Connect />}
</div>
</div>
diff --git a/apps/studio/pages/project/[ref]/settings/database.tsx b/apps/studio/pages/project/[ref]/settings/database.tsx
index 902109f8a29..1ed247a0807 100644
--- a/apps/studio/pages/project/[ref]/settings/database.tsx
+++ b/apps/studio/pages/project/[ref]/settings/database.tsx
@@ -1,25 +1,25 @@
+import { DiskManagementPanelForm } from 'components/interfaces/DiskManagement/DiskManagementPanelForm'
import {
ConnectionPooling,
DatabaseSettings,
NetworkRestrictions,
} from 'components/interfaces/Settings/Database'
-import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'
-import type { NextPageWithLayout } from 'types'
-
-import { DiskManagementPanelForm } from 'components/interfaces/DiskManagement/DiskManagementPanelForm'
import BannedIPs from 'components/interfaces/Settings/Database/BannedIPs'
+import { ConnectionStringMoved } from 'components/interfaces/Settings/Database/ConnectionStringMoved'
import { DatabaseReadOnlyAlert } from 'components/interfaces/Settings/Database/DatabaseReadOnlyAlert'
import { DatabaseConnectionString } from 'components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString'
+import DiskSizeConfiguration from 'components/interfaces/Settings/Database/DiskSizeConfiguration'
import { PoolingModesModal } from 'components/interfaces/Settings/Database/PoolingModesModal'
import SSLConfiguration from 'components/interfaces/Settings/Database/SSLConfiguration'
+import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'
import { ScaffoldContainer, ScaffoldHeader, ScaffoldTitle } from 'components/layouts/Scaffold'
-import DiskSizeConfiguration from 'components/interfaces/Settings/Database/DiskSizeConfiguration'
-import { useFlag } from 'hooks/ui/useFlag'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
+import { useFlag } from 'hooks/ui/useFlag'
+import type { NextPageWithLayout } from 'types'
const ProjectSettings: NextPageWithLayout = () => {
const diskManagementV2 = useFlag('diskManagementV2')
- const showDiskAndComputeForm = useFlag('diskAndComputeForm')
+ const connectDialogUpdate = useFlag('connectDialogUpdate')
const project = useSelectedProject()
const showNewDiskManagementUI = diskManagementV2 && project?.cloud_provider === 'AWS'
@@ -35,8 +35,14 @@ const ProjectSettings: NextPageWithLayout = () => {
<div className="space-y-10">
<div className="flex flex-col gap-y-10">
<DatabaseReadOnlyAlert />
- <DatabaseConnectionString appearance="default" />
- <DatabaseSettings />
+ {connectDialogUpdate ? (
+ <ConnectionStringMoved />
+ ) : (
+ <>
+ <DatabaseConnectionString appearance="default" />
+ <DatabaseSettings />
+ </>
+ )}
<ConnectionPooling />
</div>
diff --git a/apps/studio/state/app-state.ts b/apps/studio/state/app-state.ts
index 23efeaa44da..9a9f4450a3b 100644
--- a/apps/studio/state/app-state.ts
+++ b/apps/studio/state/app-state.ts
@@ -68,6 +68,7 @@ const getInitialState = () => {
showGenerateSqlModal: false,
navigationPanelOpen: false,
navigationPanelJustClosed: false,
+ showConnectDialog: false,
}
}
@@ -111,6 +112,7 @@ const getInitialState = () => {
showGenerateSqlModal: false,
navigationPanelOpen: false,
navigationPanelJustClosed: false,
+ showConnectDialog: false,
}
}
@@ -210,6 +212,11 @@ export const appState = proxy({
...value,
}
},
+
+ showConnectDialog: false,
+ setShowConnectDialog: (value: boolean) => {
+ appState.showConnectDialog = value
+ },
})
// Set up localStorage subscription
diff --git a/apps/studio/styles/main.scss b/apps/studio/styles/main.scss
index ad2f81cd43f..a4ed805f793 100644
--- a/apps/studio/styles/main.scss
+++ b/apps/studio/styles/main.scss
@@ -198,11 +198,6 @@ input[type='number'] {
display: none;
}
-code {
- // use supabase-ui code style
- @apply text-code;
-}
-
div[data-radix-portal]:not(.portal--toast) {
z-index: 2147483646 !important;
}
diff --git a/packages/ui/src/components/CodeBlock/CodeBlock.tsx b/packages/ui/src/components/CodeBlock/CodeBlock.tsx
index 2013320d5ba..ccf629e76c1 100644
--- a/packages/ui/src/components/CodeBlock/CodeBlock.tsx
+++ b/packages/ui/src/components/CodeBlock/CodeBlock.tsx
@@ -1,10 +1,12 @@
'use client'
+import { noop } from 'lodash'
import { Check, Copy } from 'lucide-react'
import { useTheme } from 'next-themes'
import { Children, ReactNode, useState } from 'react'
import { CopyToClipboard } from 'react-copy-to-clipboard'
import { Light as SyntaxHighlighter, SyntaxHighlighterProps } from 'react-syntax-highlighter'
+
import { cn } from '../../lib/utils/cn'
import { Button } from '../Button/Button'
import { monokaiCustomTheme } from './CodeBlock.utils'
@@ -13,29 +15,38 @@ import curl from 'highlightjs-curl'
import bash from 'react-syntax-highlighter/dist/cjs/languages/hljs/bash'
import csharp from 'react-syntax-highlighter/dist/cjs/languages/hljs/csharp'
import dart from 'react-syntax-highlighter/dist/cjs/languages/hljs/dart'
+import go from 'react-syntax-highlighter/dist/cjs/languages/hljs/go'
import http from 'react-syntax-highlighter/dist/cjs/languages/hljs/http'
import js from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript'
import json from 'react-syntax-highlighter/dist/cjs/languages/hljs/json'
import kotlin from 'react-syntax-highlighter/dist/cjs/languages/hljs/kotlin'
-import py from 'react-syntax-highlighter/dist/cjs/languages/hljs/python'
+import php from 'react-syntax-highlighter/dist/cjs/languages/hljs/php'
+import {
+ default as py,
+ default as python,
+} from 'react-syntax-highlighter/dist/cjs/languages/hljs/python'
import sql from 'react-syntax-highlighter/dist/cjs/languages/hljs/sql'
import ts from 'react-syntax-highlighter/dist/cjs/languages/hljs/typescript'
+export type CodeBlockLang =
+ | 'js'
+ | 'jsx'
+ | 'sql'
+ | 'py'
+ | 'bash'
+ | 'ts'
+ | 'dart'
+ | 'json'
+ | 'csharp'
+ | 'kotlin'
+ | 'curl'
+ | 'http'
+ | 'php'
+ | 'python'
+ | 'go'
export interface CodeBlockProps {
title?: ReactNode
- language?:
- | 'js'
- | 'jsx'
- | 'sql'
- | 'py'
- | 'bash'
- | 'ts'
- | 'dart'
- | 'json'
- | 'csharp'
- | 'kotlin'
- | 'curl'
- | 'http'
+ language?: CodeBlockLang
linesToHighlight?: number[]
highlightBorder?: boolean
styleConfig?: {
@@ -52,6 +63,7 @@ export interface CodeBlockProps {
children?: string
renderer?: SyntaxHighlighterProps['renderer']
focusable?: boolean
+ onCopyCallback?: () => void
wrapLines?: boolean
}
@@ -88,6 +100,7 @@ export const CodeBlock = ({
wrapLines = true,
renderer,
focusable = true,
+ onCopyCallback = noop,
}: CodeBlockProps) => {
const { resolvedTheme } = useTheme()
const isDarkTheme = resolvedTheme?.includes('dark')!
@@ -97,6 +110,7 @@ export const CodeBlock = ({
const handleCopy = () => {
setCopied(true)
+ onCopyCallback()
setTimeout(() => {
setCopied(false)
}, 1000)
@@ -129,6 +143,9 @@ export const CodeBlock = ({
SyntaxHighlighter.registerLanguage('kotlin', kotlin)
SyntaxHighlighter.registerLanguage('curl', curl)
SyntaxHighlighter.registerLanguage('http', http)
+ SyntaxHighlighter.registerLanguage('php', php)
+ SyntaxHighlighter.registerLanguage('python', python)
+ SyntaxHighlighter.registerLanguage('go', go)
const large = false
// don't show line numbers if bash == lang
@@ -157,7 +174,7 @@ export const CodeBlock = ({
style={monokaiTheme}
className={cn(
'code-block border border-surface p-4 w-full !my-0 !bg-surface-100 outline-none focus:border-foreground-lighter/50',
- `${!title ? '!rounded-md' : '!rounded-t-none !rounded-b-md'}`,
+ `${!title ? 'rounded-md' : 'rounded-t-none rounded-b-md'}`,
`${!showLineNumbers ? 'pl-6' : ''}`,
className
)}
diff --git a/packages/ui/src/components/shadcn/ui/select.tsx b/packages/ui/src/components/shadcn/ui/select.tsx
index 8fd409dbcae..8b519980d13 100644
--- a/packages/ui/src/components/shadcn/ui/select.tsx
+++ b/packages/ui/src/components/shadcn/ui/select.tsx
@@ -49,6 +49,7 @@ const SelectTrigger = React.forwardRef<
className={cn(
'flex w-full items-center justify-between rounded-md border border-strong hover:border-stronger bg-alternative dark:bg-muted hover:bg-selection text-xs ring-offset-background-control data-[placeholder]:text-foreground-lighter focus:outline-none ring-border-control focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-200',
'data-[state=open]:bg-selection data-[state=open]:border-stronger',
+ 'gap-2',
SelectTriggerVariants({ size }),
className
)}
@@ -56,7 +57,7 @@ const SelectTrigger = React.forwardRef<
>
{children}
<SelectPrimitive.Icon asChild>
- <ChevronDown className="h-4 w-4 text-foreground-muted" />
+ <ChevronDown className="h-4 w-4 text-foreground-lighter" strokeWidth={1.5} />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
))