1- import  {  ChevronDown ,  GlobeIcon ,   InfoIcon  }  from  'lucide-react' 
1+ import  {  BookOpen ,   ChevronDown ,  ChevronRight ,   ExternalLink  }  from  'lucide-react' 
22import  {  parseAsString ,  useQueryState  }  from  'nuqs' 
33import  {  HTMLAttributes ,  ReactNode ,  useEffect ,  useMemo ,  useState  }  from  'react' 
4+ import  Link  from  'next/link' 
45
56import  {  useParams  }  from  'common' 
67import  {  getAddons  }  from  'components/interfaces/Billing/Subscription/Subscription.utils' 
@@ -19,6 +20,7 @@ import { pluckObjectFields } from 'lib/helpers'
1920import  {  useDatabaseSelectorStateSnapshot  }  from  'state/database-selector' 
2021import  { 
2122  Badge , 
23+   Button , 
2224  CodeBlock , 
2325  CollapsibleContent_Shadcn_ , 
2426  CollapsibleTrigger_Shadcn_ , 
@@ -30,6 +32,7 @@ import {
3032  SelectValue_Shadcn_ , 
3133  Select_Shadcn_ , 
3234  Separator , 
35+   TextLink , 
3336  cn , 
3437}  from  'ui' 
3538import  {  Admonition  }  from  'ui-patterns' 
@@ -275,55 +278,69 @@ export const DatabaseConnectionString = () => {
275278
276279  return  ( 
277280    < div  className = "flex flex-col" > 
278-       < div 
279-         className = { cn ( 
280-           'flex flex-col md:flex-row items-stretch md:items-center gap-2 md:gap-3' , 
281-           DIALOG_PADDING_X 
282-         ) } 
283-       > 
284-         < div  className = "flex" > 
285-           < span  className = "flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0" > 
286-             Type
287-           </ span > 
288-           < Select_Shadcn_  value = { selectedTab }  onValueChange = { handleTabChange } > 
289-             < SelectTrigger_Shadcn_  size = "small"  className = "w-auto rounded-l-none" > 
290-               < SelectValue_Shadcn_  /> 
291-             </ SelectTrigger_Shadcn_ > 
292-             < SelectContent_Shadcn_ > 
293-               { DATABASE_CONNECTION_TYPES . map ( ( type )  =>  ( 
294-                 < SelectItem_Shadcn_  key = { type . id }  value = { type . id } > 
295-                   { type . label } 
296-                 </ SelectItem_Shadcn_ > 
297-               ) ) } 
298-             </ SelectContent_Shadcn_ > 
299-           </ Select_Shadcn_ > 
300-         </ div > 
301-         < DatabaseSelector 
302-           portal = { false } 
303-           buttonProps = { {  size : 'small'  } } 
304-           onSelectId = { handleDatabaseChange } 
305-         /> 
306-         < div  className = "flex" > 
307-           < span  className = "flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0" > 
308-             Method
309-           </ span > 
310-           < Select_Shadcn_  value = { selectedMethod }  onValueChange = { handleMethodChange } > 
311-             < SelectTrigger_Shadcn_  size = "small"  className = "w-auto rounded-l-none" > 
312-               < SelectValue_Shadcn_  size = "tiny" > 
313-                 { connectionStringMethodOptions [ selectedMethod ] . label } 
314-               </ SelectValue_Shadcn_ > 
315-             </ SelectTrigger_Shadcn_ > 
316-             < SelectContent_Shadcn_  className = "max-w-sm" > 
317-               { Object . keys ( connectionStringMethodOptions ) . map ( ( method )  =>  ( 
318-                 < ConnectionStringMethodSelectItem 
319-                   key = { method } 
320-                   method = { method  as  ConnectionStringMethod } 
321-                   poolerBadge = { poolerBadge } 
322-                 /> 
323-               ) ) } 
324-             </ SelectContent_Shadcn_ > 
325-           </ Select_Shadcn_ > 
281+       < div  className = { cn ( 'w-full flex flex-col items-start gap-2 lg:gap-3' ,  DIALOG_PADDING_X ) } > 
282+         < div  className = "flex w-full flex-col md:flex-row items-stretch md:items-center gap-2 md:gap-3" > 
283+           < div  className = "flex" > 
284+             < span  className = "w-1/2 md:w-auto flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0" > 
285+               Type
286+             </ span > 
287+             < Select_Shadcn_  value = { selectedTab }  onValueChange = { handleTabChange } > 
288+               < SelectTrigger_Shadcn_  size = "small"  className = "w-full md:w-auto rounded-l-none" > 
289+                 < SelectValue_Shadcn_  /> 
290+               </ SelectTrigger_Shadcn_ > 
291+               < SelectContent_Shadcn_ > 
292+                 { DATABASE_CONNECTION_TYPES . map ( ( type )  =>  ( 
293+                   < SelectItem_Shadcn_  key = { type . id }  value = { type . id } > 
294+                     { type . label } 
295+                   </ SelectItem_Shadcn_ > 
296+                 ) ) } 
297+               </ SelectContent_Shadcn_ > 
298+             </ Select_Shadcn_ > 
299+           </ div > 
300+           < DatabaseSelector 
301+             portal = { false } 
302+             buttonProps = { { 
303+               size : 'small' , 
304+               className : 'w-full justify-between pr-2.5 [&_svg]:h-4' , 
305+             } } 
306+             className = "w-full md:w-auto [&>span]:w-1/2 [&>span]:md:w-auto" 
307+             onSelectId = { handleDatabaseChange } 
308+           /> 
309+           < div  className = "flex" > 
310+             < span  className = "w-1/2 md:w-auto flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0" > 
311+               Method
312+             </ span > 
313+             < Select_Shadcn_  value = { selectedMethod }  onValueChange = { handleMethodChange } > 
314+               < SelectTrigger_Shadcn_  size = "small"  className = "w-full md:w-auto rounded-l-none" > 
315+                 < SelectValue_Shadcn_  size = "tiny" > 
316+                   { connectionStringMethodOptions [ selectedMethod ] . label } 
317+                 </ SelectValue_Shadcn_ > 
318+               </ SelectTrigger_Shadcn_ > 
319+               < SelectContent_Shadcn_  className = "max-w-sm" > 
320+                 { Object . keys ( connectionStringMethodOptions ) . map ( ( method )  =>  ( 
321+                   < ConnectionStringMethodSelectItem 
322+                     key = { method } 
323+                     method = { method  as  ConnectionStringMethod } 
324+                     poolerBadge = { method  ===  'transaction'  ? poolerBadge  : undefined } 
325+                   /> 
326+                 ) ) } 
327+               </ SelectContent_Shadcn_ > 
328+             </ Select_Shadcn_ > 
329+           </ div > 
326330        </ div > 
331+         < p  className = "text-xs inline-flex items-center gap-1 text-foreground-lighter" > 
332+           < BookOpen  size = { 12 }  strokeWidth = { 1.5 }  className = "-mb-px"  />  Learn how to connect to your
333+           Postgres databases.
334+           < Link 
335+             href = "https://supabase.com/docs/guides/database/connecting-to-postgres" 
336+             className = "underline transition hover:text-foreground inline-flex items-center gap-1" 
337+             target = "_blank" 
338+             rel = "noreferrer" 
339+             title = "Read docs" 
340+           > 
341+             Read docs < ExternalLink  size = { 12 }  strokeWidth = { 1.5 }  /> 
342+           </ Link > 
343+         </ p > 
327344      </ div > 
328345
329346      { isLoading  &&  ( 
@@ -458,7 +475,49 @@ export const DatabaseConnectionString = () => {
458475                    {  ...CONNECTION_PARAMETERS . pool_mode ,  value : 'transaction'  } , 
459476                  ] } 
460477                  onCopyCallback = { ( )  =>  handleCopy ( selectedTab ,  'transaction_pooler' ) } 
461-                 /> 
478+                 > 
479+                   { ! sharedPoolerPreferred  &&  ! ipv4Addon  &&  ( 
480+                     < Collapsible_Shadcn_  className = "group" > 
481+                       < CollapsibleTrigger_Shadcn_ 
482+                         asChild 
483+                         className = "w-full justify-start !last:rounded-b group-data-[state=open]:rounded-b-none border-light px-3" 
484+                       > 
485+                         < Button 
486+                           type = "default" 
487+                           size = "large" 
488+                           iconRight = { 
489+                             < ChevronDown  className = "transition group-data-[state=open]:rotate-180"  /> 
490+                           } 
491+                           className = "text-foreground !bg-dash-sidebar justify-between" 
492+                         > 
493+                           < div  className = "text-xs flex items-center py-2 px-1" > 
494+                             < span > Using the Shared Pooler</ span > 
495+                             < Badge  variant = { 'brand' }  size = { 'small' }  className = "ml-2" > 
496+                               IPv4 compatible
497+                             </ Badge > 
498+                           </ div > 
499+                         </ Button > 
500+                       </ CollapsibleTrigger_Shadcn_ > 
501+                       < CollapsibleContent_Shadcn_  className = "bg-dash-sidebar rounded-b border text-xs" > 
502+                         < CodeBlock 
503+                           wrapperClassName = { cn ( 
504+                             '[&_pre]:border-x-0 [&_pre]:border-t-0 [&_pre]:px-4 [&_pre]:py-3' , 
505+                             '[&_pre]:rounded-t-none' 
506+                           ) } 
507+                           language = { lang } 
508+                           value = { supavisorConnectionStrings [ 'pooler' ] [ selectedTab ] } 
509+                           className = "[&_code]:text-[12px] [&_code]:text-foreground" 
510+                           hideLineNumbers 
511+                           onCopyCallback = { ( )  =>  handleCopy ( selectedTab ,  'transaction_pooler' ) } 
512+                         /> 
513+                         < p  className = "px-3 py-2 text-foreground-light" > 
514+                           Only recommended when your network does not support IPv6. Added latency
515+                           compared to dedicated pooler.
516+                         </ p > 
517+                       </ CollapsibleContent_Shadcn_ > 
518+                     </ Collapsible_Shadcn_ > 
519+                   ) } 
520+                 </ ConnectionPanel > 
462521              ) } 
463522
464523              { selectedMethod  ===  'session'  &&  IS_PLATFORM  &&  ( 
@@ -587,14 +646,30 @@ const ConnectionStringMethodSelectItem = ({
587646  poolerBadge, 
588647} : { 
589648  method : ConnectionStringMethod 
590-   poolerBadge : string 
591- } )  =>  ( 
592-   < SelectItem_Shadcn_  value = { method }  className = "[&>span:first-child]:top-3.5" > 
593-     < div  className = "flex flex-col w-full py-1" > 
594-       < div > { connectionStringMethodOptions [ method ] . label } </ div > 
595-       < div  className = "text-foreground-lighter text-xs" > 
596-         { connectionStringMethodOptions [ method ] . description } 
649+   poolerBadge ?: string 
650+ } )  =>  { 
651+   const  badges : ReactNode [ ]  =  [ ] 
652+ 
653+   if  ( method  !==  'direct' )  { 
654+     badges . push ( < Badge  className = "flex gap-x-1" > Shared Pooler</ Badge > ) 
655+   } 
656+   if  ( poolerBadge  ===  'Dedicated Pooler' )  { 
657+     badges . push ( < Badge  className = "flex gap-x-1" > { poolerBadge } </ Badge > ) 
658+   } 
659+ 
660+   return  ( 
661+     < SelectItem_Shadcn_  value = { method }  className = "[&>span:first-child]:top-3.5" > 
662+       < div  className = "flex flex-col w-full py-1" > 
663+         < div  className = "flex gap-x-2 items-center" > 
664+           { connectionStringMethodOptions [ method ] . label } 
665+         </ div > 
666+         < div  className = "text-foreground-lighter text-xs" > 
667+           { connectionStringMethodOptions [ method ] . description } 
668+         </ div > 
669+         < div  className = "flex items-center gap-0.5 flex-wrap mt-1.5" > 
670+           { badges . map ( ( badge )  =>  badge ) } 
671+         </ div > 
597672      </ div > 
598-     </ div > 
599-   </ SelectItem_Shadcn_ > 
600- ) 
673+     </ SelectItem_Shadcn_ > 
674+   ) 
675+ } 
0 commit comments