Clean up databaseUpgrades flag

This commit is contained in:
Joshen Lim committed 2024-02-14 14:08:47 +08:00
1 parent 310fac3f4d
commit 40d73d4354
3 files changed
+63 -68

No files matched your search

@@ -1,9 +1,9 @@
import * as Tooltip from '@radix-ui/react-tooltip'
import { useParams } from 'common'
import { observer } from 'mobx-react-lite'
import Link from 'next/link'
import { Alert, Badge, Button, IconPackage, Input } from 'ui'
import { useParams } from 'common/hooks'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import {
FormHeader,
@@ -13,11 +13,11 @@ import {
FormSectionLabel,
} from 'components/ui/Forms'
import { useProjectUpgradeEligibilityQuery } from 'data/config/project-upgrade-eligibility-query'
import { useFlag, useSelectedOrganization } from 'hooks'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useSelectedOrganization } from 'hooks'
import PauseProjectButton from './PauseProjectButton'
import ProjectUpgradeAlert from './ProjectUpgradeAlert'
import RestartServerButton from './RestartServerButton'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
interface InfrastructureProps {}
@@ -41,7 +41,6 @@ const Infrastructure = ({}: InfrastructureProps) => {
const currentPgVersion = (current_app_version ?? '').split('supabase-postgres-')[1]
const latestPgVersion = (latest_app_version ?? '').split('supabase-postgres-')[1]
const showDbUpgrades = useFlag('databaseUpgrades')
const subject = 'Request%20for%20Postgres%20upgrade%20for%20project'
const message = `Upgrade information:%0A• Manual intervention reason: ${requires_manual_intervention}`
@@ -125,8 +124,8 @@ const Infrastructure = ({}: InfrastructureProps) => {
),
]}
/>
{showDbUpgrades && data?.eligible && <ProjectUpgradeAlert />}
{showDbUpgrades && !data?.eligible && data?.requires_manual_intervention && (
{data?.eligible && <ProjectUpgradeAlert />}
{!data?.eligible && data?.requires_manual_intervention && (
<Alert
icon={<IconPackage className="text-foreground-light" strokeWidth={1.5} />}
variant="neutral"
@@ -1,7 +1,15 @@
import * as Tooltip from '@radix-ui/react-tooltip'
import Link from 'next/link'
import { useParams } from 'common'
import Link from 'next/link'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
Alert_Shadcn_,
Badge,
Button,
Input,
} from 'ui'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import {
ScaffoldContainer,
@@ -15,14 +23,6 @@ import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useProjectUpgradeEligibilityQuery } from 'data/config/project-upgrade-eligibility-query'
import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
import { useFlag, useIsFeatureEnabled } from 'hooks'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
Alert_Shadcn_,
Badge,
Button,
Input,
} from 'ui'
import ProjectUpgradeAlert from '../General/Infrastructure/ProjectUpgradeAlert'
import InstanceConfiguration from './InfrastructureConfiguration/InstanceConfiguration'
@@ -47,7 +47,6 @@ const InfrastructureInfo = () => {
const currentPgVersion = (current_app_version ?? '').split('supabase-postgres-')[1]
const latestPgVersion = (latest_app_version ?? '').split('supabase-postgres-')[1]
const showDbUpgrades = useFlag('databaseUpgrades')
const readReplicasEnabled = useFlag('readReplicas')
const showReadReplicasUI = readReplicasEnabled && project?.is_read_replicas_enabled
const hasReadReplicas = (databases ?? []).length > 1
@@ -155,8 +154,8 @@ const InfrastructureInfo = () => {
),
]}
/>
{showDbUpgrades && data?.eligible && !hasReadReplicas && <ProjectUpgradeAlert />}
{showDbUpgrades && data.eligible && hasReadReplicas && (
{data?.eligible && !hasReadReplicas && <ProjectUpgradeAlert />}
{data.eligible && hasReadReplicas && (
<Alert_Shadcn_>
<AlertTitle_Shadcn_>
A new version of Postgres is available for your project
@@ -167,7 +166,7 @@ const InfrastructureInfo = () => {
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
{showDbUpgrades && !data?.eligible && data?.requires_manual_intervention && (
{!data?.eligible && data?.requires_manual_intervention && (
<Alert_Shadcn_ title="A new version of Postgres is available for your project">
<AlertTitle_Shadcn_>
A new version of Postgres is available for your project
@@ -189,49 +188,47 @@ const InfrastructureInfo = () => {
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
{showDbUpgrades &&
!data?.eligible &&
(data?.extension_dependent_objects || []).length > 0 && (
<Alert_Shadcn_
variant="warning"
title="A new version of Postgres is available for your project"
>
<AlertTitle_Shadcn_>New version of Postgres available</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_ className="flex flex-col gap-3">
<div>
<p className="mb-1">
This project cannot be upgraded due to the following extension dependent
objects:
</p>
<ul className="pl-4">
{(data?.extension_dependent_objects || []).map((obj) => (
<li className="list-disc" key={obj}>
{obj}
</li>
))}
</ul>
</div>
<p>
Once the above objects are exported and removed, you can proceed to
upgrade your project, and re-import the objects after the upgrade
operation is complete. Please refer to the docs on additional extensions
that might also need to be dropped.
{!data?.eligible && (data?.extension_dependent_objects || []).length > 0 && (
<Alert_Shadcn_
variant="warning"
title="A new version of Postgres is available for your project"
>
<AlertTitle_Shadcn_>New version of Postgres available</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_ className="flex flex-col gap-3">
<div>
<p className="mb-1">
This project cannot be upgraded due to the following extension dependent
objects:
</p>
<div>
<Button size="tiny" type="default" asChild>
<Link
href="https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#caveats"
target="_blank"
rel="noreferrer"
>
View docs
</Link>
</Button>
</div>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
<ul className="pl-4">
{(data?.extension_dependent_objects || []).map((obj) => (
<li className="list-disc" key={obj}>
{obj}
</li>
))}
</ul>
</div>
<p>
Once the above objects are exported and removed, you can proceed to upgrade
your project, and re-import the objects after the upgrade operation is
complete. Please refer to the docs on additional extensions that might also
need to be dropped.
</p>
<div>
<Button size="tiny" type="default" asChild>
<Link
href="https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#caveats"
target="_blank"
rel="noreferrer"
>
View docs
</Link>
</Button>
</div>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
</>
)}
</ScaffoldSectionContent>
@@ -1,18 +1,17 @@
import { DatabaseUpgradeStatus } from '@supabase/shared-types/out/events'
import { useParams } from 'common'
import dayjs from 'dayjs'
import Link from 'next/link'
import { useState } from 'react'
import { Alert, Button, IconX } from 'ui'
import { useParams } from 'common/hooks'
import { IS_PLATFORM } from 'lib/constants'
import { useProjectUpgradingStatusQuery } from 'data/config/project-upgrade-status-query'
import { DatabaseUpgradeStatus } from '@supabase/shared-types/out/events'
import { useFlag } from 'hooks'
import { IS_PLATFORM } from 'lib/constants'
// [Joshen] Think twice about the category though - it doesn't correspond
const ProjectUpgradeFailedBanner = () => {
const { ref } = useParams()
const showDbUpgrades = useFlag('databaseUpgrades')
const { data } = useProjectUpgradingStatusQuery({ projectRef: ref }, { enabled: IS_PLATFORM })
const { status, initiated_at, error } = data?.databaseUpgradeStatus ?? {}
@@ -35,7 +34,7 @@ const ProjectUpgradeFailedBanner = () => {
localStorage.setItem(key, 'true')
}
if (!isFailed || !showMessage || !showDbUpgrades) return null
if (!isFailed || !showMessage) return null
return (
<div className="max-w-7xl">