Skip to content

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

fix: make high availability in project creation form public (#48338)

Bobbie Soedirgo60e6a89f9ddf
diff --git a/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx b/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx
index 5e24360fa55..fce289df274 100644
--- a/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx
+++ b/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx
@@ -3,6 +3,7 @@ import { FormControl, FormField, Switch } from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { CreateProjectForm } from './ProjectCreation.schema'
+import Panel from '@/components/ui/Panel'
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
interface HighAvailabilityInputProps {
@@ -15,20 +16,22 @@ export const HighAvailabilityInput = ({ form }: HighAvailabilityInputProps) => {
if (!hasAccess) return null
return (
- <FormField
- control={form.control}
- name="highAvailability"
- render={({ field }) => (
- <FormItemLayout
- label="High Availability"
- description="Horizontally scalable Postgres for highly available, globally distributed deployments while staying true to standard Postgres."
- layout="horizontal"
- >
- <FormControl>
- <Switch checked={field.value} onCheckedChange={field.onChange} />
- </FormControl>
- </FormItemLayout>
- )}
- />
+ <Panel.Content>
+ <FormField
+ control={form.control}
+ name="highAvailability"
+ render={({ field }) => (
+ <FormItemLayout
+ label="High availability"
+ description="Horizontally scalable Postgres for highly available, globally distributed deployments while staying true to standard Postgres."
+ layout="horizontal"
+ >
+ <FormControl>
+ <Switch checked={field.value} onCheckedChange={field.onChange} />
+ </FormControl>
+ </FormItemLayout>
+ )}
+ />
+ </Panel.Content>
)
}
diff --git a/apps/studio/components/interfaces/ProjectCreation/InternalOnlyConfiguration.tsx b/apps/studio/components/interfaces/ProjectCreation/InternalOnlyConfiguration.tsx
index 12858f3df5f..e1c62c30d4d 100644
--- a/apps/studio/components/interfaces/ProjectCreation/InternalOnlyConfiguration.tsx
+++ b/apps/studio/components/interfaces/ProjectCreation/InternalOnlyConfiguration.tsx
@@ -6,7 +6,6 @@ import { CollapsibleCardSection } from 'ui-patterns/CollapsibleCardSection'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { CloudProviderSelector } from './CloudProviderSelector'
-import { HighAvailabilityInput } from './HighAvailabilityInput'
import { PostgresVersionSelector } from './PostgresVersionSelector'
import { CreateProjectForm } from './ProjectCreation.schema'
import Panel from '@/components/ui/Panel'
@@ -40,8 +39,6 @@ export const InternalOnlyConfiguration = ({ form }: InternalOnlyConfigurationPro
/>
)}
/>
-
- <HighAvailabilityInput form={form} />
</div>
{showNonProdFields && (
diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx
index 459f1666d53..49e4ab3ecc3 100644
--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx
+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx
@@ -19,6 +19,7 @@ import { DatabasePasswordInput } from './DatabasePasswordInput'
import { DataSeeding } from './DataSeeding'
import { DisabledWarningDueToIncident } from './DisabledWarningDueToIncident'
import { FreeProjectLimitWarning } from './FreeProjectLimitWarning'
+import { HighAvailabilityInput } from './HighAvailabilityInput'
import { InternalOnlyConfiguration } from './InternalOnlyConfiguration'
import { OrganizationSelector } from './OrganizationSelector'
import { extractPostgresVersionDetails } from './PostgresVersionSelector'
@@ -658,6 +659,8 @@ export const ProjectCreationForm = ({
{canChooseInstanceSize && <ComputeSizeSelector form={form} />}
+ <HighAvailabilityInput form={form} />
+
<DatabasePasswordInput form={form} />
<RegionSelector
diff --git a/apps/studio/tests/pages/new/[slug].test.tsx b/apps/studio/tests/pages/new/[slug].test.tsx
index 3c77f3cfc76..7579b282bb2 100644
--- a/apps/studio/tests/pages/new/[slug].test.tsx
+++ b/apps/studio/tests/pages/new/[slug].test.tsx
@@ -525,12 +525,12 @@ describe('project creation wizard', () => {
const onRequest = vi.fn()
mockCreateProject(onRequest)
- await renderWizard({ flags: { newProjectInternalOnlyConfiguration: true } })
+ await renderWizard()
await fillProjectName('HA Oriole Project')
await selectRegion(/Americas/)
- fireEvent.click(await screen.findByRole('button', { name: 'Internal-only Configuration' }))
+ // The high availability toggle is now a top-level field, gated only by the entitlement.
await user.click(await screen.findByRole('switch'))
fireEvent.click(await screen.findByRole('button', { name: 'Advanced Configuration' }))
@@ -592,6 +592,58 @@ describe('project creation wizard', () => {
})
})
+ describe('high availability', () => {
+ test('shows the high availability toggle from the entitlement, without the internal-only flag', async () => {
+ mockWizardEndpoints()
+
+ await renderWizard()
+
+ expect(await screen.findByText('High availability')).toBeInTheDocument()
+ // The toggle must not depend on the internal-only configuration section.
+ expect(
+ screen.queryByRole('button', { name: 'Internal-only Configuration' })
+ ).not.toBeInTheDocument()
+ })
+
+ test('hides the high availability toggle when the org lacks the entitlement', async () => {
+ mockWizardEndpoints({
+ entitlements: [
+ {
+ feature: { key: 'instances.high_availability', type: 'boolean' },
+ hasAccess: false,
+ type: 'boolean',
+ config: { enabled: false },
+ } as Entitlement,
+ ],
+ })
+
+ await renderWizard()
+
+ await screen.findByPlaceholderText('Project name')
+ expect(screen.queryByText('High availability')).not.toBeInTheDocument()
+ })
+
+ test('enabling high availability submits the flag and forces the AWS_K8S cloud provider', async () => {
+ mockWizardEndpoints()
+ const onRequest = vi.fn()
+ mockCreateProject(onRequest)
+
+ await renderWizard()
+
+ await fillProjectName('HA Project')
+ await generateAndWaitForStrongPassword()
+ await user.click(await screen.findByRole('switch'))
+ await selectRegion(/Americas/)
+
+ fireEvent.click(screen.getByRole('button', { name: 'Create new project' }))
+
+ await waitFor(() => expect(onRequest).toHaveBeenCalled())
+ const body = onRequest.mock.calls[0][0]
+ expect(body.high_availability).toBe(true)
+ expect(body.cloud_provider).toBe('AWS_K8S')
+ })
+ })
+
describe('security options', () => {
test('disabling the Data API sends an empty exposed-schemas list', async () => {
mockWizardEndpoints()