Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Merge compute and disk into Infrastructure (#48370)

Saxon Fletcherad203ae27769
diff --git a/apps/studio/.github/eslint-rule-baselines.json b/apps/studio/.github/eslint-rule-baselines.json
index c95bbd984d6..bb9dff36ebb 100644
--- a/apps/studio/.github/eslint-rule-baselines.json
+++ b/apps/studio/.github/eslint-rule-baselines.json
@@ -357,7 +357,6 @@
"components/interfaces/SQLEditor/useSqlEditorExecution.ts": 1,
"components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx": 1,
"components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.utils.ts": 2,
- "components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx": 1,
"components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceNode.tsx": 1,
"components/interfaces/Settings/Logs/LogSelectionRenderers/DefaultPreviewSelectionRenderer.tsx": 1,
"components/interfaces/Settings/Logs/LogTable.tsx": 1,
diff --git a/apps/studio/TANSTACK_MIGRATION.md b/apps/studio/TANSTACK_MIGRATION.md
index 387e808c2ce..a30d05471c9 100644
--- a/apps/studio/TANSTACK_MIGRATION.md
+++ b/apps/studio/TANSTACK_MIGRATION.md
@@ -289,7 +289,6 @@ These are the layout-only TanStack files. Most hold a single product layout comp
- [x] A `routes/project/$ref/settings/general.tsx` ← `pages/project/[ref]/settings/general.tsx`
- [x] A `routes/project/$ref/settings/addons.tsx` ← `pages/project/[ref]/settings/addons.tsx`
- [x] A `routes/project/$ref/settings/api.tsx` ← `pages/project/[ref]/settings/api.tsx` (sets `skipSettingsLayout: true` — page is a useEffect redirect)
-- [x] A `routes/project/$ref/settings/compute-and-disk.tsx` ← `pages/project/[ref]/settings/compute-and-disk.tsx`
- [x] A `routes/project/$ref/settings/dashboard.tsx` ← `pages/project/[ref]/settings/dashboard.tsx`
- [x] A `routes/project/$ref/settings/infrastructure.tsx` ← `pages/project/[ref]/settings/infrastructure.tsx`
- [x] A `routes/project/$ref/settings/integrations.tsx` ← `pages/project/[ref]/settings/integrations.tsx`
diff --git a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx
index 8bd01d65a4d..31a46cc0551 100644
--- a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx
@@ -41,6 +41,7 @@ import {
estimateRestoreTime,
} from './BranchManagement.utils'
import { TaxDisclaimer } from '@/components/interfaces/Billing/TaxDisclaimer'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { BranchingPITRNotice } from '@/components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice'
import { AlertError } from '@/components/ui/AlertError'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
@@ -522,9 +523,9 @@ export const CreateBranchModal = () => {
<InlineLink
onClick={() => setShowCreateBranchModal(false)}
className="pointer-events-auto"
- href={`/project/${ref}/settings/compute-and-disk`}
+ href={getInfrastructurePath(projectRef)}
>
- Compute and Disk
+ Infrastructure
</InlineLink>
</p>
</TooltipContent>
diff --git a/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/AdditionalMonthlySpend.tsx b/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/AdditionalMonthlySpend.tsx
index 746446bc5b6..d39a85d6dc4 100644
--- a/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/AdditionalMonthlySpend.tsx
+++ b/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/AdditionalMonthlySpend.tsx
@@ -13,7 +13,7 @@ export const AdditionalMonthlySpend = ({
be able to update the compute size and increase the disk size after the new project is
created in{' '}
<span className="font-mono text-xs tracking-tighter text-foreground-light">
- Project Settings &gt; Compute and Disk
+ Project Settings &gt; Infrastructure
</span>
</p>
<div className="flex flex-col gap-2 text-foreground mt-4">
diff --git a/apps/studio/components/interfaces/Database/RestoreToNewProject/RestoreToNewProject.tsx b/apps/studio/components/interfaces/Database/RestoreToNewProject/RestoreToNewProject.tsx
index 81f29c20184..30319bc6fd3 100644
--- a/apps/studio/components/interfaces/Database/RestoreToNewProject/RestoreToNewProject.tsx
+++ b/apps/studio/components/interfaces/Database/RestoreToNewProject/RestoreToNewProject.tsx
@@ -14,6 +14,7 @@ import { CreateNewProjectDialog } from '@/components/interfaces/Database/Backups
import { projectSpecToMonthlyPrice } from '@/components/interfaces/Database/Backups/RestoreToNewProject/RestoreToNewProject.utils'
import { DiskType } from '@/components/interfaces/DiskManagement/ui/DiskManagement.constants'
import { Markdown } from '@/components/interfaces/Markdown'
+import { getServiceVersionsPath } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils'
import { AlertError } from '@/components/ui/AlertError'
import { InlineLink } from '@/components/ui/InlineLink'
import { NoPermission } from '@/components/ui/NoPermission'
@@ -158,7 +159,7 @@ export const RestoreToNewProject = () => {
<Markdown
className="max-w-full"
content={`Restore to new project is only available for Postgres 15 and above.
- Go to [infrastructure settings](/project/${project?.ref}/settings/infrastructure)
+ Go to [Service versions](${getServiceVersionsPath(project?.ref)})
to upgrade your database version.
`}
/>
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx
index 03a04ecb40d..724da3d3ec6 100644
--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx
@@ -11,6 +11,7 @@ import {
} from 'ui-patterns/PageSection'
import { DocsButton } from '../../ui/DocsButton'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { DOCS_URL } from '@/lib/constants'
// [Joshen] Only used for non AWS projects
@@ -30,12 +31,10 @@ export function DiskManagementPanelForm() {
type="default"
layout="responsive"
title="Disk Management has moved"
- description="Disk configuration is now managed alongside Project Compute on the new Compute and Disk page."
+ description="Disk configuration is now managed alongside Project Compute on the Infrastructure page."
actions={
<Button variant="default" asChild>
- <Link href={`/project/${projectRef}/settings/compute-and-disk`}>
- Go to Compute and Disk
- </Link>
+ <Link href={getInfrastructurePath(projectRef)}>Go to Infrastructure</Link>
</Button>
}
/>
diff --git a/apps/studio/components/interfaces/DiskManagement/fields/AutoScaleFields.tsx b/apps/studio/components/interfaces/DiskManagement/fields/AutoScaleFields.tsx
index 82bfd945a6d..6e626f6b204 100644
--- a/apps/studio/components/interfaces/DiskManagement/fields/AutoScaleFields.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/fields/AutoScaleFields.tsx
@@ -70,6 +70,7 @@ export const AutoScaleFields = ({ form }: AutoScaleFieldProps) => {
<InputGroup>
<FormInputGroupInput
{...field}
+ id={field.name}
type="number"
value={field.value ?? undefined}
disabled={isError}
@@ -116,6 +117,7 @@ export const AutoScaleFields = ({ form }: AutoScaleFieldProps) => {
<InputGroup>
<FormInputGroupInput
{...field}
+ id={field.name}
type="number"
value={field.value ?? undefined}
disabled={isError}
@@ -157,6 +159,7 @@ export const AutoScaleFields = ({ form }: AutoScaleFieldProps) => {
<InputGroup>
<FormInputGroupInput
{...field}
+ id={field.name}
type="number"
value={field.value ?? undefined}
disabled={isError}
diff --git a/apps/studio/components/interfaces/DiskManagement/fields/IOPSField.tsx b/apps/studio/components/interfaces/DiskManagement/fields/IOPSField.tsx
index 71f0a40bed5..5af294822c2 100644
--- a/apps/studio/components/interfaces/DiskManagement/fields/IOPSField.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/fields/IOPSField.tsx
@@ -86,6 +86,7 @@ export function IOPSField({ form, disableInput }: IOPSFieldProps) {
<FormInputGroupInput
type="number"
{...field}
+ id={field.name}
value={field.value}
disabled={disableInput || disableIopsInput || isError}
onChange={(e) => {
diff --git a/apps/studio/components/interfaces/DiskManagement/fields/ThroughputField.tsx b/apps/studio/components/interfaces/DiskManagement/fields/ThroughputField.tsx
index eb854c5872e..9b07712f8fb 100644
--- a/apps/studio/components/interfaces/DiskManagement/fields/ThroughputField.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/fields/ThroughputField.tsx
@@ -77,6 +77,7 @@ export function ThroughputField({ form, disableInput }: ThroughputFieldProps) {
<FormItemLayout
label="Throughput"
layout="flex-row-reverse"
+ id={field.name}
description={
<span className="flex flex-col gap-y-2">
<p>Higher throughput suits applications with high data transfer needs.</p>
@@ -100,6 +101,7 @@ export function ThroughputField({ form, disableInput }: ThroughputFieldProps) {
<FormInputGroupInput
type="number"
{...field}
+ id={field.name}
value={field.value}
onChange={(e) => {
setValue('throughput', e.target.valueAsNumber, {
diff --git a/apps/studio/components/interfaces/Integrations/Queues/UpgradeDatabaseAlert.tsx b/apps/studio/components/interfaces/Integrations/Queues/UpgradeDatabaseAlert.tsx
index b953b74630c..e3ca55cb706 100644
--- a/apps/studio/components/interfaces/Integrations/Queues/UpgradeDatabaseAlert.tsx
+++ b/apps/studio/components/interfaces/Integrations/Queues/UpgradeDatabaseAlert.tsx
@@ -2,6 +2,7 @@ import Link from 'next/link'
import { Button } from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
+import { getServiceVersionsPath } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
interface UpgradeDatabaseAlertProps {
@@ -24,7 +25,7 @@ export const UpgradeDatabaseAlert = ({ minimumVersion = '15.6' }: UpgradeDatabas
</p>
</div>
<Button color="primary" className="w-fit">
- <Link href={`/project/${project?.ref}/settings/infrastructure`}>Upgrade database</Link>
+ <Link href={getServiceVersionsPath(project?.ref)}>Upgrade database</Link>
</Button>
</Admonition>
)
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx
index ea61852ace7..884794f0ef0 100644
--- a/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx
+++ b/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx
@@ -14,6 +14,7 @@ import { CreateWrapperSheet } from './CreateWrapperSheet'
import { WRAPPERS } from './Wrappers.constants'
import { WrapperTable } from './WrapperTable'
import { useIsMarketplaceEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { getServiceVersionsPath } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils'
import { ScaffoldContainer, ScaffoldSection } from '@/components/layouts/Scaffold'
import { DiscardChangesConfirmationDialog } from '@/components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
@@ -124,7 +125,7 @@ const AddNewWrapperCTA = () => {
<Link
href={
databaseNeedsUpgrading
- ? `/project/${project?.ref}/settings/infrastructure`
+ ? getServiceVersionsPath(project?.ref)
: `/project/${project?.ref}/database/extensions?filter=wrappers`
}
>
diff --git a/apps/studio/components/interfaces/Linter/Linter.utils.tsx b/apps/studio/components/interfaces/Linter/Linter.utils.tsx
index a9b00f7fda9..2e8a7b0c11c 100644
--- a/apps/studio/components/interfaces/Linter/Linter.utils.tsx
+++ b/apps/studio/components/interfaces/Linter/Linter.utils.tsx
@@ -16,6 +16,7 @@ import { Badge, Button } from 'ui'
import { asGraphqlExposureLint, GraphqlExposureLintCTA } from './GraphqlExposureLintCTA'
import { LINTER_LEVELS, LintInfo } from '@/components/interfaces/Linter/Linter.constants'
+import { getServiceVersionsPath } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils'
import { Lint, LINT_TYPES } from '@/data/lint/lint-query'
import { DOCS_URL } from '@/lib/constants'
@@ -305,7 +306,7 @@ export const lintInfoMap: LintInfo[] = [
name: 'vulnerable_postgres_version',
title: 'Postgres version has security patches available',
icon: <LockIcon className="text-foreground-muted" size={15} strokeWidth={1} />,
- link: ({ projectRef }) => `/project/${projectRef}/settings/infrastructure`,
+ link: ({ projectRef }) => getServiceVersionsPath(projectRef),
linkText: 'View settings',
docsLink: `${DOCS_URL}/guides/platform/upgrading`,
category: 'security',
diff --git a/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx b/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx
index 6f30631ff4f..1f93a706ec9 100644
--- a/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx
+++ b/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx
@@ -6,6 +6,7 @@ import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { SectionContent } from '../SectionContent'
import { CategoryAttribute } from '../Usage.constants'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { AlertError } from '@/components/ui/AlertError'
import Panel from '@/components/ui/Panel'
import { PricingMetric } from '@/data/analytics/org-daily-stats-query'
@@ -59,7 +60,6 @@ export const DiskUsage = ({
})
.filter((it) => it.ref === projectRef || !projectRef)
: []
- // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isSuccess, projects, projectRef])
const hasProjectsExceedingDiskSize = useMemo(() => {
@@ -200,9 +200,7 @@ export const DiskUsage = ({
</div>
<Button asChild variant="default" size="tiny">
- <Link href={`/project/${project.ref}/settings/compute-and-disk`}>
- Manage Disk
- </Link>
+ <Link href={getInfrastructurePath(project.ref)}>Manage Disk</Link>
</Button>
</div>
)
diff --git a/apps/studio/components/interfaces/QueryPerformance/IndexAdvisor/IndexAdvisorDisabledState.tsx b/apps/studio/components/interfaces/QueryPerformance/IndexAdvisor/IndexAdvisorDisabledState.tsx
index 13351f9d8eb..ec98dd43e7d 100644
--- a/apps/studio/components/interfaces/QueryPerformance/IndexAdvisor/IndexAdvisorDisabledState.tsx
+++ b/apps/studio/components/interfaces/QueryPerformance/IndexAdvisor/IndexAdvisorDisabledState.tsx
@@ -5,6 +5,7 @@ import { Alert, AlertDescription, AlertTitle, Button } from 'ui'
import { Markdown } from '../../Markdown'
import { getIndexAdvisorExtensions } from './index-advisor.utils'
+import { getServiceVersionsPath } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils'
import { DocsButton } from '@/components/ui/DocsButton'
import { useDatabaseExtensionEnableMutation } from '@/data/database-extensions/database-extension-enable-mutation'
import { useDatabaseExtensionsQuery } from '@/data/database-extensions/database-extensions-query'
@@ -77,7 +78,7 @@ export const IndexAdvisorDisabledState = () => {
<div className="flex items-center gap-x-2">
{indexAdvisor === undefined ? (
<Button asChild variant="default">
- <Link href={`/project/${ref}/settings/infrastructure`}>Upgrade Postgres version</Link>
+ <Link href={getServiceVersionsPath(ref)}>Upgrade Postgres version</Link>
</Button>
) : (
<Button
diff --git a/apps/studio/components/interfaces/Settings/Database/JitDatabaseAccess/JitDbAccessConfiguration.tsx b/apps/studio/components/interfaces/Settings/Database/JitDatabaseAccess/JitDbAccessConfiguration.tsx
index ff497a0cf1e..bfd7d6a522e 100644
--- a/apps/studio/components/interfaces/Settings/Database/JitDatabaseAccess/JitDbAccessConfiguration.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/JitDatabaseAccess/JitDbAccessConfiguration.tsx
@@ -42,6 +42,7 @@ import {
import { JitDbAccessDeleteDialog } from './JitDbAccessDeleteDialog'
import { JitDbAccessRuleSheet } from './JitDbAccessRuleSheet'
import { JitDbAccessRulesTable } from './JitDbAccessRulesTable'
+import { getServiceVersionsPath } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils'
import { SupportLink } from '@/components/interfaces/Support/SupportLink'
import { AlertError } from '@/components/ui/AlertError'
import { DocsButton } from '@/components/ui/DocsButton'
@@ -379,7 +380,7 @@ export const JitDbAccessConfiguration = () => {
actions={
unavailableReason === 'postgres_upgrade_required' && ref ? (
<Button variant="default" asChild>
- <Link href={`/project/${ref}/settings/infrastructure`}>Upgrade Postgres</Link>
+ <Link href={getServiceVersionsPath(ref)}>Upgrade Postgres</Link>
</Button>
) : unavailableReason === 'ssl_enforcement_required' && ref ? (
<Button variant="default" asChild>
diff --git a/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils.test.ts b/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils.test.ts
new file mode 100644
index 00000000000..44a95ef8a9b
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils.test.ts
@@ -0,0 +1,15 @@
+import { describe, expect, it } from 'vitest'
+
+import { getServiceVersionsPath } from './ServiceVersions.utils'
+
+describe('getServiceVersionsPath', () => {
+ it('links directly to the Service versions section in General settings', () => {
+ expect(getServiceVersionsPath('project-ref')).toBe(
+ '/project/project-ref/settings/general#service-versions'
+ )
+ })
+
+ it('uses the project placeholder while the selected project is unavailable', () => {
+ expect(getServiceVersionsPath()).toBe('/project/_/settings/general#service-versions')
+ })
+})
diff --git a/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils.ts b/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils.ts
new file mode 100644
index 00000000000..ea5babc2202
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils.ts
@@ -0,0 +1,2 @@
+export const getServiceVersionsPath = (projectRef?: string) =>
+ `/project/${projectRef ?? '_'}/settings/general#service-versions`
diff --git a/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersionsSection.test.tsx b/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersionsSection.test.tsx
new file mode 100644
index 00000000000..1f384ce4210
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersionsSection.test.tsx
@@ -0,0 +1,280 @@
+import { render, screen } from '@testing-library/react'
+import type { InputHTMLAttributes, ReactNode } from 'react'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+import { ServiceVersionsSection } from './ServiceVersionsSection'
+
+const {
+ mockUseFeatures,
+ mockUseIsOrioleDb,
+ mockUseProject,
+ mockUseReadReplicas,
+ mockUseServiceVersions,
+ mockUseUpgradeEligibility,
+} = vi.hoisted(() => ({
+ mockUseFeatures: vi.fn(),
+ mockUseIsOrioleDb: vi.fn(),
+ mockUseProject: vi.fn(),
+ mockUseReadReplicas: vi.fn(),
+ mockUseServiceVersions: vi.fn(),
+ mockUseUpgradeEligibility: vi.fn(),
+}))
+
+vi.mock('common', () => ({
+ useParams: () => ({ ref: 'project-ref' }),
+}))
+
+vi.mock('ui', () => ({
+ Badge: ({ children }: { children: ReactNode }) => <span>{children}</span>,
+ Card: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ CardContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ Input: (props: InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
+ InputGroup: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ InputGroupAddon: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ InputGroupInput: (props: InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
+ Tooltip: ({ children }: { children: ReactNode }) => <>{children}</>,
+ TooltipContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ TooltipTrigger: ({ children }: { children: ReactNode }) => <>{children}</>,
+}))
+
+vi.mock('ui-patterns/Admonition', () => ({
+ Admonition: ({
+ title,
+ description,
+ children,
+ }: {
+ title?: ReactNode
+ description?: ReactNode
+ children?: ReactNode
+ }) => (
+ <div>
+ <div>{title}</div>
+ <div>{description}</div>
+ {children}
+ </div>
+ ),
+}))
+
+vi.mock('ui-patterns/form/FormItemLayout/FormItemLayout', () => ({
+ FormItemLayout: ({ label, children }: { label: ReactNode; children: ReactNode }) => (
+ <label>
+ {label}
+ {children}
+ </label>
+ ),
+}))
+
+vi.mock('ui-patterns/PageSection', () => ({
+ PageSection: ({ children, id }: { children: ReactNode; id?: string }) => (
+ <section id={id}>{children}</section>
+ ),
+ PageSectionContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ PageSectionDescription: ({ children }: { children: ReactNode }) => <p>{children}</p>,
+ PageSectionMeta: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ PageSectionSummary: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ PageSectionTitle: ({ children }: { children: ReactNode }) => <h2>{children}</h2>,
+}))
+
+vi.mock('ui-patterns/ShimmeringLoader', () => ({
+ GenericSkeletonLoader: () => <div>Loading service versions</div>,
+}))
+
+vi.mock('../../Infrastructure/UpgradeWarnings', () => ({
+ ReadReplicasWarning: ({ latestPgVersion }: { latestPgVersion?: string }) => (
+ <div>Read replicas block upgrade to {latestPgVersion}</div>
+ ),
+ ValidationErrorsWarning: ({ validationErrors }: { validationErrors?: string[] }) => (
+ <div>Validation errors: {validationErrors?.join(', ')}</div>
+ ),
+ ValidationWarningsAdmonition: ({ warnings }: { warnings?: string[] }) => (
+ <div>Validation warnings: {warnings?.join(', ')}</div>
+ ),
+}))
+
+vi.mock('../Infrastructure/ProjectUpgradeAlert', () => ({
+ ProjectUpgradeAlert: () => <div>Project upgrade available</div>,
+}))
+
+vi.mock('@/components/ui/AlertError', () => ({
+ AlertError: ({ subject }: { subject: string }) => <div>{subject}</div>,
+}))
+
+vi.mock('@/data/config/project-upgrade-eligibility-query', () => ({
+ useProjectUpgradeEligibilityQuery: mockUseUpgradeEligibility,
+}))
+
+vi.mock('@/data/projects/project-service-versions', () => ({
+ useProjectServiceVersionsQuery: mockUseServiceVersions,
+}))
+
+vi.mock('@/data/read-replicas/replicas-query', () => ({
+ useReadReplicasQuery: mockUseReadReplicas,
+}))
+
+vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({
+ useIsFeatureEnabled: mockUseFeatures,
+}))
+
+vi.mock('@/hooks/misc/useSelectedProject', () => ({
+ useIsOrioleDb: mockUseIsOrioleDb,
+ useSelectedProjectQuery: mockUseProject,
+}))
+
+describe('ServiceVersionsSection', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ mockUseFeatures.mockReturnValue({
+ projectAuthAll: true,
+ projectSettingsDatabaseUpgrades: true,
+ })
+ mockUseIsOrioleDb.mockReturnValue(false)
+ mockUseProject.mockReturnValue({ data: { status: 'ACTIVE_HEALTHY' } })
+ mockUseReadReplicas.mockReturnValue({ data: [{ identifier: 'project-ref' }] })
+ mockUseUpgradeEligibility.mockReturnValue({
+ data: {
+ current_app_version: 'supabase-postgres-15.8.1.060',
+ current_app_version_release_channel: 'ga',
+ latest_app_version: 'supabase-postgres-17.4.1.060',
+ eligible: true,
+ validation_errors: [],
+ warnings: [],
+ },
+ error: undefined,
+ isPending: false,
+ isError: false,
+ isSuccess: true,
+ })
+ mockUseServiceVersions.mockReturnValue({
+ data: {
+ gotrue: '2.180.0',
+ postgrest: '12.2.8',
+ 'supabase-postgres': '15.8.1.060',
+ },
+ error: undefined,
+ isPending: false,
+ isError: false,
+ isSuccess: true,
+ })
+ })
+
+ it('preserves the paused-project state without showing stale version values', () => {
+ mockUseProject.mockReturnValue({ data: { status: 'INACTIVE' } })
+
+ const { container } = render(<ServiceVersionsSection />)
+
+ expect(
+ screen.getByText('Service versions cannot be retrieved while project is paused')
+ ).toBeInTheDocument()
+ expect(screen.queryByDisplayValue('12.2.8')).not.toBeInTheDocument()
+ expect(container.querySelector('#service-versions')).toBeInTheDocument()
+ })
+
+ it('renders Auth, PostgREST, and Postgres versions with release metadata', () => {
+ mockUseIsOrioleDb.mockReturnValue(true)
+ mockUseUpgradeEligibility.mockReturnValue({
+ data: {
+ current_app_version: 'supabase-postgres-17.4.1.060-orioledb',
+ current_app_version_release_channel: 'beta',
+ latest_app_version: 'supabase-postgres-17.4.1.060-orioledb',
+ eligible: true,
+ validation_errors: [],
+ warnings: [],
+ },
+ error: undefined,
+ isPending: false,
+ isError: false,
+ isSuccess: true,
+ })
+
+ render(<ServiceVersionsSection />)
+
+ expect(screen.getByDisplayValue('2.180.0')).toBeInTheDocument()
+ expect(screen.getByDisplayValue('12.2.8')).toBeInTheDocument()
+ expect(screen.getByDisplayValue('17.4.1.060')).toBeInTheDocument()
+ expect(screen.getAllByText('beta').length).toBeGreaterThan(0)
+ expect(screen.getAllByText('OrioleDB').length).toBeGreaterThan(0)
+ expect(screen.getAllByText('Latest').length).toBeGreaterThan(0)
+ expect(screen.getByText('Project upgrade available')).toBeInTheDocument()
+ })
+
+ it('shows the read-replica upgrade block instead of the upgrade action', () => {
+ mockUseReadReplicas.mockReturnValue({
+ data: [{ identifier: 'project-ref' }, { identifier: 'replica-1' }],
+ })
+
+ render(<ServiceVersionsSection />)
+
+ expect(screen.getByText('Read replicas block upgrade to 17.4.1.060')).toBeInTheDocument()
+ expect(screen.queryByText('Project upgrade available')).not.toBeInTheDocument()
+ })
+
+ it('renders upgrade validation errors and warnings for an ineligible project', () => {
+ mockUseUpgradeEligibility.mockReturnValue({
+ data: {
+ current_app_version: 'supabase-postgres-15.8.1.060',
+ latest_app_version: 'supabase-postgres-17.4.1.060',
+ eligible: false,
+ validation_errors: ['Remove read replicas'],
+ warnings: ['Review extension compatibility'],
+ },
+ error: undefined,
+ isPending: false,
+ isError: false,
+ isSuccess: true,
+ })
+
+ render(<ServiceVersionsSection />)
+
+ expect(screen.getByText('Validation errors: Remove read replicas')).toBeInTheDocument()
+ expect(
+ screen.getByText('Validation warnings: Review extension compatibility')
+ ).toBeInTheDocument()
+ expect(screen.queryByText('Project upgrade available')).not.toBeInTheDocument()
+ })
+
+ it('preserves eligibility and service-version loading and error states', () => {
+ mockUseUpgradeEligibility
+ .mockReturnValueOnce({
+ data: undefined,
+ error: undefined,
+ isPending: true,
+ isError: false,
+ isSuccess: false,
+ })
+ .mockReturnValueOnce({
+ data: undefined,
+ error: new Error('eligibility failed'),
+ isPending: false,
+ isError: true,
+ isSuccess: false,
+ })
+
+ const { rerender } = render(<ServiceVersionsSection />)
+ expect(screen.getByText('Loading service versions')).toBeInTheDocument()
+
+ rerender(<ServiceVersionsSection />)
+ expect(screen.getByText('Failed to retrieve Postgres version')).toBeInTheDocument()
+
+ mockUseUpgradeEligibility.mockReturnValue({
+ data: {
+ current_app_version: 'supabase-postgres-15.8.1.060',
+ latest_app_version: 'supabase-postgres-17.4.1.060',
+ eligible: true,
+ },
+ error: undefined,
+ isPending: false,
+ isError: false,
+ isSuccess: true,
+ })
+ mockUseServiceVersions.mockReturnValue({
+ data: undefined,
+ error: new Error('versions failed'),
+ isPending: false,
+ isError: true,
+ isSuccess: false,
+ })
+
+ rerender(<ServiceVersionsSection />)
+ expect(screen.getByText('Failed to retrieve versions')).toBeInTheDocument()
+ })
+})
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx b/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersionsSection.tsx
similarity index 89%
rename from apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx
rename to apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersionsSection.tsx
index aacf582ae32..b08da20bad0 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx
+++ b/apps/studio/components/interfaces/Settings/General/ServiceVersions/ServiceVersionsSection.tsx
@@ -1,6 +1,8 @@
import { useParams } from 'common'
import {
Badge,
+ Card,
+ CardContent,
Input,
InputGroup,
InputGroupAddon,
@@ -11,21 +13,22 @@ import {
} from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import {
+ PageSection,
+ PageSectionContent,
+ PageSectionDescription,
+ PageSectionMeta,
+ PageSectionSummary,
+ PageSectionTitle,
+} from 'ui-patterns/PageSection'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
-import { ProjectUpgradeAlert } from '../General/Infrastructure/ProjectUpgradeAlert'
import {
ReadReplicasWarning,
ValidationErrorsWarning,
ValidationWarningsAdmonition,
-} from './UpgradeWarnings'
-import {
- ScaffoldContainer,
- ScaffoldDivider,
- ScaffoldSection,
- ScaffoldSectionContent,
- ScaffoldSectionDetail,
-} from '@/components/layouts/Scaffold'
+} from '../../Infrastructure/UpgradeWarnings'
+import { ProjectUpgradeAlert } from '../Infrastructure/ProjectUpgradeAlert'
import { AlertError } from '@/components/ui/AlertError'
import { useProjectUpgradeEligibilityQuery } from '@/data/config/project-upgrade-eligibility-query'
import { useProjectServiceVersionsQuery } from '@/data/projects/project-service-versions'
@@ -33,7 +36,7 @@ import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
-export const InfrastructureInfo = () => {
+export const ServiceVersionsSection = () => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
@@ -82,18 +85,18 @@ export const InfrastructureInfo = () => {
const hasReadReplicas = (databases ?? []).length > 1
return (
- <>
- <ScaffoldDivider />
-
- <ScaffoldContainer>
- <ScaffoldSection>
- <ScaffoldSectionDetail>
- <h4 className="text-base capitalize m-0">Service versions</h4>
- <p className="text-foreground-light text-sm pr-8 mt-1">
- Service versions and upgrade eligibility for your provisioned instance.
- </p>
- </ScaffoldSectionDetail>
- <ScaffoldSectionContent>
+ <PageSection id="service-versions">
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>Service versions</PageSectionTitle>
+ <PageSectionDescription>
+ Service versions and upgrade eligibility for your provisioned instance.
+ </PageSectionDescription>
+ </PageSectionSummary>
+ </PageSectionMeta>
+ <PageSectionContent>
+ <Card>
+ <CardContent className="flex flex-col gap-6">
{isInactive ? (
<Admonition
type="note"
@@ -103,7 +106,6 @@ export const InfrastructureInfo = () => {
/>
) : (
<>
- {/* [Joshen] Double check why we need this waterfall loading behaviour here */}
{isLoadingUpgradeEligibility && <GenericSkeletonLoader />}
{isErrorUpgradeEligibility && (
<AlertError error={error} subject="Failed to retrieve Postgres version" />
@@ -214,9 +216,9 @@ export const InfrastructureInfo = () => {
)}
</>
)}
- </ScaffoldSectionContent>
- </ScaffoldSection>
- </ScaffoldContainer>
- </>
+ </CardContent>
+ </Card>
+ </PageSectionContent>
+ </PageSection>
)
}
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.constants.ts b/apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.constants.ts
deleted file mode 100644
index b2cb9ad13ca..00000000000
--- a/apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.constants.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import { DOCS_URL } from '@/lib/constants'
-
-export interface Attribute {
- key: string
- name?: string
- color: 'white' | 'blue' | 'green' | 'yellow' | 'orange'
-}
-export interface CategoryAttribute {
- anchor: string
- key: string // Property from organization usage
- attributes: Attribute[] // For querying against stats-daily / infra-monitoring
- name: string
- unit: 'bytes' | 'absolute' | 'percentage'
- links: {
- name: string
- url: string
- }[]
- description: string
- chartPrefix?: 'Max' | 'Average'
- chartDescription: string
-}
-
-export interface CategoryMeta {
- key: string
- name: string
- description: string
- attributes: CategoryAttribute[]
-}
-
-export const INFRA_ACTIVITY_METRICS: CategoryMeta[] = [
- {
- key: 'infra',
- name: 'Infrastructure',
- description: 'Usage statistics related to your server instance',
- attributes: [
- {
- anchor: 'cpu',
- key: 'max_cpu_usage',
- attributes: [{ key: 'max_cpu_usage', color: 'white' }],
- name: 'CPU',
- unit: 'percentage',
- description: 'Max CPU usage of your server.',
- chartDescription: '',
- links: [
- {
- name: 'Compute Add-Ons',
- url: `${DOCS_URL}/guides/platform/compute-add-ons`,
- },
- {
- name: 'High CPU Usage',
- url: `${DOCS_URL}/guides/troubleshooting/high-cpu-usage`,
- },
- {
- name: 'Metrics',
- url: `${DOCS_URL}/guides/platform/metrics`,
- },
- ],
- },
- {
- anchor: 'ram',
- key: 'ram_usage',
- attributes: [{ key: 'ram_usage', color: 'white' }],
- name: 'Memory',
- unit: 'percentage',
- description:
- 'Memory usage of your server.\nYou might observe elevated memory usage, even with little to no load. Besides Postgres, a wide range of services are running under the hood resulting in an elevated base memory usage.',
- chartDescription: '',
- links: [
- {
- name: 'Compute Add-Ons',
- url: `${DOCS_URL}/guides/platform/compute-add-ons`,
- },
- {
- name: 'High RAM Usage',
- url: `${DOCS_URL}/guides/troubleshooting/exhaust-ram`,
- },
- {
- name: 'Metrics',
- url: `${DOCS_URL}/guides/platform/metrics`,
- },
- ],
- },
- {
- anchor: 'disk_io',
- key: 'disk_io_consumption',
- attributes: [{ key: 'disk_io_consumption', color: 'white' }],
- name: 'Disk IO Bandwidth',
- unit: 'percentage',
- links: [
- {
- name: 'Disk Throughput and IOPS',
- url: `${DOCS_URL}/guides/platform/compute-add-ons#disk-throughput-and-iops`,
- },
- {
- name: 'High Disk I/O',
- url: `${DOCS_URL}/guides/troubleshooting/exhaust-disk-io`,
- },
- {
- name: 'Metrics',
- url: `${DOCS_URL}/guides/platform/metrics`,
- },
- ],
- description:
- 'The disk performance of your workload is determined by the Disk IO bandwidth.\nSmaller compute instances (below 4XL) can burst above their baseline disk throughput and IOPS for short periods of time. Beyond that, the performance reverts to the baseline.',
- chartDescription: '',
- },
- ],
- },
-]
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.test.ts b/apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.test.ts
new file mode 100644
index 00000000000..21cea9fd315
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.test.ts
@@ -0,0 +1,15 @@
+import { describe, expect, it } from 'vitest'
+
+import { getInfrastructurePath } from './Infrastructure.utils'
+
+describe('getInfrastructurePath', () => {
+ it('builds the path for a project ref', () => {
+ expect(getInfrastructurePath('project-ref')).toBe(
+ '/project/project-ref/settings/infrastructure'
+ )
+ })
+
+ it('falls back to the default project placeholder', () => {
+ expect(getInfrastructurePath()).toBe('/project/_/settings/infrastructure')
+ })
+})
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.ts b/apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.ts
new file mode 100644
index 00000000000..1d816d3151c
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.ts
@@ -0,0 +1,2 @@
+export const getInfrastructurePath = (projectRef?: string) =>
+ `/project/${projectRef ?? '_'}/settings/infrastructure`
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
deleted file mode 100644
index d56d563379c..00000000000
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
+++ /dev/null
@@ -1,462 +0,0 @@
-import { useParams } from 'common'
-import dayjs from 'dayjs'
-import { capitalize } from 'lodash'
-import { BarChart2, ChartLine, ExternalLink } from 'lucide-react'
-import Link from 'next/link'
-import { Fragment, useMemo, useState } from 'react'
-import { Button } from 'ui'
-import { Admonition } from 'ui-patterns/Admonition'
-import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
-
-import { INFRA_ACTIVITY_METRICS } from './Infrastructure.constants'
-import { getAddons } from '@/components/interfaces/Billing/Subscription/Subscription.utils'
-import { CPUWarnings } from '@/components/interfaces/Billing/Usage/UsageWarningAlerts/CPUWarnings'
-import { DiskIOBandwidthWarnings } from '@/components/interfaces/Billing/Usage/UsageWarningAlerts/DiskIOBandwidthWarnings'
-import { RAMWarnings } from '@/components/interfaces/Billing/Usage/UsageWarningAlerts/RAMWarnings'
-import UsageBarChart from '@/components/interfaces/Organization/Usage/UsageBarChart'
-import {
- ScaffoldContainer,
- ScaffoldDivider,
- ScaffoldSection,
- ScaffoldSectionContent,
- ScaffoldSectionDetail,
-} from '@/components/layouts/Scaffold'
-import { DatabaseSelector } from '@/components/ui/DatabaseSelector'
-import { DateRangePicker } from '@/components/ui/DateRangePicker'
-import { DocsButton } from '@/components/ui/DocsButton'
-import Panel from '@/components/ui/Panel'
-import { DataPoint } from '@/data/analytics/constants'
-import { mapResponseToAnalyticsData } from '@/data/analytics/infra-monitoring-queries'
-import {
- InfraMonitoringAttribute,
- useInfraMonitoringAttributesQuery,
-} from '@/data/analytics/infra-monitoring-query'
-import { useOrgSubscriptionQuery } from '@/data/subscriptions/org-subscription-query'
-import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
-import { useResourceWarningsQuery } from '@/data/usage/resource-warnings-query'
-import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
-import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
-import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
-import { DOCS_URL, INSTANCE_MICRO_SPECS, INSTANCE_NANO_SPECS, InstanceSpecs } from '@/lib/constants'
-import { TIME_PERIODS_BILLING, TIME_PERIODS_REPORTS } from '@/lib/constants/metrics'
-import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
-
-const NON_DEDICATED_IO_RESOURCES = [
- 'ci_micro',
- 'ci_small',
- 'ci_medium',
- 'ci_large',
- 'ci_xlarge',
- 'ci_2xlarge',
-]
-
-const INFRA_ATTRIBUTES: InfraMonitoringAttribute[] = [
- 'max_cpu_usage',
- 'ram_usage',
- 'disk_io_consumption',
-]
-
-export const InfrastructureActivity = () => {
- const { ref: projectRef } = useParams()
- const { data: project } = useSelectedProjectQuery()
- const { data: organization } = useSelectedOrganizationQuery()
- const state = useDatabaseSelectorStateSnapshot()
- const [dateRange, setDateRange] = useState<any>()
-
- const { data: subscription, isPending: isLoadingSubscription } = useOrgSubscriptionQuery({
- orgSlug: organization?.slug,
- })
- const { hasAccess: hasAccessToComputeSizes } = useCheckEntitlements(
- 'instances.compute_update_available_sizes'
- )
-
- const { data: resourceWarnings } = useResourceWarningsQuery({ ref: projectRef })
- // [Joshen Cleanup] JFYI this client side filtering can be cleaned up once BE changes are live which will only return the warnings based on the provided ref
- const projectResourceWarnings = resourceWarnings?.find((x) => x.project === projectRef)
-
- const { data: addons } = useProjectAddonsQuery({ projectRef })
- const selectedAddons = addons?.selected_addons ?? []
-
- const { computeInstance } = getAddons(selectedAddons)
- const hasDedicatedIOResources =
- computeInstance !== undefined &&
- !NON_DEDICATED_IO_RESOURCES.includes(computeInstance.variant.identifier)
-
- function getCurrentComputeInstanceSpecs() {
- if (computeInstance?.variant.meta) {
- // If user has a compute instance (called addons) return that
- return computeInstance?.variant.meta as InstanceSpecs
- } else {
- // Otherwise, return the default specs
- return project?.infra_compute_size === 'nano' ? INSTANCE_NANO_SPECS : INSTANCE_MICRO_SPECS
- }
- }
-
- const currentComputeInstanceSpecs = getCurrentComputeInstanceSpecs()
-
- const currentBillingCycleSelected = useMemo(() => {
- // Selected by default
- if (!dateRange?.period_start || !dateRange?.period_end || !subscription) return true
-
- const { current_period_start, current_period_end } = subscription
-
- return (
- dayjs(dateRange.period_start.date).isSame(new Date(current_period_start * 1000)) &&
- dayjs(dateRange.period_end.date).isSame(new Date(current_period_end * 1000))
- )
- }, [dateRange, subscription])
-
- const upgradeUrl =
- organization === undefined
- ? `/`
- : hasAccessToComputeSizes
- ? `/org/${organization?.slug ?? '[slug]'}/billing#subscription`
- : `/project/${projectRef}/settings/addons`
-
- const categoryMeta = INFRA_ACTIVITY_METRICS.find((category) => category.key === 'infra')
-
- const startDate = useMemo(() => {
- if (dateRange?.period_start?.date === 'Invalid Date') return undefined
-
- // If end date is in future, set end date to now
- if (!dateRange?.period_start?.date) {
- return undefined
- } else {
- // LF seems to have an issue with the milliseconds, causes infinite loading sometimes
- return new Date(dateRange?.period_start?.date ?? 0).toISOString().slice(0, -5) + 'Z'
- }
- }, [dateRange])
-
- const endDate = useMemo(() => {
- if (dateRange?.period_end?.date === 'Invalid Date') return undefined
-
- // If end date is in future, set end date to end of current day
- if (dateRange?.period_end?.date && dayjs(dateRange.period_end.date).isAfter(dayjs())) {
- // LF seems to have an issue with the milliseconds, causes infinite loading sometimes
- // In order to have full days from Prometheus metrics when using 1d interval,
- // the time needs to be greater or equal than the time of the start date
- return dayjs().endOf('day').toISOString().slice(0, -5) + 'Z'
- } else if (dateRange?.period_end?.date) {
- // LF seems to have an issue with the milliseconds, causes infinite loading sometimes
- return new Date(dateRange.period_end.date ?? 0).toISOString().slice(0, -5) + 'Z'
- }
- }, [dateRange])
-
- // Switch to hourly interval, if the timeframe is <48 hours
- let interval: '1d' | '1h' = '1d'
- let dateFormat = 'DD MMM'
- if (startDate && endDate) {
- const diffInHours = dayjs(endDate).diff(startDate, 'hours')
-
- if (diffInHours <= 48) {
- interval = '1h'
- dateFormat = 'h a'
- }
- }
-
- const { data: infraMonitoringData, isPending: isLoadingInfraData } =
- useInfraMonitoringAttributesQuery({
- projectRef,
- attributes: INFRA_ATTRIBUTES,
- interval,
- startDate,
- endDate,
- databaseIdentifier: state.selectedDatabaseId,
- })
-
- const transformedData = useMemo(() => {
- if (!infraMonitoringData) return undefined
- return mapResponseToAnalyticsData(infraMonitoringData, INFRA_ATTRIBUTES, dateFormat)
- }, [infraMonitoringData, dateFormat])
-
- const cpuUsageData = transformedData?.max_cpu_usage
- const memoryUsageData = transformedData?.ram_usage
- const ioBudgetData = transformedData?.disk_io_consumption
-
- const hasLatest = dayjs(endDate!).isAfter(dayjs().startOf('day'))
-
- const latestIoBudgetConsumption =
- hasLatest && ioBudgetData?.data?.slice(-1)?.[0]
- ? Number(ioBudgetData.data.slice(-1)[0].disk_io_consumption)
- : 0
-
- const highestIoBudgetConsumption = (ioBudgetData?.data || [])
- .map((x) => Number(x.disk_io_consumption) ?? 0)
- .reduce((a, b) => Math.max(a, b), 0)
-
- const chartMeta: { [key: string]: { data: DataPoint[]; isLoading: boolean } } = {
- max_cpu_usage: {
- isLoading: isLoadingInfraData,
- data: cpuUsageData?.data ?? [],
- },
- ram_usage: {
- isLoading: isLoadingInfraData,
- data: memoryUsageData?.data ?? [],
- },
- disk_io_consumption: {
- isLoading: isLoadingInfraData,
- data: ioBudgetData?.data ?? [],
- },
- }
-
- return (
- <>
- <ScaffoldContainer id="infrastructure-activity">
- <div className="mx-auto flex flex-col gap-10 pt-6">
- <div>
- <p className="text-xl">Infrastructure Activity</p>
- <p className="text-sm text-foreground-light">
- Activity statistics related to your server instance
- </p>
- </div>
- </div>
- </ScaffoldContainer>
- <ScaffoldContainer className="sticky top-0 py-6 border-b bg-studio z-10">
- <div className="flex items-center gap-x-4">
- <DatabaseSelector />
- {!isLoadingSubscription && (
- <>
- <DateRangePicker
- onChange={setDateRange}
- value={TIME_PERIODS_REPORTS[0].key}
- options={[...TIME_PERIODS_BILLING, ...TIME_PERIODS_REPORTS]}
- loading={isLoadingSubscription}
- currentBillingPeriodStart={subscription?.current_period_start}
- currentBillingPeriodEnd={subscription?.current_period_end}
- />
- <p className="text-sm text-foreground-light">
- {dayjs(startDate).format('DD MMM YYYY')} - {dayjs(endDate).format('DD MMM YYYY')}
- </p>
- </>
- )}
- </div>
- </ScaffoldContainer>
-
- {categoryMeta?.attributes.map((attribute) => {
- const chartData = chartMeta[attribute.key]?.data ?? []
-
- return (
- <Fragment key={attribute.key}>
- <ScaffoldContainer id={attribute.anchor}>
- <ScaffoldSection>
- <ScaffoldSectionDetail>
- <div className="sticky top-32 space-y-6">
- <div className="space-y-1">
- <div className="flex items-center space-x-2">
- <h4 className="text-base capitalize m-0">{attribute.name}</h4>
- </div>
- <div className="grid gap-4">
- {attribute.description.split('\n').map((value, idx) => (
- <p key={`desc-${idx}`} className="text-sm text-foreground-light pr-8 m-0">
- {value}
- </p>
- ))}
- </div>
- </div>
- <div className="space-y-2">
- <p className="text-sm text-foreground mb-2">More information</p>
- {attribute.links.map((link) => (
- <div key={link.url}>
- <Link href={link.url} target="_blank" rel="noreferrer">
- <div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">
- <p className="text-sm m-0">{link.name}</p>
- <ExternalLink size={16} strokeWidth={1.5} />
- </div>
- </Link>
- </div>
- ))}
- </div>
- </div>
- </ScaffoldSectionDetail>
- <ScaffoldSectionContent>
- {attribute.key === 'disk_io_consumption' && (
- <>
- <DiskIOBandwidthWarnings
- upgradeUrl={upgradeUrl}
- hasAccessToComputeSizes={hasAccessToComputeSizes}
- hasLatest={hasLatest}
- currentBillingCycleSelected={currentBillingCycleSelected}
- latestIoBudgetConsumption={latestIoBudgetConsumption}
- highestIoBudgetConsumption={highestIoBudgetConsumption}
- />
- <div className="space-y-1">
- <p>Disk IO Bandwidth</p>
-
- {currentComputeInstanceSpecs.baseline_disk_io_mbs ===
- currentComputeInstanceSpecs.max_disk_io_mbs ? (
- <p className="text-sm text-foreground-light">
- Your current compute has a baseline and maximum disk throughput of{' '}
- {currentComputeInstanceSpecs.max_disk_io_mbs?.toLocaleString()} Mbps.
- </p>
- ) : (
- <p className="text-sm text-foreground-light">
- Your current compute can burst above the baseline disk throughput of{' '}
- {currentComputeInstanceSpecs.baseline_disk_io_mbs?.toLocaleString()}{' '}
- Mbps for short periods of time.
- </p>
- )}
- </div>
- <div>
- <p className="text-sm mb-2">Overview</p>
- <div className="flex items-center justify-between border-b py-1">
- <p className="text-xs text-foreground-light">Current compute instance</p>
- <p className="text-xs">
- {computeInstance?.variant?.name ??
- capitalize(project?.infra_compute_size) ??
- 'Micro'}
- </p>
- </div>
- <div className="flex items-center justify-between border-b py-1">
- <p className="text-xs text-foreground-light">Baseline IO Bandwidth</p>
- <p className="text-xs">
- {currentComputeInstanceSpecs.baseline_disk_io_mbs?.toLocaleString()}{' '}
- Mbps
- </p>
- </div>
- <div className="flex items-center justify-between border-b py-1">
- <p className="text-xs text-foreground-light">
- Maximum IO Bandwidth (burst limit)
- </p>
- <p className="text-xs">
- {currentComputeInstanceSpecs.max_disk_io_mbs?.toLocaleString()} Mbps
- </p>
- </div>
- {currentComputeInstanceSpecs.max_disk_io_mbs !==
- currentComputeInstanceSpecs?.baseline_disk_io_mbs && (
- <div className="flex items-center justify-between py-1">
- <p className="text-xs text-foreground-light">Daily burst time limit</p>
- <p className="text-xs">30 mins</p>
- </div>
- )}
- </div>
- </>
- )}
- {attribute.key === 'max_cpu_usage' && (
- <CPUWarnings
- upgradeUrl={upgradeUrl}
- hasAccessToComputeSizes={hasAccessToComputeSizes}
- severity={projectResourceWarnings?.cpu_exhaustion}
- />
- )}
- {attribute.key === 'ram_usage' && (
- <RAMWarnings
- upgradeUrl={upgradeUrl}
- hasAccessToComputeSizes={hasAccessToComputeSizes}
- severity={projectResourceWarnings?.memory_and_swap_exhaustion}
- />
- )}
-
- <div className="space-y-1">
- <div className="flex flex-row justify-between">
- {attribute.key === 'disk_io_consumption' ? (
- <p>Disk IO consumed per {interval === '1d' ? 'day' : 'hour'}</p>
- ) : (
- <p>
- Max{' '}
- <span className={attribute.key === 'ram_usage' ? 'lowercase' : ''}>
- {attribute.name}
- </span>{' '}
- utilization per {interval === '1d' ? 'day' : 'hour'}
- </p>
- )}
- </div>
-
- {attribute.key === 'ram_usage' && (
- <div className="text-sm text-foreground-light">
- <p>
- Your compute instance has {currentComputeInstanceSpecs.memory_gb} GB of
- memory.
- </p>
- {currentComputeInstanceSpecs.memory_gb === 1 && (
- <p>
- As your project is running on the smallest compute instance, it is not
- unusual for your project to have a base memory usage of ~50%.
- </p>
- )}
- </div>
- )}
-
- {attribute.key === 'max_cpu_usage' && (
- <p className="text-sm text-foreground-light">
- Your compute instance has {currentComputeInstanceSpecs.cpu_cores} CPU cores.
- </p>
- )}
-
- {attribute.chartDescription.split('\n').map((paragraph, idx) => (
- <p key={`para-${idx}`} className="text-sm text-foreground-light">
- {paragraph}
- </p>
- ))}
- </div>
- {attribute.key === 'disk_io_consumption' && hasDedicatedIOResources ? (
- <>
- <Admonition
- type="note"
- title={`Your compute instance of ${computeInstance.variant.name} comes with dedicated I/O resources`}
- description="Your project thus does not rely on I/O balance or burst capacity as larger
- add-ons are designed for sustained, high performance with specific IOPS and
- throughput limits without needing to burst."
- >
- <DocsButton
- abbrev={false}
- href={`${DOCS_URL}/guides/platform/compute-add-ons#disk-throughput-and-iops`}
- />
- </Admonition>
- </>
- ) : chartMeta[attribute.key].isLoading ? (
- <div className="space-y-2">
- <ShimmeringLoader />
- <ShimmeringLoader className="w-3/4" />
- <ShimmeringLoader className="w-1/2" />
- </div>
- ) : chartData.length ? (
- <UsageBarChart
- name={`${attribute.chartPrefix || ''} ${attribute.name}`}
- unit={attribute.unit}
- attributes={attribute.attributes}
- data={chartData}
- yFormatter={(value) => `${Math.round(Number(value))}%`}
- tooltipFormatter={(value) => `${value}%`}
- yLimit={100}
- />
- ) : (
- <Panel>
- <Panel.Content>
- <div className="flex flex-col items-center justify-center space-y-2">
- <BarChart2 size={18} className="text-foreground-light mb-2" />
- <p className="text-sm">No data in period</p>
- <p className="text-sm text-foreground-light">
- May take a few minutes to show
- </p>
- </div>
- </Panel.Content>
- </Panel>
- )}
- {attribute.key === 'disk_io_consumption' && !hasDedicatedIOResources && (
- <Admonition
- type="default"
- title="Looking for actual disk activity?"
- description="The chart above shows your remaining burst budget, not real disk throughput. For detailed read/write IOPS and throughput charts, head to the Database Observability page."
- >
- <Button
- asChild
- variant="default"
- className="mt-2"
- icon={<ChartLine size={14} />}
- >
- <Link href={`/project/${projectRef}/observability/database`}>
- View detailed IOPS and throughput
- </Link>
- </Button>
- </Admonition>
- )}
- </ScaffoldSectionContent>
- </ScaffoldSection>
- </ScaffoldContainer>
- <ScaffoldDivider />
- </Fragment>
- )
- })}
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx
index f8f898ad978..b59b45ceee6 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx
@@ -36,6 +36,7 @@ import { addRegionNodes, generateNodes, getDagreGraphLayout } from './InstanceCo
import { LoadBalancerNode, PrimaryNode, RegionNode, ReplicaNode } from './InstanceNode'
import MapView from './MapView'
import { RestartReplicaConfirmationModal } from './RestartReplicaConfirmationModal'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { AlertError } from '@/components/ui/AlertError'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { useLoadBalancersQuery } from '@/data/read-replicas/load-balancers-query'
@@ -301,9 +302,7 @@ const InstanceConfigurationUI = ({ diagramOnly = false }: InstanceConfigurationU
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-52 *:space-x-2">
<DropdownMenuItem asChild>
- <Link href={`/project/${projectRef}/settings/compute-and-disk`}>
- Resize databases
- </Link>
+ <Link href={getInfrastructurePath(projectRef)}>Resize databases</Link>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => setShowDeleteAllModal(true)}>
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/BucketCallouts.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/BucketCallouts.tsx
index 21f797b4222..98a0070380e 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/BucketCallouts.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/BucketCallouts.tsx
@@ -4,6 +4,7 @@ import { Admonition } from 'ui-patterns/Admonition'
import { SimpleConfigurationDetails } from './SimpleConfigurationDetails'
import { WrapperMeta } from '@/components/interfaces/Integrations/Wrappers/Wrappers.types'
+import { getServiceVersionsPath } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils'
import { ScaffoldSection } from '@/components/layouts/Scaffold'
import { InlineLink } from '@/components/ui/InlineLink'
import { DatabaseExtension } from '@/data/database-extensions/database-extensions-query'
@@ -48,7 +49,7 @@ export const ExtensionNotInstalled = ({
<Link
href={
databaseNeedsUpgrading
- ? `/project/${projectRef}/settings/infrastructure`
+ ? getServiceVersionsPath(projectRef)
: `/project/${projectRef}/database/extensions?filter=wrappers`
}
>
@@ -97,7 +98,7 @@ export const ExtensionNeedsUpgrade = ({
<Link
href={
databaseNeedsUpgrading
- ? `/project/${projectRef}/settings/infrastructure`
+ ? getServiceVersionsPath(projectRef)
: `/project/${projectRef}/database/extensions?filter=wrappers`
}
>
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/CreateAnalyticsBucketForm.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/CreateAnalyticsBucketForm.tsx
index f48a5d1de58..25446fb5eb1 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/CreateAnalyticsBucketForm.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/CreateAnalyticsBucketForm.tsx
@@ -24,6 +24,7 @@ import {
reservedSuffixes,
validBucketNameRegex,
} from './CreateAnalyticsBucketForm.utils'
+import { getServiceVersionsPath } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils'
import { InlineLink } from '@/components/ui/InlineLink'
import { useDatabaseExtensionEnableMutation } from '@/data/database-extensions/database-extension-enable-mutation'
import { useAnalyticsBucketCreateMutation } from '@/data/storage/analytics-bucket-create-mutation'
@@ -226,9 +227,7 @@ export const CreateAnalyticsBucketForm = ({
<p className="prose max-w-full text-sm leading-normal!">
Update the <code className="text-code-inline">wrappers</code> extension by
upgrading your project from your{' '}
- <InlineLink href={`/project/${ref}/settings/infrastructure`}>
- project settings
- </InlineLink>{' '}
+ <InlineLink href={getServiceVersionsPath(ref)}>project settings</InlineLink>{' '}
before creating an Analytics bucket.{' '}
<InlineLink href={`${DOCS_URL}/guides/database/extensions/wrappers/iceberg`}>
Learn more
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails/VectorBucketCallouts.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails/VectorBucketCallouts.tsx
index a39c18f8254..acadd747eec 100644
--- a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails/VectorBucketCallouts.tsx
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails/VectorBucketCallouts.tsx
@@ -4,6 +4,7 @@ import { Button } from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { WrapperMeta } from '@/components/interfaces/Integrations/Wrappers/Wrappers.types'
+import { getServiceVersionsPath } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersions.utils'
import { ScaffoldSection } from '@/components/layouts/Scaffold'
import { InlineLink } from '@/components/ui/InlineLink'
import { DatabaseExtension } from '@/data/database-extensions/database-extensions-query'
@@ -40,7 +41,7 @@ export const ExtensionNotInstalled = ({
<Link
href={
databaseNeedsUpgrading
- ? `/project/${projectRef}/settings/infrastructure`
+ ? getServiceVersionsPath(projectRef)
: `/project/${projectRef}/database/extensions?filter=wrappers`
}
>
@@ -84,7 +85,7 @@ export const ExtensionNeedsUpgrade = ({
<Link
href={
databaseNeedsUpgrading
- ? `/project/${projectRef}/settings/infrastructure`
+ ? getServiceVersionsPath(projectRef)
: `/project/${projectRef}/database/extensions?filter=wrappers`
}
>
diff --git a/apps/studio/components/interfaces/Support/CategoryAndSeverityInfo.tsx b/apps/studio/components/interfaces/Support/CategoryAndSeverityInfo.tsx
index c8e07af7646..b1806a24497 100644
--- a/apps/studio/components/interfaces/Support/CategoryAndSeverityInfo.tsx
+++ b/apps/studio/components/interfaces/Support/CategoryAndSeverityInfo.tsx
@@ -186,14 +186,11 @@ const IssueSuggestion = ({ category, projectRef }: { category: string; projectRe
<Admonition
type="default"
className={className}
- title="Have you checked your project's infrastructure activity?"
+ title="Have you checked your project's database observability reports?"
>
High memory or low disk IO bandwidth may be slowing down your database. Verify by checking
- the infrastructure activity of your project{' '}
- <InlineLink href={`${baseUrl}/settings/infrastructure#infrastructure-activity`}>
- here
- </InlineLink>
- .
+ your project's database observability reports{' '}
+ <InlineLink href={`${baseUrl}/observability/database`}>here</InlineLink>.
</Admonition>
)
}
@@ -205,12 +202,9 @@ const IssueSuggestion = ({ category, projectRef }: { category: string; projectRe
className={className}
title="Have you checked the Query Performance Advisor?"
>
- Identify slow running queries and get actionable insights on how to optimize them with the
- Query Performance Advisor{' '}
- <InlineLink href={`${baseUrl}/settings/infrastructure#infrastructure-activity`}>
- here
- </InlineLink>
- .
+ Identify slow running queries and get actionable insights on how to optimize them with Query
+ Performance{' '}
+ <InlineLink href={`${baseUrl}/observability/query-performance`}>here</InlineLink>.
</Admonition>
)
}
diff --git a/apps/studio/components/layouts/ProjectLayout/ConnectingState.tsx b/apps/studio/components/layouts/ProjectLayout/ConnectingState.tsx
index 2e67ae92f60..5ae9884d3d9 100644
--- a/apps/studio/components/layouts/ProjectLayout/ConnectingState.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/ConnectingState.tsx
@@ -4,6 +4,7 @@ import Link from 'next/link'
import { useEffect, useRef } from 'react'
import { Badge, Button } from 'ui'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import ShimmerLine from '@/components/ui/ShimmerLine'
import {
useInvalidateProjectDetailsQuery,
@@ -89,9 +90,7 @@ const ConnectingState = ({ project }: ConnectingStateProps) => {
<div className="flex items-center justify-center space-x-2">
<Button asChild variant="default">
- <Link href={`/project/${ref}/settings/infrastructure`}>
- Check database health
- </Link>
+ <Link href={getInfrastructurePath(ref)}>Check database health</Link>
</Button>
<Button asChild variant="default" icon={<ExternalLink strokeWidth={1.5} />}>
<Link
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.selfhosted.test.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.selfhosted.test.tsx
index 1b5d40e4037..b4cb5ee9b07 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.selfhosted.test.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.selfhosted.test.tsx
@@ -106,7 +106,6 @@ describe('useGenerateSettingsMenu (self-hosted)', () => {
const { result } = renderHook(() => useGenerateSettingsMenu())
const configGroup = result.current.find((group) => group.title === 'Configuration')
- expect(configGroup?.items.some((item) => item.key === 'compute-and-disk')).toBe(false)
expect(configGroup?.items.some((item) => item.key === 'infrastructure')).toBe(false)
expect(configGroup?.items.some((item) => item.key === 'addons')).toBe(false)
})
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.test.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.test.tsx
index 1c6a6b17f16..1ea61eb5e70 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.test.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.test.tsx
@@ -80,6 +80,26 @@ describe('useGenerateSettingsMenu', () => {
expect(hasMembers).toBe(false)
})
+ it('uses Infrastructure as the canonical compute and disk destination', () => {
+ const { result } = renderHook(() => useGenerateSettingsMenu())
+ const configurationGroup = result.current.find((group) => group.title === 'Configuration')
+
+ expect(configurationGroup?.items).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ key: 'infrastructure',
+ name: 'Infrastructure',
+ url: '/project/project-ref/settings/infrastructure',
+ }),
+ ])
+ )
+ expect(
+ configurationGroup?.items.some(
+ (item) => item.key === 'compute-and-disk' || item.name === 'Compute and Disk'
+ )
+ ).toBe(false)
+ })
+
it('includes dashboard in configuration when flag is enabled', () => {
vi.mocked(useFlag).mockReturnValue(true)
@@ -147,9 +167,6 @@ describe('useGenerateSettingsMenu', () => {
)
expect(shortcutByKey.get('general')).toBe(SHORTCUT_IDS.NAV_PROJECT_SETTINGS_GENERAL)
- expect(shortcutByKey.get('compute-and-disk')).toBe(
- SHORTCUT_IDS.NAV_PROJECT_SETTINGS_COMPUTE_AND_DISK
- )
expect(shortcutByKey.get('infrastructure')).toBe(
SHORTCUT_IDS.NAV_PROJECT_SETTINGS_INFRASTRUCTURE
)
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
index 354a4b603f8..30e693dcf53 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
@@ -2,6 +2,7 @@ import { useFlag, useParams } from 'common'
import { ArrowUpRight } from 'lucide-react'
import { useIsPlatformWebhooksEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
@@ -106,19 +107,10 @@ export const useGenerateSettingsMenu = () => {
items: [],
shortcutId: SHORTCUT_IDS.NAV_PROJECT_SETTINGS_GENERAL,
},
- {
- name: 'Compute and Disk',
- key: 'compute-and-disk',
- url: `/project/${ref}/settings/compute-and-disk`,
- items: [],
- disabled: !isProjectActive,
- isLoading: isPending,
- shortcutId: SHORTCUT_IDS.NAV_PROJECT_SETTINGS_COMPUTE_AND_DISK,
- },
{
name: 'Infrastructure',
key: 'infrastructure',
- url: `/project/${ref}/settings/infrastructure`,
+ url: getInfrastructurePath(ref),
items: [],
disabled: !isProjectActive,
isLoading: isPending,
diff --git a/apps/studio/components/ui/BannerStack/Banners/BannerFreeMicroUpgrade.tsx b/apps/studio/components/ui/BannerStack/Banners/BannerFreeMicroUpgrade.tsx
index 32546af5a27..b1b0aa1e4c8 100644
--- a/apps/studio/components/ui/BannerStack/Banners/BannerFreeMicroUpgrade.tsx
+++ b/apps/studio/components/ui/BannerStack/Banners/BannerFreeMicroUpgrade.tsx
@@ -6,6 +6,7 @@ import { ComputeBadge } from 'ui-patterns/ComputeBadge'
import { BannerCard } from '../BannerCard'
import { BANNER_ID, useBannerStack } from '../BannerStackProvider'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { ChevronsUpAnimated } from '@/components/ui/ComputeBadgeWrapper'
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
import { useTrack } from '@/lib/telemetry/track'
@@ -58,9 +59,7 @@ export const BannerFreeMicroUpgrade = () => {
track('free_micro_upgrade_banner_cta_clicked')
}}
>
- <Link href={`/project/${ref}/settings/compute-and-disk?upgrade=micro`}>
- Upgrade for free
- </Link>
+ <Link href={`${getInfrastructurePath(ref)}?upgrade=micro`}>Upgrade for free</Link>
</Button>
</div>
</div>
diff --git a/apps/studio/components/ui/ComputeBadgeWrapper.tsx b/apps/studio/components/ui/ComputeBadgeWrapper.tsx
index 66218618298..9f8924a3b59 100644
--- a/apps/studio/components/ui/ComputeBadgeWrapper.tsx
+++ b/apps/studio/components/ui/ComputeBadgeWrapper.tsx
@@ -5,6 +5,7 @@ import { ComputeBadge } from 'ui-patterns/ComputeBadge'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { getAvailableComputeOptions } from '@/components/interfaces/DiskManagement/DiskManagement.utils'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { ProjectDetail } from '@/data/projects/project-detail-query'
import { useOrgSubscriptionQuery } from '@/data/subscriptions/org-subscription-query'
import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
@@ -195,9 +196,7 @@ export const ComputeBadgeWrapper = ({
})
}}
>
- <Link href={`/project/${projectRef}/settings/compute-and-disk`}>
- Upgrade compute
- </Link>
+ <Link href={getInfrastructurePath(projectRef)}>Upgrade compute</Link>
</Button>
</div>
</div>
diff --git a/apps/studio/components/ui/DatabaseSelector.tsx b/apps/studio/components/ui/DatabaseSelector.tsx
index 0543f8f87dd..bea0ab15770 100644
--- a/apps/studio/components/ui/DatabaseSelector.tsx
+++ b/apps/studio/components/ui/DatabaseSelector.tsx
@@ -23,6 +23,7 @@ import {
} from 'ui'
import { Markdown } from '@/components/interfaces/Markdown'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { REPLICA_STATUS } from '@/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants'
import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
import { formatDatabaseID, formatDatabaseRegion } from '@/data/read-replicas/replicas.utils'
@@ -177,7 +178,7 @@ export const DatabaseSelector = ({
<TooltipContent side="right" className="w-80">
<Markdown
className="text-xs text-foreground"
- content={`Replica unable to accept requests as its ${status}. [View infrastructure settings](/project/${projectRef}/settings/infrastructure) for more information.`}
+ content={`Replica unable to accept requests as its ${status}. [View infrastructure settings](${getInfrastructurePath(projectRef)}) for more information.`}
/>
</TooltipContent>
</Tooltip>
diff --git a/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx
index 9a2acba857a..9f665a1d0e5 100644
--- a/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx
+++ b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx
@@ -16,7 +16,11 @@ import {
} from 'ui'
import { RESOURCE_WARNING_MESSAGES } from './ResourceExhaustionWarningBanner.constants'
-import { getWarningContent } from './ResourceExhaustionWarningBanner.utils'
+import {
+ getResourceWarningCorrectionUrl,
+ getWarningContent,
+ isComputeUpgradeWarning,
+} from './ResourceExhaustionWarningBanner.utils'
import { mapComputeSizeNameToAddonVariantId } from '@/components/interfaces/DiskManagement/DiskManagement.utils'
import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
import { useResourceWarningsQuery } from '@/data/usage/resource-warnings-query'
@@ -26,13 +30,6 @@ import { useTrack } from '@/lib/telemetry/track'
import { useAiAssistantStateSnapshot } from '@/state/ai-assistant-state'
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
-const COMPUTE_UPGRADE_METRICS = ['disk_io', 'cpu', 'ram']
-const COMPUTE_UPGRADE_WARNING_TYPES = [
- 'disk_io_exhaustion',
- 'cpu_exhaustion',
- 'memory_and_swap_exhaustion',
-]
-
export const ResourceExhaustionWarningBanner = () => {
const { ref } = useParams()
const router = useRouter()
@@ -112,46 +109,18 @@ export const ResourceExhaustionWarningBanner = () => {
: RESOURCE_WARNING_MESSAGES[activeWarnings[0] as keyof typeof RESOURCE_WARNING_MESSAGES]
?.metric
- const correctionUrlVariants = {
- undefined: undefined,
- null: '/project/[ref]/settings/[infra-path]',
- disk_space: '/project/[ref]/settings/compute-and-disk',
- read_only: '/project/[ref]/settings/compute-and-disk',
- disk_io: '/project/[ref]/settings/compute-and-disk',
- cpu: '/project/[ref]/settings/compute-and-disk',
- ram: '/project/[ref]/settings/compute-and-disk',
- auth_email_rate_limit: '/project/[ref]/auth/rate-limits',
- auth_restricted_email_sending: '/project/[ref]/auth/smtp',
- default: (metric: string) => `/project/[ref]/settings/[infra-path]#${metric}`,
- }
-
- const getCorrectionUrl = (metric: string | undefined | null) => {
- const variant = metric === undefined ? 'undefined' : metric === null ? 'null' : metric
- const url =
- correctionUrlVariants[variant as keyof typeof correctionUrlVariants] ||
- correctionUrlVariants.default(metric as string)
- return typeof url === 'function' ? url(metric as string) : url
- }
-
const isFreePlan = organization?.plan?.id === 'free'
// True for a single compute warning, or when all active warnings are compute-related
- const isComputeUpgradeMetric =
- (metric !== null && metric !== undefined && COMPUTE_UPGRADE_METRICS.includes(metric)) ||
- (activeWarnings.length > 1 &&
- activeWarnings.every((w) => COMPUTE_UPGRADE_WARNING_TYPES.includes(w)))
+ const isComputeUpgradeMetric = isComputeUpgradeWarning(metric, activeWarnings)
- const correctionUrl = (() => {
- if (isComputeUpgradeMetric && isFreePlan) {
- return `/org/${organization?.slug ?? '_'}/billing?panel=subscriptionPlan&source=resource_exhaustion_banner`
- }
- if (isComputeUpgradeMetric && activeWarnings.length > 1) {
- return `/project/${ref ?? 'default'}/settings/compute-and-disk`
- }
- return getCorrectionUrl(metric)
- ?.replace('[ref]', ref ?? 'default')
- ?.replace('[infra-path]', 'infrastructure')
- })()
+ const correctionUrl = getResourceWarningCorrectionUrl({
+ metric,
+ activeWarnings,
+ projectRef: ref,
+ isFreePlan,
+ organizationSlug: organization?.slug,
+ })
const buttonText = (() => {
if (isComputeUpgradeMetric) return 'Upgrade compute'
@@ -182,15 +151,15 @@ export const ResourceExhaustionWarningBanner = () => {
warningContent === undefined || (!warningContent?.title && !warningContent?.description)
const isUsageOrInfraPage =
router.pathname.endsWith('/usage') || router.pathname.endsWith('/infrastructure')
- // Compute warnings now link to compute-and-disk, so they should remain visible on infrastructure
+ // Compute warnings now link to infrastructure, so they should remain visible on usage.
const onUsageOrInfraAndNotInReadOnlyMode =
isUsageOrInfraPage &&
!activeWarnings.includes('is_readonly_mode_enabled') &&
!isComputeUpgradeMetric
// Suppress when already on the target page (no-op CTA). Paid-plan compute warnings link to
- // compute-and-disk; free-plan links to billing instead, so we keep the banner visible for them.
- const onDatabaseSettingsAndInReadOnlyMode =
- router.pathname.endsWith('settings/compute-and-disk') &&
+ // infrastructure; free-plan links to billing instead, so we keep the banner visible for them.
+ const shouldSuppressOnInfrastructurePage =
+ router.pathname.endsWith('settings/infrastructure') &&
(activeWarnings.includes('is_readonly_mode_enabled') || (isComputeUpgradeMetric && !isFreePlan))
// these take precedence over each other, so there's only one active warning to check
@@ -217,7 +186,7 @@ export const ResourceExhaustionWarningBanner = () => {
hasNoWarnings ||
hasNoWarningContent ||
onUsageOrInfraAndNotInReadOnlyMode ||
- onDatabaseSettingsAndInReadOnlyMode ||
+ shouldSuppressOnInfrastructurePage ||
!isVisible
) {
return null
diff --git a/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.test.ts b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.test.ts
new file mode 100644
index 00000000000..0f91e4fb947
--- /dev/null
+++ b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.test.ts
@@ -0,0 +1,79 @@
+import { describe, expect, it } from 'vitest'
+
+import {
+ getResourceWarningCorrectionUrl,
+ isComputeUpgradeWarning,
+} from './ResourceExhaustionWarningBanner.utils'
+
+describe('resource warning correction routes', () => {
+ it.each(['cpu', 'ram', 'disk_io'])('sends paid-plan %s warnings to Infrastructure', (metric) => {
+ expect(
+ getResourceWarningCorrectionUrl({
+ metric,
+ activeWarnings: [`${metric}_warning`],
+ projectRef: 'project-ref',
+ isFreePlan: false,
+ organizationSlug: 'org-slug',
+ })
+ ).toBe('/project/project-ref/settings/infrastructure')
+ })
+
+ it('sends free-plan compute warnings to the plan upgrade panel', () => {
+ expect(
+ getResourceWarningCorrectionUrl({
+ metric: 'cpu',
+ activeWarnings: ['cpu_exhaustion'],
+ projectRef: 'project-ref',
+ isFreePlan: true,
+ organizationSlug: 'org-slug',
+ })
+ ).toBe('/org/org-slug/billing?panel=subscriptionPlan&source=resource_exhaustion_banner')
+ })
+
+ it('treats multiple compute-resource warnings as a compute upgrade', () => {
+ const activeWarnings = ['cpu_exhaustion', 'memory_and_swap_exhaustion']
+
+ expect(isComputeUpgradeWarning(null, activeWarnings)).toBe(true)
+ expect(
+ getResourceWarningCorrectionUrl({
+ metric: null,
+ activeWarnings,
+ projectRef: 'project-ref',
+ isFreePlan: false,
+ })
+ ).toBe('/project/project-ref/settings/infrastructure')
+ })
+
+ it.each(['disk_space', 'read_only'])('sends %s warnings to Infrastructure', (metric) => {
+ expect(
+ getResourceWarningCorrectionUrl({
+ metric,
+ activeWarnings: ['disk_space_exhaustion'],
+ projectRef: 'project-ref',
+ isFreePlan: false,
+ })
+ ).toBe('/project/project-ref/settings/infrastructure')
+ })
+
+ it('preserves non-infrastructure correction destinations', () => {
+ expect(
+ getResourceWarningCorrectionUrl({
+ metric: 'auth_email_rate_limit',
+ activeWarnings: ['auth_rate_limit_exhaustion'],
+ projectRef: 'project-ref',
+ isFreePlan: false,
+ })
+ ).toBe('/project/project-ref/auth/rate-limits')
+ })
+
+ it('keeps the fallback metric anchor on Infrastructure', () => {
+ expect(
+ getResourceWarningCorrectionUrl({
+ metric: 'custom_metric',
+ activeWarnings: ['custom_warning'],
+ projectRef: 'project-ref',
+ isFreePlan: false,
+ })
+ ).toBe('/project/project-ref/settings/infrastructure#custom_metric')
+ })
+})
diff --git a/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.ts b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.ts
index 671d61616e3..eee6e258a31 100644
--- a/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.ts
+++ b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.ts
@@ -1,6 +1,14 @@
import { RESOURCE_WARNING_MESSAGES } from './ResourceExhaustionWarningBanner.constants'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import type { ResourceWarning } from '@/data/usage/resource-warnings-query'
+const COMPUTE_UPGRADE_METRICS = ['disk_io', 'cpu', 'ram']
+const COMPUTE_UPGRADE_WARNING_TYPES = [
+ 'disk_io_exhaustion',
+ 'cpu_exhaustion',
+ 'memory_and_swap_exhaustion',
+]
+
export const getWarningContent = (
resourceWarnings: ResourceWarning,
metric: string,
@@ -17,3 +25,52 @@ export const getWarningContent = (
contentType
]?.[severity as 'warning' | 'critical']
}
+
+export const isComputeUpgradeWarning = (
+ metric: string | null | undefined,
+ activeWarnings: string[]
+) =>
+ (metric !== null && metric !== undefined && COMPUTE_UPGRADE_METRICS.includes(metric)) ||
+ (activeWarnings.length > 1 &&
+ activeWarnings.every((warning) => COMPUTE_UPGRADE_WARNING_TYPES.includes(warning)))
+
+export const getResourceWarningCorrectionUrl = ({
+ metric,
+ activeWarnings,
+ projectRef,
+ isFreePlan,
+ organizationSlug,
+}: {
+ metric: string | null | undefined
+ activeWarnings: string[]
+ projectRef?: string
+ isFreePlan: boolean
+ organizationSlug?: string
+}) => {
+ const isComputeUpgradeMetric = isComputeUpgradeWarning(metric, activeWarnings)
+
+ if (isComputeUpgradeMetric && isFreePlan) {
+ return `/org/${organizationSlug ?? '_'}/billing?panel=subscriptionPlan&source=resource_exhaustion_banner`
+ }
+
+ const ref = projectRef ?? 'default'
+ const infrastructurePath = getInfrastructurePath(ref)
+
+ if (isComputeUpgradeMetric && activeWarnings.length > 1) {
+ return infrastructurePath
+ }
+
+ const correctionUrlVariants: Record<string, string | undefined> = {
+ disk_space: infrastructurePath,
+ read_only: infrastructurePath,
+ disk_io: infrastructurePath,
+ cpu: infrastructurePath,
+ ram: infrastructurePath,
+ auth_email_rate_limit: `/project/${ref}/auth/rate-limits`,
+ auth_restricted_email_sending: `/project/${ref}/auth/smtp`,
+ }
+
+ if (metric === undefined) return undefined
+ if (metric === null) return infrastructurePath
+ return correctionUrlVariants[metric] ?? `${infrastructurePath}#${metric}`
+}
diff --git a/apps/studio/components/ui/UpgradePlanButton.tsx b/apps/studio/components/ui/UpgradePlanButton.tsx
index 0b1a2bacc92..2967b1b0d7f 100644
--- a/apps/studio/components/ui/UpgradePlanButton.tsx
+++ b/apps/studio/components/ui/UpgradePlanButton.tsx
@@ -6,6 +6,7 @@ import { Button } from 'ui'
import { ButtonTooltip } from './ButtonTooltip'
import { RequestUpgradeToBillingOwners } from './RequestUpgradeToBillingOwners'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { SupportLink } from '@/components/interfaces/Support/SupportLink'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
@@ -71,7 +72,7 @@ export const UpgradePlanButton = ({
? `/org/${slug ?? '_'}/billing?panel=costControl&source=${source}`
: isOnPaidPlanAndRequestingToPurchaseAddon
? addon === 'computeSize'
- ? `/project/${ref ?? '_'}/settings/compute-and-disk`
+ ? getInfrastructurePath(ref)
: `/project/${ref ?? '_'}/settings/addons?panel=${addon}&source=${source}`
: `/org/${slug ?? '_'}/billing?panel=subscriptionPlan&source=${source}`
diff --git a/apps/studio/pages/project/[ref]/database/settings.tsx b/apps/studio/pages/project/[ref]/database/settings.tsx
index 2a99513ac6f..fda7409aa70 100644
--- a/apps/studio/pages/project/[ref]/database/settings.tsx
+++ b/apps/studio/pages/project/[ref]/database/settings.tsx
@@ -58,7 +58,7 @@ const DatabaseSettings: NextPageWithLayout = () => {
<ConnectionPooling />
<SSLConfiguration />
{showNewDiskManagementUI ? (
- // This form is hidden if Disk and Compute form is enabled, new form is on ./settings/compute-and-disk
+ // This form is hidden if Disk and Compute form is enabled, new form is on ./settings/infrastructure
<DiskManagementPanelForm />
) : (
<DiskSizeConfiguration />
diff --git a/apps/studio/pages/project/[ref]/observability/database.tsx b/apps/studio/pages/project/[ref]/observability/database.tsx
index ebed8ef4feb..980782d0b92 100644
--- a/apps/studio/pages/project/[ref]/observability/database.tsx
+++ b/apps/studio/pages/project/[ref]/observability/database.tsx
@@ -17,6 +17,7 @@ import ReportWidget from '@/components/interfaces/Reports/ReportWidget'
import { ReportChartUpsell } from '@/components/interfaces/Reports/v2/ReportChartUpsell'
import { POOLING_OPTIMIZATIONS } from '@/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.constants'
import DiskSizeConfigurationModal from '@/components/interfaces/Settings/Database/DiskSizeConfigurationModal'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { LogsDatePicker } from '@/components/interfaces/Settings/Logs/Logs.DatePickers'
import UpgradePrompt from '@/components/interfaces/Settings/Logs/UpgradePrompt'
import { DefaultLayout } from '@/components/layouts/DefaultLayout'
@@ -373,9 +374,7 @@ const DatabaseUsage = () => {
<div className="ml-auto">
{project?.cloud_provider === 'AWS' ? (
<Button asChild variant="default">
- <Link href={`/project/${ref}/settings/compute-and-disk`}>
- Increase disk size
- </Link>
+ <Link href={getInfrastructurePath(ref)}>Increase disk size</Link>
</Button>
) : (
<ButtonTooltip
diff --git a/apps/studio/pages/project/[ref]/settings/billing/usage.tsx b/apps/studio/pages/project/[ref]/settings/billing/usage.tsx
index 633e333ebc1..e001a425ad9 100644
--- a/apps/studio/pages/project/[ref]/settings/billing/usage.tsx
+++ b/apps/studio/pages/project/[ref]/settings/billing/usage.tsx
@@ -2,6 +2,7 @@ import { useParams } from 'common'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { DefaultLayout } from '@/components/layouts/DefaultLayout'
import SettingsLayout from '@/components/layouts/ProjectSettingsLayout/SettingsLayout'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
@@ -22,7 +23,7 @@ const ProjectBillingUsage: NextPageWithLayout = () => {
let redirectUrl
if (['cpu', 'ram', 'disk_io'].includes(hash)) {
- redirectUrl = `/project/${ref}/settings/infrastructure#${hash}`
+ redirectUrl = `${getInfrastructurePath(ref)}#${hash}`
} else {
redirectUrl = `/org/${organization.slug}/usage?projectRef=${ref}`
}
diff --git a/apps/studio/pages/project/[ref]/settings/compute-and-disk.tsx b/apps/studio/pages/project/[ref]/settings/compute-and-disk.tsx
deleted file mode 100644
index 34fca6e71da..00000000000
--- a/apps/studio/pages/project/[ref]/settings/compute-and-disk.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import {
- PageHeader,
- PageHeaderDescription,
- PageHeaderMeta,
- PageHeaderSummary,
- PageHeaderTitle,
-} from 'ui-patterns/PageHeader'
-
-import { DiskManagementForm } from '@/components/interfaces/DiskManagement/DiskManagementForm'
-import { DefaultLayout } from '@/components/layouts/DefaultLayout'
-import SettingsLayout from '@/components/layouts/ProjectSettingsLayout/SettingsLayout'
-import type { NextPageWithLayout } from '@/types'
-
-const ComputeAndDiskSettings: NextPageWithLayout = () => {
- return (
- <>
- <PageHeader size="default">
- <PageHeaderMeta>
- <PageHeaderSummary>
- <PageHeaderTitle>Compute and Disk</PageHeaderTitle>
- <PageHeaderDescription>
- Configure the compute and disk settings for your project.
- </PageHeaderDescription>
- </PageHeaderSummary>
- </PageHeaderMeta>
- </PageHeader>
- <DiskManagementForm />
- </>
- )
-}
-
-ComputeAndDiskSettings.getLayout = (page) => (
- <DefaultLayout>
- <SettingsLayout title="Compute and Disk">{page}</SettingsLayout>
- </DefaultLayout>
-)
-export default ComputeAndDiskSettings
diff --git a/apps/studio/pages/project/[ref]/settings/general.tsx b/apps/studio/pages/project/[ref]/settings/general.tsx
index 92bd8b01719..5c4af074c56 100644
--- a/apps/studio/pages/project/[ref]/settings/general.tsx
+++ b/apps/studio/pages/project/[ref]/settings/general.tsx
@@ -15,6 +15,7 @@ import { DeleteBranchPanel } from '@/components/interfaces/Settings/General/Dele
import { DeleteProjectPanel } from '@/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectPanel'
import { General } from '@/components/interfaces/Settings/General/General'
import { Project } from '@/components/interfaces/Settings/General/Project'
+import { ServiceVersionsSection } from '@/components/interfaces/Settings/General/ServiceVersions/ServiceVersionsSection'
import { TransferProjectPanel } from '@/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectPanel'
import { DefaultLayout } from '@/components/layouts/DefaultLayout'
import SettingsLayout from '@/components/layouts/ProjectSettingsLayout/SettingsLayout'
@@ -55,6 +56,7 @@ const ProjectSettings: NextPageWithLayout = () => {
{IS_PLATFORM && (
<>
<Project />
+ <ServiceVersionsSection />
{/* this is only settable on compliance orgs, currently that means HIPAA orgs */}
{!isBranch && hasHipaaAddon && <ComplianceConfig />}
{projectSettingsCustomDomains && <CustomDomainConfig />}
diff --git a/apps/studio/pages/project/[ref]/settings/infrastructure.tsx b/apps/studio/pages/project/[ref]/settings/infrastructure.tsx
index 775a02425b8..4883b228591 100644
--- a/apps/studio/pages/project/[ref]/settings/infrastructure.tsx
+++ b/apps/studio/pages/project/[ref]/settings/infrastructure.tsx
@@ -1,38 +1,37 @@
-import { InfrastructureActivity } from '@/components/interfaces/Settings/Infrastructure/InfrastructureActivity'
-import { InfrastructureInfo } from '@/components/interfaces/Settings/Infrastructure/InfrastructureInfo'
+import {
+ PageHeader,
+ PageHeaderDescription,
+ PageHeaderMeta,
+ PageHeaderSummary,
+ PageHeaderTitle,
+} from 'ui-patterns/PageHeader'
+
+import { DiskManagementForm } from '@/components/interfaces/DiskManagement/DiskManagementForm'
import { DefaultLayout } from '@/components/layouts/DefaultLayout'
import SettingsLayout from '@/components/layouts/ProjectSettingsLayout/SettingsLayout'
-import {
- ScaffoldContainer,
- ScaffoldDescription,
- ScaffoldDivider,
- ScaffoldHeader,
- ScaffoldTitle,
-} from '@/components/layouts/Scaffold'
import type { NextPageWithLayout } from '@/types'
-const ProjectInfrastructure: NextPageWithLayout = () => {
+const InfrastructureSettings: NextPageWithLayout = () => {
return (
<>
- <ScaffoldContainer>
- <ScaffoldHeader>
- <ScaffoldTitle>Infrastructure</ScaffoldTitle>
- <ScaffoldDescription>
- General information regarding your server instance
- </ScaffoldDescription>
- </ScaffoldHeader>
- </ScaffoldContainer>
- <InfrastructureInfo />
- <ScaffoldDivider />
- <InfrastructureActivity />
+ <PageHeader size="default">
+ <PageHeaderMeta>
+ <PageHeaderSummary>
+ <PageHeaderTitle>Infrastructure</PageHeaderTitle>
+ <PageHeaderDescription>
+ View and configure compute and disk for your project.
+ </PageHeaderDescription>
+ </PageHeaderSummary>
+ </PageHeaderMeta>
+ </PageHeader>
+ <DiskManagementForm />
</>
)
}
-ProjectInfrastructure.getLayout = (page) => (
+InfrastructureSettings.getLayout = (page) => (
<DefaultLayout>
<SettingsLayout title="Infrastructure">{page}</SettingsLayout>
</DefaultLayout>
)
-
-export default ProjectInfrastructure
+export default InfrastructureSettings
diff --git a/apps/studio/redirects.shared.test.ts b/apps/studio/redirects.shared.test.ts
index 6136ae80955..1aa495d6e0e 100644
--- a/apps/studio/redirects.shared.test.ts
+++ b/apps/studio/redirects.shared.test.ts
@@ -52,6 +52,33 @@ describe('preserveQueryAndHash', () => {
})
describe('matchRedirect query/hash preservation', () => {
+ it('redirects the legacy compute and disk route while preserving query and hash', () => {
+ expect(
+ matchRedirect({
+ pathname: '/project/abc/settings/compute-and-disk',
+ search: { upgrade: 'micro' },
+ isPlatform: true,
+ hash: 'disk',
+ })
+ ).toEqual({
+ destination: '/project/abc/settings/infrastructure?upgrade=micro#disk',
+ permanent: true,
+ })
+ })
+
+ it('redirects the legacy compute billing panel to the CPU section', () => {
+ expect(
+ matchRedirect({
+ pathname: '/project/abc/settings/billing/subscription',
+ search: { panel: 'computeInstance', source: 'banner' },
+ isPlatform: true,
+ })
+ ).toEqual({
+ destination: '/project/abc/settings/infrastructure?source=banner#cpu',
+ permanent: true,
+ })
+ })
+
it('carries the incoming query and hash through a plain rule', () => {
expect(
matchRedirect({
diff --git a/apps/studio/redirects.shared.ts b/apps/studio/redirects.shared.ts
index 4963473bae7..845f11cb68a 100644
--- a/apps/studio/redirects.shared.ts
+++ b/apps/studio/redirects.shared.ts
@@ -114,6 +114,11 @@ export const SHARED_REDIRECTS: StudioRedirect[] = [
destination: '/org/_/billing?panel=subscriptionPlan',
permanent: true,
},
+ {
+ source: '/project/:ref/settings/compute-and-disk',
+ destination: '/project/:ref/settings/infrastructure',
+ permanent: true,
+ },
{
source: '/project/:ref/settings/billing/subscription',
has: [{ type: 'query', key: 'panel', value: 'pitr' }],
@@ -123,7 +128,7 @@ export const SHARED_REDIRECTS: StudioRedirect[] = [
{
source: '/project/:ref/settings/billing/subscription',
has: [{ type: 'query', key: 'panel', value: 'computeInstance' }],
- destination: '/project/:ref/settings/compute-and-disk',
+ destination: '/project/:ref/settings/infrastructure#cpu',
permanent: true,
},
{
diff --git a/apps/studio/routeTree.gen.ts b/apps/studio/routeTree.gen.ts
index 8f8e52c4d4d..3e6b5c721d8 100644
--- a/apps/studio/routeTree.gen.ts
+++ b/apps/studio/routeTree.gen.ts
@@ -104,7 +104,6 @@ import { Route as ProjectRefSettingsIntegrationsRouteImport } from './routes/pro
import { Route as ProjectRefSettingsInfrastructureRouteImport } from './routes/project/$ref/settings/infrastructure'
import { Route as ProjectRefSettingsGeneralRouteImport } from './routes/project/$ref/settings/general'
import { Route as ProjectRefSettingsDashboardRouteImport } from './routes/project/$ref/settings/dashboard'
-import { Route as ProjectRefSettingsComputeAndDiskRouteImport } from './routes/project/$ref/settings/compute-and-disk'
import { Route as ProjectRefSettingsApiKeysRouteImport } from './routes/project/$ref/settings/api-keys'
import { Route as ProjectRefSettingsApiRouteImport } from './routes/project/$ref/settings/api'
import { Route as ProjectRefSettingsAddonsRouteImport } from './routes/project/$ref/settings/addons'
@@ -808,12 +807,6 @@ const ProjectRefSettingsDashboardRoute =
path: '/dashboard',
getParentRoute: () => ProjectRefSettingsRoute,
} as any)
-const ProjectRefSettingsComputeAndDiskRoute =
- ProjectRefSettingsComputeAndDiskRouteImport.update({
- id: '/compute-and-disk',
- path: '/compute-and-disk',
- getParentRoute: () => ProjectRefSettingsRoute,
- } as any)
const ProjectRefSettingsApiKeysRoute =
ProjectRefSettingsApiKeysRouteImport.update({
id: '/api-keys',
@@ -2199,7 +2192,6 @@ export interface FileRoutesByFullPath {
'/project/$ref/settings/addons': typeof ProjectRefSettingsAddonsRoute
'/project/$ref/settings/api': typeof ProjectRefSettingsApiRoute
'/project/$ref/settings/api-keys': typeof ProjectRefSettingsApiKeysRouteWithChildren
- '/project/$ref/settings/compute-and-disk': typeof ProjectRefSettingsComputeAndDiskRoute
'/project/$ref/settings/dashboard': typeof ProjectRefSettingsDashboardRoute
'/project/$ref/settings/general': typeof ProjectRefSettingsGeneralRoute
'/project/$ref/settings/infrastructure': typeof ProjectRefSettingsInfrastructureRoute
@@ -2494,7 +2486,6 @@ export interface FileRoutesByTo {
'/project/$ref/realtime/settings': typeof ProjectRefRealtimeSettingsRoute
'/project/$ref/settings/addons': typeof ProjectRefSettingsAddonsRoute
'/project/$ref/settings/api': typeof ProjectRefSettingsApiRoute
- '/project/$ref/settings/compute-and-disk': typeof ProjectRefSettingsComputeAndDiskRoute
'/project/$ref/settings/dashboard': typeof ProjectRefSettingsDashboardRoute
'/project/$ref/settings/general': typeof ProjectRefSettingsGeneralRoute
'/project/$ref/settings/infrastructure': typeof ProjectRefSettingsInfrastructureRoute
@@ -2804,7 +2795,6 @@ export interface FileRoutesById {
'/project/$ref/settings/addons': typeof ProjectRefSettingsAddonsRoute
'/project/$ref/settings/api': typeof ProjectRefSettingsApiRoute
'/project/$ref/settings/api-keys': typeof ProjectRefSettingsApiKeysRouteWithChildren
- '/project/$ref/settings/compute-and-disk': typeof ProjectRefSettingsComputeAndDiskRoute
'/project/$ref/settings/dashboard': typeof ProjectRefSettingsDashboardRoute
'/project/$ref/settings/general': typeof ProjectRefSettingsGeneralRoute
'/project/$ref/settings/infrastructure': typeof ProjectRefSettingsInfrastructureRoute
@@ -3113,7 +3103,6 @@ export interface FileRouteTypes {
| '/project/$ref/settings/addons'
| '/project/$ref/settings/api'
| '/project/$ref/settings/api-keys'
- | '/project/$ref/settings/compute-and-disk'
| '/project/$ref/settings/dashboard'
| '/project/$ref/settings/general'
| '/project/$ref/settings/infrastructure'
@@ -3408,7 +3397,6 @@ export interface FileRouteTypes {
| '/project/$ref/realtime/settings'
| '/project/$ref/settings/addons'
| '/project/$ref/settings/api'
- | '/project/$ref/settings/compute-and-disk'
| '/project/$ref/settings/dashboard'
| '/project/$ref/settings/general'
| '/project/$ref/settings/infrastructure'
@@ -3717,7 +3705,6 @@ export interface FileRouteTypes {
| '/project/$ref/settings/addons'
| '/project/$ref/settings/api'
| '/project/$ref/settings/api-keys'
- | '/project/$ref/settings/compute-and-disk'
| '/project/$ref/settings/dashboard'
| '/project/$ref/settings/general'
| '/project/$ref/settings/infrastructure'
@@ -4650,13 +4637,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ProjectRefSettingsDashboardRouteImport
parentRoute: typeof ProjectRefSettingsRoute
}
- '/project/$ref/settings/compute-and-disk': {
- id: '/project/$ref/settings/compute-and-disk'
- path: '/compute-and-disk'
- fullPath: '/project/$ref/settings/compute-and-disk'
- preLoaderRoute: typeof ProjectRefSettingsComputeAndDiskRouteImport
- parentRoute: typeof ProjectRefSettingsRoute
- }
'/project/$ref/settings/api-keys': {
id: '/project/$ref/settings/api-keys'
path: '/api-keys'
@@ -6650,7 +6630,6 @@ interface ProjectRefSettingsRouteChildren {
ProjectRefSettingsAddonsRoute: typeof ProjectRefSettingsAddonsRoute
ProjectRefSettingsApiRoute: typeof ProjectRefSettingsApiRoute
ProjectRefSettingsApiKeysRoute: typeof ProjectRefSettingsApiKeysRouteWithChildren
- ProjectRefSettingsComputeAndDiskRoute: typeof ProjectRefSettingsComputeAndDiskRoute
ProjectRefSettingsDashboardRoute: typeof ProjectRefSettingsDashboardRoute
ProjectRefSettingsGeneralRoute: typeof ProjectRefSettingsGeneralRoute
ProjectRefSettingsInfrastructureRoute: typeof ProjectRefSettingsInfrastructureRoute
@@ -6667,7 +6646,6 @@ const ProjectRefSettingsRouteChildren: ProjectRefSettingsRouteChildren = {
ProjectRefSettingsAddonsRoute: ProjectRefSettingsAddonsRoute,
ProjectRefSettingsApiRoute: ProjectRefSettingsApiRoute,
ProjectRefSettingsApiKeysRoute: ProjectRefSettingsApiKeysRouteWithChildren,
- ProjectRefSettingsComputeAndDiskRoute: ProjectRefSettingsComputeAndDiskRoute,
ProjectRefSettingsDashboardRoute: ProjectRefSettingsDashboardRoute,
ProjectRefSettingsGeneralRoute: ProjectRefSettingsGeneralRoute,
ProjectRefSettingsInfrastructureRoute: ProjectRefSettingsInfrastructureRoute,
diff --git a/apps/studio/routes/project/$ref/settings/compute-and-disk.tsx b/apps/studio/routes/project/$ref/settings/compute-and-disk.tsx
deleted file mode 100644
index d52452e83d8..00000000000
--- a/apps/studio/routes/project/$ref/settings/compute-and-disk.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { createFileRoute } from '@tanstack/react-router'
-
-import ComputeAndDiskPage from '@/pages/project/[ref]/settings/compute-and-disk'
-
-export const Route = createFileRoute('/project/$ref/settings/compute-and-disk')({
- component: SettingsComputeAndDiskRoute,
- staticData: { settingsLayoutTitle: 'Compute and Disk' },
-})
-
-function SettingsComputeAndDiskRoute() {
- return <ComputeAndDiskPage dehydratedState={undefined} />
-}
diff --git a/apps/studio/state/shortcuts/registry/project-settings-nav.ts b/apps/studio/state/shortcuts/registry/project-settings-nav.ts
index eb941ed35e1..eeefb857bfa 100644
--- a/apps/studio/state/shortcuts/registry/project-settings-nav.ts
+++ b/apps/studio/state/shortcuts/registry/project-settings-nav.ts
@@ -10,7 +10,6 @@ import { RegistryDefinations } from '../types'
*/
export const PROJECT_SETTINGS_NAV_SHORTCUT_IDS = {
NAV_PROJECT_SETTINGS_GENERAL: 'nav.project-settings-general',
- NAV_PROJECT_SETTINGS_COMPUTE_AND_DISK: 'nav.project-settings-compute-and-disk',
NAV_PROJECT_SETTINGS_INFRASTRUCTURE: 'nav.project-settings-infrastructure',
NAV_PROJECT_SETTINGS_INTEGRATIONS: 'nav.project-settings-integrations',
NAV_PROJECT_SETTINGS_WEBHOOKS: 'nav.project-settings-webhooks',
@@ -32,13 +31,6 @@ export const projectSettingsNavRegistry: RegistryDefinations<ProjectSettingsNavS
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_PROJECT_SETTINGS,
},
- [PROJECT_SETTINGS_NAV_SHORTCUT_IDS.NAV_PROJECT_SETTINGS_COMPUTE_AND_DISK]: {
- id: PROJECT_SETTINGS_NAV_SHORTCUT_IDS.NAV_PROJECT_SETTINGS_COMPUTE_AND_DISK,
- label: 'Go to Compute and Disk',
- sequence: ['S', 'C'],
- showInSettings: false,
- referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_PROJECT_SETTINGS,
- },
[PROJECT_SETTINGS_NAV_SHORTCUT_IDS.NAV_PROJECT_SETTINGS_INFRASTRUCTURE]: {
id: PROJECT_SETTINGS_NAV_SHORTCUT_IDS.NAV_PROJECT_SETTINGS_INFRASTRUCTURE,
label: 'Go to Infrastructure',
diff --git a/apps/studio/tests/pages/project/[ref]/settings/infrastructure.test.tsx b/apps/studio/tests/pages/project/[ref]/settings/infrastructure.test.tsx
new file mode 100644
index 00000000000..4db3ac56f8c
--- /dev/null
+++ b/apps/studio/tests/pages/project/[ref]/settings/infrastructure.test.tsx
@@ -0,0 +1,437 @@
+import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { screen, waitFor, within } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { platformComponents as components } from 'api-types'
+import { HttpResponse } from 'msw'
+import type { ReactNode } from 'react'
+import { beforeEach, describe, expect, test, vi } from 'vitest'
+
+import type { ProfileContextType } from '@/lib/profile'
+import InfrastructurePage from '@/pages/project/[ref]/settings/infrastructure'
+import { createMockOrganizationResponse } from '@/tests/helpers'
+import { customRender } from '@/tests/lib/custom-render'
+import { addAPIMock } from '@/tests/lib/msw'
+
+type ProjectDetailResponse = components['schemas']['ProjectDetailResponse']
+type ProjectAddonsResponse = components['schemas']['ProjectAddonsResponse']
+type PermissionResponse = components['schemas']['AccessControlPermission']
+
+const PROJECT_REF = 'project-ref'
+const ORGANIZATION_SLUG = 'acme'
+
+const PROFILE_CONTEXT: ProfileContextType = {
+ profile: {
+ id: 1,
+ auth0_id: 'auth0|test',
+ gotrue_id: 'gotrue-test',
+ username: 'testuser',
+ primary_email: '[email protected]',
+ first_name: null,
+ last_name: null,
+ mobile: null,
+ is_alpha_user: false,
+ is_sso_user: false,
+ disabled_features: [],
+ free_project_limit: null,
+ },
+ error: null,
+ isLoading: false,
+ isError: false,
+ isSuccess: true,
+}
+
+const PROJECT: ProjectDetailResponse = {
+ cloud_provider: 'AWS',
+ connectionString: 'postgresql://postgres:[email protected]:5432/postgres',
+ db_host: 'db.project-ref.supabase.co',
+ high_availability: false,
+ id: 1,
+ infra_compute_size: 'micro',
+ inserted_at: '2026-01-01T00:00:00.000Z',
+ integration_source: null,
+ is_branch_enabled: false,
+ is_physical_backups_enabled: false,
+ name: 'Production',
+ organization_id: 1,
+ ref: PROJECT_REF,
+ region: 'us-east-1',
+ restUrl: `https://${PROJECT_REF}.supabase.co`,
+ status: 'ACTIVE_HEALTHY',
+ subscription_id: 'subscription-1',
+ updated_at: '2026-01-01T00:00:00.000Z',
+}
+
+const COMPUTE_VARIANTS: ProjectAddonsResponse['available_addons'][number]['variants'] = [
+ {
+ identifier: 'ci_micro',
+ name: 'Micro',
+ price: 0.01344,
+ price_description: '$0.01344/hour (~$10/month)',
+ price_interval: 'hourly',
+ price_type: 'usage',
+ meta: { cpu_cores: 2, memory_gb: 1 },
+ },
+ {
+ identifier: 'ci_small',
+ name: 'Small',
+ price: 0.0206,
+ price_description: '$0.0206/hour (~$15/month)',
+ price_interval: 'hourly',
+ price_type: 'usage',
+ meta: { cpu_cores: 2, memory_gb: 2 },
+ },
+ {
+ identifier: 'ci_large',
+ name: 'Large',
+ price: 0.1517,
+ price_description: '$0.1517/hour (~$110/month)',
+ price_interval: 'hourly',
+ price_type: 'usage',
+ meta: { cpu_cores: 2, memory_gb: 8 },
+ },
+]
+
+vi.mock('common', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('common')>()
+ return {
+ ...actual,
+ IS_PLATFORM: true,
+ useIsLoggedIn: () => true,
+ useParams: () => ({ ref: PROJECT_REF }),
+ }
+})
+
+vi.mock('@/lib/constants', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('@/lib/constants')>()
+ return {
+ ...actual,
+ IS_PLATFORM: true,
+ }
+})
+
+vi.mock('ui-patterns/Admonition', () => ({
+ Admonition: ({
+ children,
+ description,
+ title,
+ }: {
+ children?: ReactNode
+ description?: ReactNode
+ title?: ReactNode
+ }) => (
+ <div>
+ {title}
+ {description}
+ {children}
+ </div>
+ ),
+}))
+
+vi.mock('ui-patterns/Chart', () => ({
+ Chart: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ ChartCard: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ ChartContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ ChartEmptyState: ({ title }: { title: ReactNode }) => <div>{title}</div>,
+ ChartHeader: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ ChartLine: () => <div data-testid="usage-chart" />,
+ ChartLoadingState: () => <div>Loading chart</div>,
+ ChartMetric: ({ label, value }: { label: ReactNode; value: ReactNode }) => (
+ <div data-testid={`metric-${label}`}>
+ {label}: {value}
+ </div>
+ ),
+}))
+
+function mockInfrastructureEndpoints() {
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref',
+ response: PROJECT,
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/organizations',
+ response: [
+ createMockOrganizationResponse({
+ id: 1,
+ slug: ORGANIZATION_SLUG,
+ plan: { id: 'pro', name: 'Pro' },
+ usage_billing_enabled: true,
+ }),
+ ],
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/organizations/:slug/entitlements',
+ response: {
+ entitlements: [
+ {
+ config: { enabled: true },
+ feature: {
+ key: 'instances.compute_update_available_sizes',
+ type: 'boolean',
+ },
+ hasAccess: true,
+ type: 'boolean',
+ },
+ ],
+ },
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/profile/permissions',
+ response: [
+ {
+ actions: [PermissionAction.UPDATE],
+ condition: null,
+ organization_id: 1,
+ organization_slug: ORGANIZATION_SLUG,
+ project_ids: [PROJECT.id],
+ project_refs: [PROJECT_REF],
+ resources: ['projects'],
+ restrictive: false,
+ } satisfies PermissionResponse,
+ ],
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects-resource-warnings',
+ response: [],
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref/databases',
+ response: [
+ {
+ cloud_provider: 'AWS',
+ connection_string_read_only: PROJECT.connectionString,
+ connectionString: PROJECT.connectionString,
+ db_host: PROJECT.db_host,
+ db_name: 'postgres',
+ db_port: 5432,
+ db_user: 'postgres',
+ identifier: PROJECT_REF,
+ inserted_at: PROJECT.inserted_at,
+ region: PROJECT.region,
+ restUrl: PROJECT.restUrl,
+ size: 't4g.small',
+ status: 'ACTIVE_HEALTHY',
+ },
+ ],
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref/disk',
+ response: {
+ attributes: {
+ iops: 3000,
+ size_gb: 100,
+ throughput_mbps: 125,
+ throughput_mibps: 125,
+ type: 'gp3',
+ },
+ },
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref/disk/util',
+ response: {
+ metrics: {
+ fs_avail_bytes: 60 * 1024 * 1024 * 1024,
+ fs_size_bytes: 100 * 1024 * 1024 * 1024,
+ fs_used_bytes: 40 * 1024 * 1024 * 1024,
+ },
+ timestamp: '2026-07-20T00:00:00.000Z',
+ },
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref/disk/custom-config',
+ response: {
+ growth_percent: 20,
+ max_size_gb: 1000,
+ min_increment_gb: 10,
+ },
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref/billing/addons',
+ response: {
+ available_addons: [
+ {
+ name: 'Compute Instance',
+ type: 'compute_instance',
+ variants: COMPUTE_VARIANTS,
+ },
+ ],
+ ref: PROJECT_REF,
+ selected_addons: [
+ {
+ type: 'compute_instance',
+ variant: COMPUTE_VARIANTS[0],
+ },
+ ],
+ },
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref/infra-monitoring',
+ response: () =>
+ HttpResponse.json({
+ series: {},
+ data: [
+ {
+ period_start: '2026-07-20T00:00:00.000Z',
+ values: {
+ max_cpu_usage: '40',
+ ram_usage: '50',
+ disk_io_consumption: '60',
+ pg_database_size: String(40 * 1024 * 1024 * 1024),
+ disk_fs_used_wal: String(5 * 1024 * 1024 * 1024),
+ disk_fs_used_system: String(5 * 1024 * 1024 * 1024),
+ disk_fs_size: String(100 * 1024 * 1024 * 1024),
+ },
+ },
+ ],
+ }),
+ })
+}
+
+function renderInfrastructurePage() {
+ return customRender(<InfrastructurePage dehydratedState={{}} />, {
+ profileContext: PROFILE_CONTEXT,
+ })
+}
+
+describe('/project/[ref]/settings/infrastructure', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ mockInfrastructureEndpoints()
+ window.HTMLElement.prototype.scrollIntoView = vi.fn()
+ })
+
+ test('loads the complete infrastructure page through MSW and resets an interaction', async () => {
+ const user = userEvent.setup()
+ renderInfrastructurePage()
+
+ expect(screen.getByRole('heading', { name: 'Infrastructure', level: 1 })).toBeInTheDocument()
+ expect(screen.getByText('Scaling')).toBeInTheDocument()
+ expect(screen.getByText('Compute size')).toBeInTheDocument()
+ expect(screen.getByRole('heading', { name: 'Disk', level: 2 })).toBeInTheDocument()
+ // The Advanced section renders only once the project query resolves (isAws)
+ expect(await screen.findByText('Advanced')).toBeInTheDocument()
+
+ const diskSize = await screen.findByRole('spinbutton', { name: 'Disk size' })
+ await waitFor(() => expect(diskSize).toHaveValue(100))
+ expect(screen.getByRole('spinbutton', { name: 'IOPS' })).toHaveValue(3000)
+ expect(screen.getByRole('spinbutton', { name: 'Throughput' })).toHaveValue(125)
+ expect(screen.getByTestId('metric-CPU')).toHaveTextContent('40%')
+ expect(screen.getByTestId('metric-Memory')).toHaveTextContent('50%')
+ expect(screen.getByTestId('metric-Disk')).toHaveTextContent('50%')
+
+ await user.click(screen.getByText('Small'))
+ expect(screen.getByRole('button', { name: 'Review changes' })).toBeEnabled()
+
+ await user.click(screen.getByRole('button', { name: 'Cancel' }))
+ await waitFor(() => {
+ expect(screen.queryByRole('button', { name: 'Review changes' })).not.toBeInTheDocument()
+ })
+ })
+
+ test('reviews and confirms a compute resize through the add-on API', async () => {
+ const user = userEvent.setup()
+ let addonRequest: unknown
+
+ addAPIMock({
+ method: 'post',
+ path: '/platform/projects/:ref/billing/addons',
+ response: async ({ request }) => {
+ addonRequest = await request.json()
+ return new HttpResponse(null, { status: 201 })
+ },
+ })
+
+ renderInfrastructurePage()
+
+ await user.click(await screen.findByText('Small'))
+ await user.click(screen.getByRole('button', { name: 'Review changes' }))
+
+ const dialog = await screen.findByRole('dialog')
+ expect(within(dialog).getByText('Compute size')).toBeInTheDocument()
+ expect(within(dialog).getByText('Micro')).toBeInTheDocument()
+ expect(within(dialog).getByText('Small')).toBeInTheDocument()
+
+ await user.click(within(dialog).getByRole('button', { name: 'Confirm changes' }))
+
+ await waitFor(() => {
+ expect(addonRequest).toEqual({
+ addon_type: 'compute_instance',
+ addon_variant: 'ci_small',
+ })
+ })
+ })
+
+ test('submits disk and autoscaling changes to both infrastructure APIs', async () => {
+ const user = userEvent.setup()
+ let diskRequest: unknown
+ let autoscaleRequest: unknown
+
+ addAPIMock({
+ method: 'post',
+ path: '/platform/projects/:ref/disk',
+ response: async ({ request }) => {
+ diskRequest = await request.json()
+ return new HttpResponse(null, { status: 201 })
+ },
+ })
+ addAPIMock({
+ method: 'post',
+ path: '/platform/projects/:ref/disk/custom-config',
+ response: async ({ request }) => {
+ autoscaleRequest = await request.json()
+ return HttpResponse.json(
+ {
+ growth_percent: 20,
+ max_size_gb: 1200,
+ min_increment_gb: 10,
+ },
+ { status: 201 }
+ )
+ },
+ })
+
+ renderInfrastructurePage()
+
+ const diskSize = await screen.findByRole('spinbutton', { name: 'Disk size' })
+ await waitFor(() => expect(diskSize).toHaveValue(100))
+ await user.clear(diskSize)
+ await user.type(diskSize, '120')
+
+ const maxDiskSize = screen.getByRole('spinbutton', { name: 'Maximum disk size' })
+ await user.clear(maxDiskSize)
+ await user.type(maxDiskSize, '1200')
+
+ await user.click(screen.getByRole('button', { name: 'Review changes' }))
+ const dialog = await screen.findByRole('dialog')
+ expect(within(dialog).getByText('Disk size')).toBeInTheDocument()
+ expect(within(dialog).getByText('Max disk size')).toBeInTheDocument()
+
+ await user.click(within(dialog).getByRole('button', { name: 'Confirm changes' }))
+
+ await waitFor(() => {
+ expect(diskRequest).toEqual({
+ attributes: {
+ iops: 3000,
+ size_gb: 120,
+ throughput_mbps: 125,
+ type: 'gp3',
+ },
+ })
+ expect(autoscaleRequest).toEqual({
+ growth_percent: 20,
+ max_size_gb: 1200,
+ min_increment_gb: 10,
+ })
+ })
+ })
+})