mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 21:29:08 +03:00
chore: init useIsOrioleDbInAws (#35325)
* chore: check for cloud provider in useIsOrioleDb * chore: introduce useIsOrioleDbInAwsNew instead * chore: consolidate to using useIsOrioleDb * chore: selectively include useIsOrioleDbInAwsNew in conditionals * fix: prettier * fix: incorrect cloud provider * fix: update conditional instead * fix: prettier * Simplify logic * Smol fix --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
This commit is contained in:
1 parent
915af35334
commit
14562e9c8a
7 files changed
+40
-28
No files matched your search
@@ -76,7 +76,7 @@ export const PostgresVersionSelector = ({
|
||||
const defaultValue = gaVersion ? formatValue(gaVersion) : formatValue(availableVersions[0])
|
||||
form.setValue('postgresVersionSelection', defaultValue)
|
||||
}
|
||||
}, [isSuccess, form])
|
||||
}, [isSuccess, availableVersions, form])
|
||||
|
||||
return (
|
||||
<FormItemLayout label="Postgres Version" layout={layout}>
|
||||
|
||||
@@ -32,7 +32,7 @@ import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-que
|
||||
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
|
||||
import type { ProjectAddonVariantMeta } from 'data/subscriptions/types'
|
||||
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
|
||||
import { useIsOrioleDb, useProjectByRef } from 'hooks/misc/useSelectedProject'
|
||||
import { useIsOrioleDb, useIsOrioleDbInAws, useProjectByRef } from 'hooks/misc/useSelectedProject'
|
||||
import { useFlag } from 'hooks/ui/useFlag'
|
||||
import { getCloudProviderArchitecture } from 'lib/cloudprovider-utils'
|
||||
import { BASE_PATH, INSTANCE_MICRO_SPECS, INSTANCE_NANO_SPECS } from 'lib/constants'
|
||||
@@ -54,6 +54,7 @@ const Addons = () => {
|
||||
const isBranch = parentProject !== undefined
|
||||
const isProjectActive = useIsProjectActive()
|
||||
const isOrioleDb = useIsOrioleDb()
|
||||
const isOrioleDbInAws = useIsOrioleDbInAws()
|
||||
|
||||
const { data: settings } = useProjectSettingsV2Query({ projectRef })
|
||||
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: selectedOrg?.slug })
|
||||
@@ -486,7 +487,7 @@ const Addons = () => {
|
||||
</Button>
|
||||
</AlertDescription_Shadcn_>
|
||||
</Alert_Shadcn_>
|
||||
) : isOrioleDb ? (
|
||||
) : isOrioleDbInAws ? (
|
||||
<ButtonTooltip
|
||||
disabled
|
||||
type="default"
|
||||
|
||||
@@ -13,6 +13,7 @@ import { useProjectUpgradeEligibilityQuery } from 'data/config/project-upgrade-e
|
||||
import { useProjectServiceVersionsQuery } from 'data/projects/project-service-versions'
|
||||
import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
|
||||
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
|
||||
import { useIsOrioleDb } from 'hooks/misc/useSelectedProject'
|
||||
import {
|
||||
AlertDescription_Shadcn_,
|
||||
AlertTitle_Shadcn_,
|
||||
@@ -62,7 +63,7 @@ const InfrastructureInfo = () => {
|
||||
current_app_version_release_channel && current_app_version_release_channel !== 'ga'
|
||||
? current_app_version_release_channel
|
||||
: undefined
|
||||
const isOrioleDb = (current_app_version ?? '').includes('orioledb')
|
||||
const isOrioleDb = useIsOrioleDb()
|
||||
const latestPgVersion = (latest_app_version ?? '').split('supabase-postgres-')[1]
|
||||
|
||||
const isInactive = project?.status === 'INACTIVE'
|
||||
@@ -147,18 +148,16 @@ const InfrastructureInfo = () => {
|
||||
</Tooltip>
|
||||
),
|
||||
isOrioleDb && (
|
||||
<>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<Badge variant="default" className="mr-1">
|
||||
OrioleDB
|
||||
</Badge>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom" className="w-44 text-center">
|
||||
This project uses OrioleDB
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</>
|
||||
<Tooltip>
|
||||
<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>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||
|
||||
import type { components } from 'data/api'
|
||||
import { get, handleError } from 'data/fetchers'
|
||||
import { useIsOrioleDb } from 'hooks/misc/useSelectedProject'
|
||||
import { useIsOrioleDbInAws } from 'hooks/misc/useSelectedProject'
|
||||
import type { ResponseError } from 'types'
|
||||
import { databaseKeys } from './keys'
|
||||
|
||||
@@ -32,11 +32,14 @@ export const useBackupsQuery = <TData = BackupsData>(
|
||||
{ enabled = true, ...options }: UseQueryOptions<BackupsData, BackupsError, TData> = {}
|
||||
) => {
|
||||
// [Joshen] Check for specifically false to account for project not loaded yet
|
||||
const isOrioleDb = useIsOrioleDb()
|
||||
const isOrioleDbInAws = useIsOrioleDbInAws()
|
||||
|
||||
return useQuery<BackupsData, BackupsError, TData>(
|
||||
databaseKeys.backups(projectRef),
|
||||
({ signal }) => getBackups({ projectRef }, signal),
|
||||
{ enabled: enabled && isOrioleDb === false && typeof projectRef !== 'undefined', ...options }
|
||||
{
|
||||
enabled: enabled && !isOrioleDbInAws && typeof projectRef !== 'undefined',
|
||||
...options,
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import { useMemo } from 'react'
|
||||
|
||||
import { useIsLoggedIn, useParams } from 'common'
|
||||
import { useProjectDetailQuery } from 'data/projects/project-detail-query'
|
||||
import { ProjectInfo, useProjectsQuery } from 'data/projects/projects-query'
|
||||
import { useMemo } from 'react'
|
||||
import { PROVIDERS } from 'lib/constants'
|
||||
|
||||
export function useSelectedProject({ enabled = true } = {}) {
|
||||
const { ref } = useParams()
|
||||
@@ -37,3 +39,10 @@ export const useIsOrioleDb = () => {
|
||||
const isOrioleDb = project?.dbVersion?.endsWith('orioledb')
|
||||
return isOrioleDb
|
||||
}
|
||||
|
||||
export const useIsOrioleDbInAws = () => {
|
||||
const project = useSelectedProject()
|
||||
const isOrioleDbInAws =
|
||||
project?.dbVersion?.endsWith('orioledb') && project?.cloud_provider === PROVIDERS.AWS.id
|
||||
return isOrioleDbInAws
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { useParams } from 'common'
|
||||
import DatabaseBackupsNav from 'components/interfaces/Database/Backups/DatabaseBackupsNav'
|
||||
import { PITRNotice, PITRSelection } from 'components/interfaces/Database/Backups/PITR'
|
||||
import DatabaseLayout from 'components/layouts/DatabaseLayout/DatabaseLayout'
|
||||
import DefaultLayout from 'components/layouts/DefaultLayout'
|
||||
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
|
||||
import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold'
|
||||
import AlertError from 'components/ui/AlertError'
|
||||
@@ -16,12 +17,11 @@ import UpgradeToPro from 'components/ui/UpgradeToPro'
|
||||
import { useBackupsQuery } from 'data/database/backups-query'
|
||||
import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'
|
||||
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
|
||||
import { useIsOrioleDb } from 'hooks/misc/useSelectedProject'
|
||||
import { useIsOrioleDbInAws } from 'hooks/misc/useSelectedProject'
|
||||
import { PROJECT_STATUS } from 'lib/constants'
|
||||
import type { NextPageWithLayout } from 'types'
|
||||
import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_ } from 'ui'
|
||||
import { Admonition } from 'ui-patterns'
|
||||
import DefaultLayout from 'components/layouts/DefaultLayout'
|
||||
|
||||
const DatabasePhysicalBackups: NextPageWithLayout = () => {
|
||||
return (
|
||||
@@ -51,7 +51,7 @@ const PITR = () => {
|
||||
const { ref: projectRef } = useParams()
|
||||
const { project } = useProjectContext()
|
||||
const organization = useSelectedOrganization()
|
||||
const isOrioleDb = useIsOrioleDb()
|
||||
const isOrioleDbInAws = useIsOrioleDbInAws()
|
||||
const { data: backups, error, isLoading, isError, isSuccess } = useBackupsQuery({ projectRef })
|
||||
|
||||
const plan = organization?.plan?.id
|
||||
@@ -65,7 +65,7 @@ const PITR = () => {
|
||||
return <NoPermission resourceText="view PITR backups" />
|
||||
}
|
||||
|
||||
if (isOrioleDb) {
|
||||
if (isOrioleDbInAws) {
|
||||
return (
|
||||
<Admonition
|
||||
type="default"
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useParams } from 'common'
|
||||
import { BackupsList } from 'components/interfaces/Database'
|
||||
import DatabaseBackupsNav from 'components/interfaces/Database/Backups/DatabaseBackupsNav'
|
||||
import DatabaseLayout from 'components/layouts/DatabaseLayout/DatabaseLayout'
|
||||
import DefaultLayout from 'components/layouts/DefaultLayout'
|
||||
import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold'
|
||||
import AlertError from 'components/ui/AlertError'
|
||||
import { DocsButton } from 'components/ui/DocsButton'
|
||||
@@ -14,17 +15,16 @@ import NoPermission from 'components/ui/NoPermission'
|
||||
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
|
||||
import { useBackupsQuery } from 'data/database/backups-query'
|
||||
import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'
|
||||
import { useIsOrioleDb } from 'hooks/misc/useSelectedProject'
|
||||
import { useIsOrioleDbInAws } from 'hooks/misc/useSelectedProject'
|
||||
import type { NextPageWithLayout } from 'types'
|
||||
import { Admonition } from 'ui-patterns'
|
||||
import DefaultLayout from 'components/layouts/DefaultLayout'
|
||||
|
||||
const DatabaseScheduledBackups: NextPageWithLayout = () => {
|
||||
const { ref: projectRef } = useParams()
|
||||
|
||||
const { data: backups, error, isLoading, isError, isSuccess } = useBackupsQuery({ projectRef })
|
||||
|
||||
const isOrioleDb = useIsOrioleDb()
|
||||
const isOrioleDbInAws = useIsOrioleDbInAws()
|
||||
const isPitrEnabled = backups?.pitr_enabled
|
||||
const isPermissionsLoaded = usePermissionsLoaded()
|
||||
|
||||
@@ -39,7 +39,7 @@ const DatabaseScheduledBackups: NextPageWithLayout = () => {
|
||||
|
||||
<DatabaseBackupsNav active="scheduled" />
|
||||
|
||||
{isOrioleDb ? (
|
||||
{isOrioleDbInAws ? (
|
||||
<Admonition
|
||||
type="default"
|
||||
title="Database backups are not available for OrioleDB"
|
||||
|
||||
Reference in new issue
Block a user