@@ -245,7 +245,7 @@ export default function Chat() {
245245 ) }
246246 ref = { scrollRef }
247247 >
248- < LiveShareOverlay />
248+ < LiveShareOverlay databaseId = { databaseId } />
249249 < m . div
250250 key = { databaseId }
251251 className = "flex flex-col gap-4 w-full max-w-4xl p-10"
@@ -334,7 +334,7 @@ export default function Chat() {
334334 < div className = "h-full w-full max-w-4xl flex flex-col gap-10 justify-center items-center" >
335335 { user ? (
336336 < >
337- < LiveShareOverlay />
337+ < LiveShareOverlay databaseId = { databaseId } />
338338 < m . h3
339339 layout
340340 className = "text-2xl font-light text-center"
@@ -533,76 +533,76 @@ export default function Chat() {
533533 )
534534}
535535
536- function LiveShareOverlay ( ) {
536+ function LiveShareOverlay ( props : { databaseId : string } ) {
537537 const { liveShare } = useApp ( )
538538
539- if ( ! liveShare . isLiveSharing ) {
540- return null
541- }
542-
543- return (
544- < div className = "h-full w-full max-w-4xl flex flex-col gap-10 p-10 absolute backdrop-blur-sm bg-card/90 z-10" >
545- < div className = "flex items-center justify-center h-full flex-col gap-y-7" >
546- < div className = "w-full text-left" >
547- < p className = "text-lg" > Access your in-browser database</ p >
548- < p className = "text-xs text-muted-foreground" >
549- Closing the window will stop the Live Share session
550- </ p >
539+ if ( liveShare . isLiveSharing && liveShare . databaseId === props . databaseId ) {
540+ return (
541+ < div className = "h-full w-full max-w-4xl flex flex-col gap-10 p-10 absolute backdrop-blur-sm bg-card/90 z-10" >
542+ < div className = "flex items-center justify-center h-full flex-col gap-y-7" >
543+ < div className = "w-full text-left" >
544+ < p className = "text-lg" > Access your in-browser database</ p >
545+ < p className = "text-xs text-muted-foreground" >
546+ Closing the window will stop the Live Share session
547+ </ p >
548+ </ div >
549+ < Tabs defaultValue = "uri" className = "w-full justify-between bg-muted/50 rounded-md border" >
550+ < TabsList className = "w-full flex justify-start bg-transparent px-3" >
551+ < TabsTrigger
552+ value = "uri"
553+ className = "hover:text-foreground data-[state=active]:border-b-2 data-[state=active]:border-foreground data-[state=active]:bg-none! data-[state=active]:text-foreground data-[state=active]:shadow-none rounded-none relative cursor-pointer text-foreground-lighter flex items-center space-x-2 text-center transition focus:outline-none focus-visible:ring focus-visible:ring-foreground-muted focus-visible:border-foreground-muted text-xs px-2.5 py-1"
554+ >
555+ URI
556+ </ TabsTrigger >
557+ < TabsTrigger
558+ value = "psql"
559+ className = "hover:text-foreground data-[state=active]:border-b-2 data-[state=active]:border-foreground data-[state=active]:bg-none! data-[state=active]:text-foreground data-[state=active]:shadow-none rounded-none relative cursor-pointer text-foreground-lighter flex items-center space-x-2 text-center transition focus:outline-none focus-visible:ring focus-visible:ring-foreground-muted focus-visible:border-foreground-muted text-xs px-2.5 py-1"
560+ >
561+ PSQL
562+ </ TabsTrigger >
563+ </ TabsList >
564+ < TabsContent value = "uri" className = "px-2 pb-2" >
565+ < CopyableField
566+ value = { `postgres://postgres@${ liveShare . databaseId } .${ process . env . NEXT_PUBLIC_BROWSER_PROXY_DOMAIN } /postgres?sslmode=require` }
567+ />
568+ </ TabsContent >
569+ < TabsContent value = "psql" className = "px-2 pb-2" >
570+ < CopyableField
571+ value = { `psql "postgres://postgres@${ liveShare . databaseId } .${ process . env . NEXT_PUBLIC_BROWSER_PROXY_DOMAIN } /postgres?sslmode=require"` }
572+ />
573+ </ TabsContent >
574+ </ Tabs >
575+
576+ { liveShare . clientIp ? (
577+ < p className = "text-sm text-muted-foreground flex items-center gap-2" >
578+ < span className = "relative flex h-3 w-3" >
579+ < span className = "animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75" > </ span >
580+ < span className = "relative inline-flex rounded-full h-3 w-3 bg-primary" > </ span >
581+ </ span >
582+ < span >
583+ Connected from < span className = "text-card-foreground" > { liveShare . clientIp } </ span >
584+ </ span >
585+ </ p >
586+ ) : (
587+ < p className = "text-sm text-muted-foreground flex items-center gap-2" >
588+ < span className = "relative inline-flex rounded-full h-3 w-3 bg-muted-foreground" > </ span >
589+ < span > No client connected</ span >
590+ </ p >
591+ ) }
592+ < Button
593+ className = "w-full gap-2"
594+ variant = "outline"
595+ onClick = { ( ) => {
596+ liveShare . stop ( )
597+ } }
598+ >
599+ < PlugIcon size = { 16 } />
600+ < span > Stop sharing database</ span >
601+ </ Button >
551602 </ div >
552- < Tabs defaultValue = "uri" className = "w-full justify-between bg-muted/50 rounded-md border" >
553- < TabsList className = "w-full flex justify-start bg-transparent px-3" >
554- < TabsTrigger
555- value = "uri"
556- className = "hover:text-foreground data-[state=active]:border-b-2 data-[state=active]:border-foreground data-[state=active]:bg-none! data-[state=active]:text-foreground data-[state=active]:shadow-none rounded-none relative cursor-pointer text-foreground-lighter flex items-center space-x-2 text-center transition focus:outline-none focus-visible:ring focus-visible:ring-foreground-muted focus-visible:border-foreground-muted text-xs px-2.5 py-1"
557- >
558- URI
559- </ TabsTrigger >
560- < TabsTrigger
561- value = "psql"
562- className = "hover:text-foreground data-[state=active]:border-b-2 data-[state=active]:border-foreground data-[state=active]:bg-none! data-[state=active]:text-foreground data-[state=active]:shadow-none rounded-none relative cursor-pointer text-foreground-lighter flex items-center space-x-2 text-center transition focus:outline-none focus-visible:ring focus-visible:ring-foreground-muted focus-visible:border-foreground-muted text-xs px-2.5 py-1"
563- >
564- PSQL
565- </ TabsTrigger >
566- </ TabsList >
567- < TabsContent value = "uri" className = "px-2 pb-2" >
568- < CopyableField
569- value = { `postgres://postgres@${ liveShare . databaseId } .${ process . env . NEXT_PUBLIC_BROWSER_PROXY_DOMAIN } /postgres?sslmode=require` }
570- />
571- </ TabsContent >
572- < TabsContent value = "psql" className = "px-2 pb-2" >
573- < CopyableField
574- value = { `psql "postgres://postgres@${ liveShare . databaseId } .${ process . env . NEXT_PUBLIC_BROWSER_PROXY_DOMAIN } /postgres?sslmode=require"` }
575- />
576- </ TabsContent >
577- </ Tabs >
578-
579- { liveShare . clientIp ? (
580- < p className = "text-sm text-muted-foreground flex items-center gap-2" >
581- < span className = "relative flex h-3 w-3" >
582- < span className = "animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75" > </ span >
583- < span className = "relative inline-flex rounded-full h-3 w-3 bg-primary" > </ span >
584- </ span >
585- < span >
586- Connected from < span className = "text-card-foreground" > { liveShare . clientIp } </ span >
587- </ span >
588- </ p >
589- ) : (
590- < p className = "text-sm text-muted-foreground flex items-center gap-2" >
591- < span className = "relative inline-flex rounded-full h-3 w-3 bg-muted-foreground" > </ span >
592- < span > No client connected</ span >
593- </ p >
594- ) }
595- < Button
596- className = "w-full gap-2"
597- variant = "outline"
598- onClick = { ( ) => {
599- liveShare . stop ( )
600- } }
601- >
602- < PlugIcon size = { 16 } />
603- < span > Stop sharing database</ span >
604- </ Button >
605603 </ div >
606- </ div >
607- )
604+ )
605+
606+ return null
607+ }
608608}
0 commit comments