mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 12:55:06 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? This PR introduces some visual indicators when a Nano project is exhausting resources on Pro plus plans. The indicator tells the user a free upgrade to Micro is available via a flashing Nano badge that guides them to Upgrade and a global banner that notifies them resources are near exhaustion, please upgrade for free. | Project List | Project View | |--------|--------| | <img width="412" height="223" alt="Screenshot 2026-03-31 at 16 11 19" src="https://github.com/user-attachments/assets/0d0e7727-e4eb-4ade-9024-528a2501596c" /> | <img width="1256" height="618" alt="Screenshot 2026-03-31 at 16 11 10" src="https://github.com/user-attachments/assets/b664e020-2b18-4842-8e64-4e49fac69eef" /> | <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Free Micro Upgrade banner appears for nano-tier projects near compute exhaustion with animated visuals and an “Upgrade for free” CTA. * Compute badge highlights near-exhaustion with glow/shimmer and an animated upgrade indicator; optional icon support added. * Per-project banner dismissal is saved locally; dismissed banners remain hidden. * **Tests** * Added tests covering banner display and dismissal scenarios. * **Chores** * Added local-storage keys and telemetry events for banner and upgrade interactions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
113 lines
4.8 KiB
TypeScript
113 lines
4.8 KiB
TypeScript
import { ReactFlowProvider } from '@xyflow/react'
|
|
import { ActivityStats } from 'components/interfaces/ProjectHome/ActivityStats'
|
|
import { ProjectConnectionPopover } from 'components/interfaces/ProjectHome/ProjectConnectionPopover'
|
|
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 { useResourceWarningsQuery } from 'data/usage/resource-warnings-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 { Badge, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
import { InstanceConfiguration } from '../Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration'
|
|
import { HighAvailabilityBadge } from './HighAvailabilityBadge'
|
|
|
|
export const TopSection = () => {
|
|
const isOrioleDb = useIsOrioleDb()
|
|
const { data: project } = useSelectedProjectQuery()
|
|
const { data: organization } = useSelectedOrganizationQuery()
|
|
const { data: resourceWarnings } = useResourceWarningsQuery({ slug: organization?.slug })
|
|
const projectResourceWarnings = resourceWarnings?.find((w) => w.project === project?.ref)
|
|
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}
|
|
resourceWarnings={projectResourceWarnings}
|
|
/>
|
|
{project?.high_availability && <HighAvailabilityBadge />}
|
|
</div>
|
|
</div>
|
|
<ProjectConnectionPopover 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>
|
|
)
|
|
}
|