Files
supabase/apps/studio/components/interfaces/HomeNew/TopSection.tsx
Saxon FletcherandJoshen Lim cf24eab382 Introduce connection details in home (#42400)
<img width="855" height="482" alt="image"
src="https://github.com/user-attachments/assets/9f4451aa-2ed6-461a-88b2-933385eecda9"
/>

<img width="887" height="573" alt="image"
src="https://github.com/user-attachments/assets/a8686a38-f25b-4e1d-960a-70331b75f251"
/>

This introduces database url under project title which reveals summary
to connection details that then reveals full connect dialog if needed.
Increases exposure to connection info which we know some people struggle
to find.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a project connection hover card showing Data API (project URL,
publishable key) and Database connection string with copyable, read-only
fields, loading/permission states, and a "Get connected" action to open
connection setup.

* **UI Improvements**
* Integrated the connection hover card into the top section; reorganized
title and badge layout for clearer hierarchy and adjacent controls.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-02-04 10:29:35 +10:00

107 lines
4.4 KiB
TypeScript

import { ActivityStats } from 'components/interfaces/HomeNew/ActivityStats'
import { ProjectConnectionHoverCard } from 'components/interfaces/HomeNew/ProjectConnectionHoverCard'
import { ProjectPausedState } from 'components/layouts/ProjectLayout/PausedState/ProjectPausedState'
import { ComputeBadgeWrapper } from 'components/ui/ComputeBadgeWrapper'
import { InlineLink } from 'components/ui/InlineLink'
import { ProjectUpgradeFailedBanner } from 'components/ui/ProjectUpgradeFailedBanner'
import { useBranchesQuery } from 'data/branches/branches-query'
import { useProjectDetailQuery } from 'data/projects/project-detail-query'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useIsOrioleDb, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { DOCS_URL, PROJECT_STATUS } from 'lib/constants'
import Link from 'next/link'
import { ReactFlowProvider } from 'reactflow'
import { Badge, Tooltip, TooltipContent, TooltipTrigger, cn } from 'ui'
import { InstanceConfiguration } from '../Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration'
export const TopSection = () => {
const isOrioleDb = useIsOrioleDb()
const { data: project } = useSelectedProjectQuery()
const { data: organization } = useSelectedOrganizationQuery()
const { data: parentProject } = useProjectDetailQuery({ ref: project?.parent_project_ref })
const { data: branches } = useBranchesQuery({
projectRef: project?.parent_project_ref ?? project?.ref,
})
const mainBranch = branches?.find((branch) => branch.is_default)
const currentBranch = branches?.find((branch) => branch.project_ref === project?.ref)
const isMainBranch = currentBranch?.name === mainBranch?.name
const isPaused = project?.status === PROJECT_STATUS.INACTIVE
const projectName =
currentBranch && !isMainBranch
? currentBranch.name
: project?.name
? project.name
: 'Welcome to your project'
if (isPaused) {
return <ProjectPausedState />
}
return (
<div className="flex flex-col gap-y-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 py-0 w-full items-center">
<div className="flex flex-col">
<div className="flex flex-row flex-wrap items-center gap-4 w-full">
<div>
{!isMainBranch && (
<Link
href={`/project/${parentProject?.ref}`}
className="text-sm text-foreground-light"
>
{parentProject?.name}
</Link>
)}
<div className="flex items-center gap-x-2">
<h1 className="text-3xl">{projectName}</h1>
<div className="flex items-center gap-x-2">
{isOrioleDb && (
<Tooltip>
<TooltipTrigger asChild>
<Badge variant="warning">OrioleDB</Badge>
</TooltipTrigger>
<TooltipContent side="bottom" align="start" className="max-w-80 text-center">
This project is using Postgres with OrioleDB which is currently in preview
and not suitable for production workloads. View our{' '}
<InlineLink href={`${DOCS_URL}/guides/database/orioledb`}>
documentation
</InlineLink>{' '}
for all limitations.
</TooltipContent>
</Tooltip>
)}
<ComputeBadgeWrapper
projectRef={project?.ref}
slug={organization?.slug}
cloudProvider={project?.cloud_provider}
computeSize={project?.infra_compute_size}
/>
</div>
</div>
<ProjectConnectionHoverCard projectRef={project?.ref} />
</div>
</div>
<div className="mt-8">
<ActivityStats />
</div>
</div>
<div>
<div
className={cn(
'w-full h-[400px] md:h-[500px] border border-muted rounded-md overflow-hidden flex flex-col relative'
)}
>
<ReactFlowProvider>
<InstanceConfiguration diagramOnly />
</ReactFlowProvider>
</div>
</div>
</div>
<ProjectUpgradeFailedBanner />
</div>
)
}