Files
Monica Khoury c31c7afb1b fix(studio): add latest-version hint to Postgres version field (#52143)
## Problem

On the General settings page, the Service versions card shows the
versions as disabled inputs. When a project is already up to date,
nothing explains that Postgres updates would show up in this section, or
where to learn more.

Resolves FE-4604:
https://linear.app/supabase/issue/FE-4604/add-hint-regarding-database-versioning

## Solution

Adds a subtle description under the Postgres version field, using the
existing `description` prop on `FormItemLayout`:

> This project is already on the latest version of Postgres that
Supabase supports. Updates will appear here when available. Learn more

"Learn more" links to the upgrading guide. It is tertiary information,
so it is a field description and not an admonition (changed after design
feedback).

It only shows when the project is on the latest version, database
upgrades are enabled, and the project is not on a K8s cloud provider.
The condition is one named boolean, `canShowLatestVersionHint`.
Component tests cover the visible case and the hidden cases.

## How to test

1. Run Studio and open a project's General settings page.
2. On a project already on the latest Postgres version, check that the
description appears under the Postgres version field, next to the
"Latest" badge.
3. Click "Learn more" and check that the upgrading guide opens in a new
tab.
4. On a project with an upgrade available, check that only the upgrade
alert shows and the description does not.
2026-10-26 18:20:05 +02:00

250 lines
10 KiB
TypeScript

import { useParams } from 'common'
import {
Badge,
Card,
CardContent,
Input,
InputGroup,
InputGroupAddon,
InputGroupInput,
Tooltip,
TooltipContent,
TooltipTrigger,
} 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 {
ReadReplicasWarning,
ValidationErrorsWarning,
ValidationWarningsAdmonition,
} from '../../Infrastructure/UpgradeWarnings'
import { ProjectUpgradeAlert } from '../Infrastructure/ProjectUpgradeAlert'
import { AlertError } from '@/components/ui/AlertError'
import { InlineLink } from '@/components/ui/InlineLink'
import { useProjectUpgradeEligibilityQuery } from '@/data/config/project-upgrade-eligibility-query'
import { useProjectServiceVersionsQuery } from '@/data/projects/project-service-versions'
import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import {
useIsAwsK8sCloudProvider,
useIsOrioleDb,
useSelectedProjectQuery,
} from '@/hooks/misc/useSelectedProject'
import { DOCS_URL } from '@/lib/constants'
export const ServiceVersionsSection = () => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
const isAwsK8s = useIsAwsK8sCloudProvider()
const { projectAuthAll: authEnabled, projectSettingsDatabaseUpgrades: showDatabaseUpgrades } =
useIsFeatureEnabled([
'project_auth:all',
'project_settings:database_upgrades',
'database:replication',
])
const {
data,
error,
isPending: isLoadingUpgradeEligibility,
isError: isErrorUpgradeEligibility,
isSuccess: isSuccessUpgradeEligibility,
} = useProjectUpgradeEligibilityQuery({
projectRef: ref,
})
const {
data: serviceVersions,
error: serviceVersionsError,
isPending: isLoadingServiceVersions,
isError: isErrorServiceVersions,
isSuccess: isSuccessServiceVersions,
} = useProjectServiceVersionsQuery({ projectRef: ref })
const { data: databases } = useReadReplicasQuery({ projectRef: ref })
const { current_app_version, current_app_version_release_channel, latest_app_version } =
data || {}
const isOnLatestVersion = current_app_version === latest_app_version
const currentPgVersion = (current_app_version ?? '')
.split('supabase-postgres-')[1]
?.replace('-orioledb', '')
const isVisibleReleaseChannel =
current_app_version_release_channel &&
!['ga', 'withdrawn'].includes(current_app_version_release_channel)
? current_app_version_release_channel
: undefined
const isOrioleDb = useIsOrioleDb()
const latestPgVersion = (latest_app_version ?? '').split('supabase-postgres-')[1]
const isInactive = project?.status === 'INACTIVE'
const hasReadReplicas = (databases ?? []).length > 1
const hasUpgradeAlertOrWarning =
!!data?.eligible ||
(data?.validation_errors ?? []).length > 0 ||
(data?.warnings ?? []).length > 0
const canShowLatestVersionHint =
isOnLatestVersion && showDatabaseUpgrades && !isAwsK8s && !hasUpgradeAlertOrWarning
return (
<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"
showIcon={false}
title="Service versions cannot be retrieved while project is paused"
description="Restoring the project will update Postgres to the newest version"
/>
) : (
<>
{isLoadingUpgradeEligibility && <GenericSkeletonLoader />}
{isErrorUpgradeEligibility && (
<AlertError error={error} subject="Failed to retrieve Postgres version" />
)}
{isSuccessUpgradeEligibility && (
<>
{isLoadingServiceVersions && <GenericSkeletonLoader />}
{isErrorServiceVersions && (
<AlertError
error={serviceVersionsError}
subject="Failed to retrieve versions"
/>
)}
{isSuccessServiceVersions && (
<>
{authEnabled && (
<FormItemLayout
label="Auth version"
layout="vertical"
isReactForm={false}
>
<Input readOnly disabled value={serviceVersions?.gotrue ?? ''} />
</FormItemLayout>
)}
<FormItemLayout
label="PostgREST version"
layout="vertical"
isReactForm={false}
>
<Input readOnly disabled value={serviceVersions?.postgrest ?? ''} />
</FormItemLayout>
<FormItemLayout
label="Postgres version"
layout="vertical"
isReactForm={false}
description={
canShowLatestVersionHint ? (
<>
This project is already on the latest version of Postgres that
Supabase supports. Updates will appear here when available.{' '}
<InlineLink href={`${DOCS_URL}/guides/platform/upgrading`}>
Learn more
</InlineLink>
</>
) : undefined
}
>
<InputGroup>
<InputGroupInput
readOnly
disabled
value={
currentPgVersion || serviceVersions?.['supabase-postgres'] || ''
}
/>
<InputGroupAddon align="inline-end">
{[
isVisibleReleaseChannel && (
<Tooltip key="release-channel">
<TooltipTrigger>
<Badge variant="warning" className="mr-1">
{isVisibleReleaseChannel}
</Badge>
</TooltipTrigger>
<TooltipContent side="bottom" className="w-44 text-center">
This project uses a {isVisibleReleaseChannel} database version
release
</TooltipContent>
</Tooltip>
),
isOrioleDb && (
<Tooltip key="orioledb">
<TooltipTrigger>
<Badge variant="default" className="mr-1">
OrioleDB
</Badge>
</TooltipTrigger>
<TooltipContent side="bottom" className="w-44 text-center">
This project uses OrioleDB
</TooltipContent>
</Tooltip>
),
isOnLatestVersion && (
<Tooltip key="latest-version">
<TooltipTrigger>
<Badge variant="success" className="mr-1">
Latest
</Badge>
</TooltipTrigger>
<TooltipContent side="bottom" className="w-52 text-center">
Project is on the latest version of Postgres that Supabase
supports
</TooltipContent>
</Tooltip>
),
]}
</InputGroupAddon>
</InputGroup>
</FormItemLayout>
</>
)}
{showDatabaseUpgrades && data && data.eligible && !isAwsK8s ? (
hasReadReplicas ? (
<ReadReplicasWarning latestPgVersion={latestPgVersion} />
) : (
<ProjectUpgradeAlert />
)
) : null}
{showDatabaseUpgrades && data && !data.eligible && (
<ValidationErrorsWarning validationErrors={data.validation_errors} />
)}
{showDatabaseUpgrades && data && data.warnings && (
<ValidationWarningsAdmonition warnings={data.warnings} />
)}
</>
)}
</>
)}
</CardContent>
</Card>
</PageSectionContent>
</PageSection>
)
}