mirror of
https://github.com/supabase/supabase.git
synced 2026-09-08 19:08:44 +08:00
## What kind of change does this PR introduce? Feature. Stack 2 of 5 for [PIPE-1007](https://linear.app/supabase/issue/PIPE-1007/move-read-replicas-out-of-replication-into-infrastructure). ## What is the current behavior? Settings / Infrastructure only covers compute and disk. ## What is the new behavior? Adds topology, a Read replicas list, and the add-replica sheet on Infrastructure. Still gated on `infrastructure:read_replicas`. | Before | After | | --- | --- | | <img width="1279" height="1323" alt="Infrastructure Settings Chisel Toolshed Supabase" src="https://github.com/user-attachments/assets/34e7b414-a326-415b-984c-00ae0000f46e" /> | <img width="1279" height="1323" alt="Infrastructure Settings Chisel Toolshed Supabase" src="https://github.com/user-attachments/assets/547cd7ac-435e-45d1-80ad-2f35476f579f" /> | ## Additional context [#49043](https://github.com/supabase/supabase/pull/49043) is merged. This PR targets `master`. Please review, but do not merge. `infrastructure:read_replicas` is already on, so merging this alone would show replicas on both Infrastructure and Replication. Merge 2→5 ([#49045](https://github.com/supabase/supabase/pull/49045), [#49046](https://github.com/supabase/supabase/pull/49046), [#48921](https://github.com/supabase/supabase/pull/48921)) in succession once they are all reviewed. Replica detail still uses the old Replication URL until #49045. ## To test `infrastructure:read_replicas` is an enabled-feature, on by default in `enabled-features.json`. There is no Feature Preview or ConfigCat switch. On this preview you should already see it: Settings → Infrastructure shows topology and a Read replicas section. If those are missing, your profile lists `infrastructure:read_replicas` in `disabled_features` (from `/platform/profile`), and you cannot flip it in the UI. Open [Settings / Infrastructure](https://studio-staging-git-danny-pipe-1007-02-infra-section-supabase.vercel.app/dashboard/project/_/settings/infrastructure). Confirm the topology, Read replicas section, and Add read replica sheet. Replication should still list replicas too. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added infrastructure topology visibility to project infrastructure settings. * Added read replica management, including status monitoring, empty states, creation flow, documentation access, and discard-change confirmation. * Infrastructure settings now include read replicas alongside compute and disk configuration. * Added flexible placement for supplemental disk overview and scaling content. * **Bug Fixes** * Simplified project configuration rendering for more reliable display. * **Tests** * Added coverage for enabled and disabled read replica states. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
107 lines
4.1 KiB
TypeScript
107 lines
4.1 KiB
TypeScript
import Link from 'next/link'
|
|
import { Badge, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { InstanceConfiguration } from '../Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration'
|
|
import { ActivityStats } from '@/components/interfaces/ProjectHome/ActivityStats'
|
|
import { ProjectConnectionPopover } from '@/components/interfaces/ProjectHome/ProjectConnectionPopover'
|
|
import { ProjectPausedState } from '@/components/layouts/ProjectLayout/PausedState/ProjectPausedState'
|
|
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 { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
import { DOCS_URL, IS_PLATFORM, PROJECT_STATUS } from '@/lib/constants'
|
|
|
|
export const TopSection = () => {
|
|
const isOrioleDb = useIsOrioleDb()
|
|
const { data: project, isLoading } = useSelectedProjectQuery()
|
|
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={cn(
|
|
'grid grid-cols-1 gap-8 py-0 w-full items-center',
|
|
IS_PLATFORM && 'md:grid-cols-2'
|
|
)}
|
|
>
|
|
<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">
|
|
{isLoading ? (
|
|
<ShimmeringLoader className="w-32 py-0 h-[33.6px]" />
|
|
) : (
|
|
<h1 className="text-3xl">{projectName}</h1>
|
|
)}
|
|
{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>
|
|
)}
|
|
</div>
|
|
<ProjectConnectionPopover projectRef={project?.ref} />
|
|
</div>
|
|
</div>
|
|
{IS_PLATFORM && (
|
|
<div className="mt-8">
|
|
<ActivityStats />
|
|
</div>
|
|
)}
|
|
</div>
|
|
{IS_PLATFORM && (
|
|
<div>
|
|
<div
|
|
className={cn(
|
|
'w-full h-[400px] md:h-[500px] border border-muted rounded-md overflow-hidden flex flex-col relative'
|
|
)}
|
|
>
|
|
<InstanceConfiguration />
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
<ProjectUpgradeFailedBanner />
|
|
</div>
|
|
)
|
|
}
|