Files
supabase/apps/studio/hooks/misc/useSelectedProject.ts
T
Artur ZakirovandCharis 4b2d163a1d fix(orioledb): use alpha and beta conditionally based on AMI version (#51162)
## Problem

- Older orioledb projects show "Public Beta" instead of "Public Alpha"
in UI.
- List of backups in the "Scheduled backups" tab hangs.

## Solution

- show in the UI "Public Alpha" for projects older than
17.11.0.001-orioledb
- show in the UI "Public Beta" for new projects
- enable scheduled-backup query for "Public Beta"


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Backup availability messages now reflect OrioleDB’s current release
stage rather than always describing it as public beta.
* AWS backup queries are no longer disabled for every OrioleDB project;
they remain disabled during the alpha stage.
* **New Features**
* Added an informational notice and documentation link for scheduled
backups on AWS OrioleDB projects in alpha.
  * Added release-stage details to the PITR availability notice.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
2026-10-02 09:43:32 -04:00

82 lines
2.4 KiB
TypeScript

import { useParams } from 'common'
import {
isOrioleDbVersionAtLeast,
ORIOLEDB_PUBLIC_BETA_VERSION,
type OrioleDbReleaseStage,
} from './useSelectedProject.utils'
import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
import { PROJECT_STATUS, PROVIDERS } from '@/lib/constants'
export function useSelectedProjectQuery({ enabled = true } = {}) {
const { ref } = useParams()
return useProjectDetailQuery(
{ ref },
{
enabled,
select: (data) => {
return {
...data,
parentRef: data.parent_project_ref ?? data.ref,
}
},
}
)
}
export const useIsAwsCloudProvider = () => {
const { data: project } = useSelectedProjectQuery()
const isAws = project?.cloud_provider === PROVIDERS.AWS.id
return isAws
}
export const useIsAwsK8sCloudProvider = () => {
const { data: project } = useSelectedProjectQuery()
const isAwsK8s = project?.cloud_provider === PROVIDERS.AWS_K8S.id
return isAwsK8s
}
export const useIsAwsNimbusCloudProvider = () => {
const { data: project } = useSelectedProjectQuery()
const isAwsNimbus = project?.cloud_provider === PROVIDERS.AWS_NIMBUS.id
return isAwsNimbus
}
export const useIsOrioleDb = () => {
const { data: project } = useSelectedProjectQuery()
const isOrioleDb = project?.dbVersion?.endsWith('orioledb')
return isOrioleDb
}
export const useIsOrioleDbInAws = () => {
const { data: project } = useSelectedProjectQuery()
const isOrioleDbInAws =
project?.dbVersion?.endsWith('orioledb') && project?.cloud_provider === PROVIDERS.AWS.id
return isOrioleDbInAws
}
// OrioleDB moved from Public Alpha to Public Beta at engine version 17.11.0.001.
// PITR remains unsupported for every OrioleDB version regardless of stage.
export const useOrioleDbReleaseStage = (): OrioleDbReleaseStage | undefined => {
const { data: project } = useSelectedProjectQuery()
if (!project?.dbVersion?.endsWith('orioledb')) return undefined
return isOrioleDbVersionAtLeast(project.dbVersion, ORIOLEDB_PUBLIC_BETA_VERSION)
? 'beta'
: 'alpha'
}
// [Joshen TODO] There's a duplicate method `resolveHighAvailability` in `useHighAvailability.constants`
export const useIsHighAvailability = () => {
const { data: project } = useSelectedProjectQuery()
return project?.high_availability ?? false
}
export const useIsProjectActive = () => {
const { data: project } = useSelectedProjectQuery()
return project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
}