Skip to content

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

Fix version selector if only one result returned, and default to first result if no GA version found (#34815)

Joshen Limf8265f1b42af
diff --git a/apps/studio/components/interfaces/ProjectCreation/PostgresVersionSelector.tsx b/apps/studio/components/interfaces/ProjectCreation/PostgresVersionSelector.tsx
index aa9cb4c67f7..dd5bb1a399c 100644
--- a/apps/studio/components/interfaces/ProjectCreation/PostgresVersionSelector.tsx
+++ b/apps/studio/components/interfaces/ProjectCreation/PostgresVersionSelector.tsx
@@ -68,19 +68,22 @@ export const PostgresVersionSelector = ({
const availableVersions = (data?.available_versions ?? []).sort((a, b) =>
a.version.localeCompare(b.version)
)
+ const { postgresVersionSelection } = form.watch()
useEffect(() => {
- const gaVersion = availableVersions.find((x) => x.release_channel === 'ga')
- const defaultValue = gaVersion ? formatValue(gaVersion) : undefined
- form.setValue('postgresVersionSelection', defaultValue)
+ if (availableVersions.length > 0) {
+ const gaVersion = availableVersions.find((x) => x.release_channel === 'ga')
+ const defaultValue = gaVersion ? formatValue(gaVersion) : formatValue(availableVersions[0])
+ form.setValue('postgresVersionSelection', defaultValue)
+ }
}, [isSuccess, form])
return (
<FormItemLayout label="Postgres Version" layout={layout}>
<Select_Shadcn_
- value={field.value}
+ value={postgresVersionSelection}
onValueChange={field.onChange}
- disabled={availableVersions.length <= 1 || isLoadingProjectVersions}
+ disabled={availableVersions.length === 0 || isLoadingProjectVersions}
>
<SelectTrigger_Shadcn_ className="[&>:nth-child(1)]:w-full [&>:nth-child(1)]:flex [&>:nth-child(1)]:items-start">
<SelectValue_Shadcn_ placeholder="Select a Postgres version for your project" />
diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsx
index 0ca6b3667fa..9872032be75 100644
--- a/apps/studio/pages/new/[slug].tsx
+++ b/apps/studio/pages/new/[slug].tsx
@@ -82,9 +82,9 @@ import {
} from 'ui'
import { Admonition } from 'ui-patterns/admonition'
import { Input } from 'ui-patterns/DataInputs/Input'
+import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { InfoTooltip } from 'ui-patterns/info-tooltip'
-import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
type DesiredInstanceSize = components['schemas']['DesiredInstanceSize']