Skip to content

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

Update add-ons design (#43159)

Saxon Fletcherd8f8d9a1f3b5
diff --git a/apps/studio/components/interfaces/Settings/Addons/Addons.tsx b/apps/studio/components/interfaces/Settings/Addons/Addons.tsx
index f672118ea3a..fd43ba280d6 100644
--- a/apps/studio/components/interfaces/Settings/Addons/Addons.tsx
+++ b/apps/studio/components/interfaces/Settings/Addons/Addons.tsx
@@ -4,26 +4,16 @@ import {
getAddons,
subscriptionHasHipaaAddon,
} from 'components/interfaces/Billing/Subscription/Subscription.utils'
-import { NoticeBar } from 'components/interfaces/DiskManagement/ui/NoticeBar'
import { ProjectUpdateDisabledTooltip } from 'components/interfaces/Organization/BillingSettings/ProjectUpdateDisabledTooltip'
import { SupportLink } from 'components/interfaces/Support/SupportLink'
-import {
- ScaffoldContainer,
- ScaffoldDivider,
- ScaffoldSection,
- ScaffoldSectionContent,
- ScaffoldSectionDetail,
-} from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
-import { ButtonTooltip } from 'components/ui/ButtonTooltip'
-import { mapResponseToAnalyticsData } from 'data/analytics/infra-monitoring-queries'
-import { useInfraMonitoringAttributesQuery } from 'data/analytics/infra-monitoring-query'
+import { ResourceItem } from 'components/ui/Resource/ResourceItem'
+import { ResourceList } from 'components/ui/Resource/ResourceList'
+import { HorizontalShimmerWithIcon } from 'components/ui/Shimmers'
import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
import { useProjectDetailQuery } from 'data/projects/project-detail-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
-import type { ProjectAddonVariantMeta } from 'data/subscriptions/types'
-import dayjs from 'dayjs'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import {
@@ -32,19 +22,32 @@ import {
useIsProjectActive,
useSelectedProjectQuery,
} from 'hooks/misc/useSelectedProject'
-import { getCloudProviderArchitecture } from 'lib/cloudprovider-utils'
-import { BASE_PATH, DOCS_URL, INSTANCE_MICRO_SPECS, INSTANCE_NANO_SPECS } from 'lib/constants'
+import { BASE_PATH, DOCS_URL } from 'lib/constants'
import { getDatabaseMajorVersion, getSemanticVersion } from 'lib/helpers'
-import { AlertCircle, ChevronRight, ExternalLink, Info } from 'lucide-react'
+import { AlertCircle, Lock } from 'lucide-react'
import { useTheme } from 'next-themes'
import Image from 'next/image'
import Link from 'next/link'
-import { useMemo } from 'react'
import { useAddonsPagePanel } from 'state/addons-page'
-import { Alert, Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_, Button } from 'ui'
-import { ComputeBadge } from 'ui-patterns/ComputeBadge'
-import { GenericSkeletonLoader, ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
+import {
+ Alert_Shadcn_,
+ AlertDescription_Shadcn_,
+ AlertTitle_Shadcn_,
+ Badge,
+ Button,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from 'ui'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import { PageSection } from 'ui-patterns/PageSection'
+import {
+ getCustomDomainDisabledReason,
+ getIPv4DisabledReason,
+ getPitrAlertState,
+ getPitrDisabledReason,
+} from './Addons.utils'
import CustomDomainSidePanel from './CustomDomainSidePanel'
import IPv4SidePanel from './IPv4SidePanel'
import PITRSidePanel from './PITRSidePanel'
@@ -55,7 +58,7 @@ export const Addons = () => {
const { setPanel } = useAddonsPagePanel()
const isAws = useIsAwsCloudProvider()
const isProjectActive = useIsProjectActive()
- const isOrioleDbInAws = useIsOrioleDbInAws()
+ const isOrioleDbInAws = useIsOrioleDbInAws() === true
const { projectSettingsCustomDomains, projectAddonsDedicatedIpv4Address } = useIsFeatureEnabled([
'project_settings:custom_domains',
@@ -63,7 +66,7 @@ export const Addons = () => {
])
const { data: selectedOrg } = useSelectedOrganizationQuery()
- const { data: selectedProject, isPending: isLoadingProject } = useSelectedProjectQuery()
+ const { data: selectedProject } = useSelectedProjectQuery()
const { data: parentProject } = useProjectDetailQuery({
ref: selectedProject?.parent_project_ref,
})
@@ -73,10 +76,8 @@ export const Addons = () => {
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: selectedOrg?.slug })
const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')
+ const hasHipaaAddon = subscriptionHasHipaaAddon(subscription) && settings?.is_sensitive === true
- const hasHipaaAddon = subscriptionHasHipaaAddon(subscription) && settings?.is_sensitive
-
- const cpuArchitecture = getCloudProviderArchitecture(selectedProject?.cloud_provider)
// Only projects of version greater than supabase-postgrest-14.1.0.44 can use PITR
const sufficientPgVersion =
// introduced as generatedSemantic version could be < 141044 even if actual version is indeed past it
@@ -84,26 +85,6 @@ export const Addons = () => {
getDatabaseMajorVersion(selectedProject?.dbVersion ?? '') > 14 ||
getSemanticVersion(selectedProject?.dbVersion ?? '') >= 141044
- // [Joshen] We could possibly look into reducing the interval to be more "realtime"
- // I tried setting the interval to 1m but no data was returned, may need to experiment
- const startDate = useMemo(() => dayjs().subtract(15, 'minutes').millisecond(0).toISOString(), [])
- const endDate = useMemo(() => dayjs().millisecond(0).toISOString(), [])
- const { data: ioBudgetData } = useInfraMonitoringAttributesQuery({
- projectRef,
- attributes: ['disk_io_budget'],
- interval: '5m',
- startDate,
- endDate,
- })
- const mostRecentRemainingIOBudget = useMemo(() => {
- if (!ioBudgetData) return undefined
- const mapped = mapResponseToAnalyticsData(ioBudgetData, ['disk_io_budget'])
- const data = mapped['disk_io_budget']?.data
- if (!data?.length) return undefined
- const lastPoint = data[data.length - 1]
- return { disk_io_budget: lastPoint?.disk_io_budget }
- }, [ioBudgetData])
-
const {
data: addons,
error,
@@ -111,550 +92,315 @@ export const Addons = () => {
isError,
isSuccess,
} = useProjectAddonsQuery({ projectRef })
+
const selectedAddons = addons?.selected_addons ?? []
- const { computeInstance, pitr, customDomain, ipv4 } = getAddons(selectedAddons)
+ const { pitr, customDomain, ipv4 } = getAddons(selectedAddons)
+
+ const canUpdateIPv4 = settings?.db_ip_addr_config === 'ipv6'
- const meta = useMemo(() => {
- const computeMeta = computeInstance?.variant?.meta as ProjectAddonVariantMeta | undefined
+ const ipv4Enabled = ipv4 !== undefined
+ const pitrEnabled = pitr !== undefined
+ const customDomainEnabled = customDomain !== undefined
- if (!computeMeta && selectedProject?.infra_compute_size === 'nano') {
- return INSTANCE_NANO_SPECS
- } else if (selectedProject?.infra_compute_size === 'micro') {
- return INSTANCE_MICRO_SPECS
- }
+ const canOpenIPv4 =
+ isAws && isProjectActive && !projectUpdateDisabled && (canUpdateIPv4 || ipv4Enabled)
+ const canOpenPITR =
+ isProjectActive &&
+ !projectUpdateDisabled &&
+ sufficientPgVersion &&
+ !hasHipaaAddon &&
+ !isOrioleDbInAws
+ const canOpenCustomDomain = isProjectActive && !projectUpdateDisabled
- return computeMeta
- }, [selectedProject, computeInstance])
+ const ipv4DisabledReason = getIPv4DisabledReason({
+ isAws,
+ isProjectActive,
+ projectUpdateDisabled,
+ canUpdateIPv4,
+ ipv4Enabled,
+ })
- const canUpdateIPv4 = settings?.db_ip_addr_config === 'ipv6'
+ const pitrDisabledReason = getPitrDisabledReason({
+ isProjectActive,
+ projectUpdateDisabled,
+ hasHipaaAddon,
+ sufficientPgVersion,
+ isOrioleDbInAws,
+ })
- return (
- <>
- <ScaffoldDivider />
+ const customDomainDisabledReason = getCustomDomainDisabledReason({
+ isProjectActive,
+ projectUpdateDisabled,
+ })
+ const pitrAlertState = getPitrAlertState({
+ hasHipaaAddon,
+ sufficientPgVersion,
+ isOrioleDbInAws,
+ })
+
+ const listTopSpacing = isBranch ? 'mt-6' : undefined
+ const resourceItemClassName =
+ 'min-h-[128px] !border-b last:!border-b-0 [&>div:first-child]:hidden @lg:[&>div:first-child]:flex'
- {isBranch && (
- <ScaffoldContainer>
+ let pitrAlert = null
+
+ if (pitrAlertState === 'hipaa') {
+ pitrAlert = (
+ <Alert_Shadcn_ className="rounded-none border-0 border-b px-6">
+ <AlertTitle_Shadcn_>PITR cannot be changed with HIPAA</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ All projects should have PITR enabled by default and cannot be changed with HIPAA enabled.
+ Contact support for further assistance.
+ </AlertDescription_Shadcn_>
+ <div className="mt-4">
+ <Button type="default" asChild>
+ <SupportLink>Contact support</SupportLink>
+ </Button>
+ </div>
+ </Alert_Shadcn_>
+ )
+ } else if (pitrAlertState === 'legacy-project') {
+ pitrAlert = (
+ <Alert_Shadcn_ className="rounded-none border-0 border-b px-6">
+ <AlertTitle_Shadcn_>Your project is too old to enable PITR</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ <p className="text-sm leading-normal mb-2">
+ Reach out to us via support if you're interested
+ </p>
+ <Button asChild type="default">
+ <SupportLink
+ queryParams={{
+ projectRef,
+ category: SupportCategories.SALES_ENQUIRY,
+ subject: 'Project too old old for PITR',
+ }}
+ >
+ Contact support
+ </SupportLink>
+ </Button>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )
+ } else if (pitrAlertState === 'orioledb') {
+ pitrAlert = (
+ <Alert_Shadcn_ className="rounded-none border-0 border-b px-6">
+ <AlertTitle_Shadcn_>PITR not supported</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ Point in time recovery is not supported with OrioleDB
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )
+ }
+
+ return (
+ <PageContainer size="default">
+ <PageSection className="last:pb-0 gap-0">
+ {isBranch && (
<Alert_Shadcn_ variant="default" className="mt-6">
<AlertCircle strokeWidth={2} />
<AlertTitle_Shadcn_>
You are currently on a preview branch of your project
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
- Updating addons here will only apply to this preview branch. To manage your addons,
- for your main branch, please visit the{' '}
+ Updating add-ons here will only apply to this preview branch. To manage add-ons for
+ your main branch, please visit the{' '}
<Link href={`/project/${parentProject.ref}/settings/general`} className="text-brand">
main branch
</Link>
.
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
- </ScaffoldContainer>
- )}
-
- {isLoading && (
- <ScaffoldContainer>
- <ScaffoldSection>
- <div className="col-span-12">
- <GenericSkeletonLoader />
- </div>
- </ScaffoldSection>
- </ScaffoldContainer>
- )}
+ )}
- {isError && (
- <ScaffoldContainer>
- <ScaffoldSection>
- <div className="col-span-12">
- <AlertError error={error} subject="Failed to retrieve project addons" />
- </div>
- </ScaffoldSection>
- </ScaffoldContainer>
- )}
-
- {isSuccess && (
- <>
- {selectedProject?.infra_compute_size === 'nano' && subscription?.plan.id !== 'free' && (
- <ScaffoldContainer className="mt-4">
- <Alert_Shadcn_ variant="default">
- <Info strokeWidth={2} />
- <AlertTitle_Shadcn_>Free compute upgrade to Micro</AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- Paid Plans include a free upgrade to Micro compute. Your project is ready to
- upgrade for no additional charges.
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- </ScaffoldContainer>
- )}
- <ScaffoldContainer>
- <ScaffoldSection className="!pb-12">
- <ScaffoldSectionDetail>
- <div className="space-y-6">
- <p className="m-0">Compute Size</p>
- <div className="space-y-2">
- <p className="text-sm text-foreground-light m-0">More information</p>
- <div>
- <Link
- href={`${DOCS_URL}/guides/platform/compute-add-ons`}
- target="_blank"
- rel="noreferrer"
- >
- <div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">
- <p className="text-sm m-0">About compute add-ons</p>
- <ExternalLink size={16} strokeWidth={1.5} />
- </div>
- </Link>
- </div>
- <div>
- <Link
- href={`${DOCS_URL}/guides/database/connecting-to-postgres#connection-pooler`}
- target="_blank"
- rel="noreferrer"
- >
- <div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">
- <p className="text-sm m-0">Connection Pooler</p>
- <ExternalLink size={16} strokeWidth={1.5} />
- </div>
- </Link>
- </div>
- </div>
+ {isLoading && (
+ <ResourceList className={listTopSpacing}>
+ {Array.from({ length: 3 }).map((_, index) => (
+ <div
+ key={index}
+ className="flex min-h-[128px] items-center gap-4 border-b px-6 py-4 last:border-b-none"
+ >
+ <div className="hidden @lg:flex h-24 w-40 shrink-0 items-center justify-center rounded-lg border">
+ <div className="shimmering-loader h-full w-full rounded-lg" />
</div>
- </ScaffoldSectionDetail>
- <ScaffoldSectionContent>
- <div className="flex space-x-6">
- <div>
- <div className="rounded-md bg-surface-100 border border-muted w-[160px] h-[96px] overflow-hidden">
- <Image
- alt="Compute size"
- width={160}
- height={96}
- src={
- ['nano', 'micro'].includes(selectedProject?.infra_compute_size || 'micro')
- ? `${BASE_PATH}/img/optimized-compute-off${
- resolvedTheme?.includes('dark') ? '' : '--light'
- }.svg`
- : `${BASE_PATH}/img/optimized-compute-on${
- resolvedTheme?.includes('dark') ? '' : '--light'
- }.svg`
- }
- />
- </div>
- </div>
- <div className="flex-grow">
- <p className="text-sm text-foreground-light">Current option:</p>
- {isLoading || (computeInstance === undefined && isLoadingProject) ? (
- <ShimmeringLoader className="w-32" />
- ) : (
- <div className="flex py-3">
- <ComputeBadge infraComputeSize={selectedProject?.infra_compute_size} />
- </div>
- )}
+ <div className="flex-1">
+ <HorizontalShimmerWithIcon />
+ </div>
+ </div>
+ ))}
+ </ResourceList>
+ )}
- <NoticeBar
- visible={true}
- type="default"
- title="Compute size has moved"
- description="Compute size is now managed alongside Disk configuration on the new Compute and Disk page."
- actions={
- <ProjectUpdateDisabledTooltip
- projectUpdateDisabled={projectUpdateDisabled}
- projectNotActive={!isProjectActive}
- >
- <Button
- asChild
- type="default"
- className="pointer-events-auto"
- disabled={projectUpdateDisabled || !isProjectActive}
- >
- <Link href={`/project/${projectRef}/settings/compute-and-disk`}>
- Go to Compute and Disk
- </Link>
- </Button>
- </ProjectUpdateDisabledTooltip>
- }
- />
+ {isError && <AlertError error={error} subject="Failed to retrieve project add-ons" />}
- {Number(mostRecentRemainingIOBudget?.disk_io_budget) === 0 ? (
- <Alert
- withIcon
- className="mt-4"
- variant="danger"
- title="Your disk IO budget has run out for today"
- >
- <p>
- Your workload is currently running at the baseline disk IO bandwidth at{' '}
- {meta?.baseline_disk_io_mbs?.toLocaleString() ?? '-'} Mbps and may suffer
- degradation in performance.
- </p>
- <p className="mt-1">
- Consider upgrading to a larger compute instance for a higher baseline
- throughput.
- </p>
- </Alert>
- ) : Number(mostRecentRemainingIOBudget?.disk_io_budget) <= 10 ? (
- <Alert
- withIcon
- className="mt-4"
- variant="warning"
- title="Your disk IO budget is running out for today"
- >
- <p>
- If the disk IO budget drops to zero, your workload will run at the
- baseline disk IO bandwidth at{' '}
- {meta?.baseline_disk_io_mbs?.toLocaleString() ?? '-'} Mbps and may suffer
- degradation in performance.
- </p>
- <p className="mt-1">
- Consider upgrading to a larger compute instance for a higher baseline
- throughput.
- </p>
- </Alert>
- ) : null}
- <div className="mt-2 w-full flex items-center justify-between border-b py-2">
- <Link href={`/project/${projectRef}/settings/infrastructure#ram`}>
- <div className="group flex items-center space-x-2">
- <p className="text-sm text-foreground-light group-hover:text-foreground transition cursor-pointer">
- Memory
- </p>
- <ChevronRight
- strokeWidth={1.5}
- size={16}
- className="transition opacity-0 -translate-x-2 group-hover:opacity-100 group-hover:translate-x-0"
- />
- </div>
- </Link>
- <p className="text-sm">{meta?.memory_gb ?? '-'} GB</p>
- </div>
- <div className="w-full flex items-center justify-between border-b py-2">
- <Link href={`/project/${projectRef}/settings/infrastructure#cpu`}>
- <div className="group flex items-center space-x-2">
- <p className="text-sm text-foreground-light group-hover:text-foreground transition cursor-pointer">
- CPU
- </p>
- <ChevronRight
- strokeWidth={1.5}
- size={16}
- className="transition opacity-0 -translate-x-2 group-hover:opacity-100 group-hover:translate-x-0"
- />
- </div>
- </Link>
- <p className="text-sm">
- {meta?.cpu_cores ?? '?'}-core {cpuArchitecture}{' '}
- {meta?.cpu_dedicated ? '(Dedicated)' : '(Shared)'}
- </p>
- </div>
- <div className="w-full flex items-center justify-between border-b py-2">
- <p className="text-sm text-foreground-light">No. of direct connections</p>
- <p className="text-sm">{meta?.connections_direct ?? '-'}</p>
- </div>
- <div className="w-full flex items-center justify-between border-b py-2">
- <p className="text-sm text-foreground-light">No. of pooler connections</p>
- <p className="text-sm">{meta?.connections_pooler ?? '-'}</p>
- </div>
+ {isSuccess && (
+ <ResourceList className={listTopSpacing}>
+ {projectAddonsDedicatedIpv4Address && (
+ <ResourceItem
+ className={resourceItemClassName}
+ onClick={canOpenIPv4 ? () => setPanel('ipv4') : undefined}
+ media={
+ <Image
+ className="bg rounded-lg border"
+ alt="IPv4"
+ width={160}
+ height={96}
+ src={
+ ipv4Enabled
+ ? `${BASE_PATH}/img/ipv4-on${resolvedTheme?.includes('dark') ? '' : '--light'}.svg?v=2`
+ : `${BASE_PATH}/img/ipv4-off${resolvedTheme?.includes('dark') ? '' : '--light'}.svg?v=2`
+ }
+ />
+ }
+ meta={
+ <div className="flex items-center gap-4">
+ <ProjectUpdateDisabledTooltip
+ projectUpdateDisabled={projectUpdateDisabled}
+ projectNotActive={!isProjectActive}
+ tooltip={ipv4DisabledReason}
+ >
+ {ipv4Enabled ? (
+ <Badge variant="success">Enabled</Badge>
+ ) : (
+ <Badge variant="default">Disabled</Badge>
+ )}
+ </ProjectUpdateDisabledTooltip>
</div>
+ }
+ >
+ <div className="space-y-1">
+ <div>Dedicated IPv4 address</div>
+ <p className="m-0 text-foreground-light text-sm">
+ Reserve a dedicated IPv4 address for your project.
+ </p>
+ <Link
+ href={`${DOCS_URL}/guides/platform/ipv4-address`}
+ target="_blank"
+ rel="noreferrer"
+ className="text-link text-sm"
+ onClick={(event) => event.stopPropagation()}
+ >
+ About IPv4 deprecation
+ </Link>
</div>
- </ScaffoldSectionContent>
- </ScaffoldSection>
- </ScaffoldContainer>
+ </ResourceItem>
+ )}
- {projectAddonsDedicatedIpv4Address && (
- <>
- <ScaffoldDivider />
- <ScaffoldContainer>
- <ScaffoldSection className="!pb-12">
- <ScaffoldSectionDetail>
- <div className="space-y-6">
- <p className="m-0">Dedicated IPv4 address</p>
- <div className="space-y-2">
- <p className="text-sm text-foreground-light m-0">More information</p>
- <div>
- <Link
- href={`${DOCS_URL}/guides/platform/ipv4-address`}
- target="_blank"
- rel="noreferrer"
- >
- <div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">
- <p className="text-sm m-0">About IPv4 deprecation</p>
- <ExternalLink size={16} strokeWidth={1.5} />
- </div>
- </Link>
- </div>
- </div>
- </div>
- </ScaffoldSectionDetail>
- <ScaffoldSectionContent>
- <div className="flex space-x-6">
- <div>
- <div className="rounded-md bg-surface-100 border border-muted w-[160px] h-[96px] overflow-hidden">
- <img
- alt="IPv4"
- width={160}
- height={96}
- src={
- ipv4 !== undefined
- ? `${BASE_PATH}/img/ipv4-on${
- resolvedTheme?.includes('dark') ? '' : '--light'
- }.svg?v=2`
- : `${BASE_PATH}/img/ipv4-off${
- resolvedTheme?.includes('dark') ? '' : '--light'
- }.svg?v=2`
- }
- />
- </div>
- </div>
- <div>
- <p className="text-sm text-foreground-light">Current option:</p>
- <p>
- {ipv4 !== undefined
- ? 'Dedicated IPv4 address is enabled'
- : 'Dedicated IPv4 address is not enabled'}
- </p>
- <ProjectUpdateDisabledTooltip
- projectUpdateDisabled={projectUpdateDisabled}
- projectNotActive={!isProjectActive}
- tooltip={
- !isAws
- ? 'Dedicated IPv4 address is only available for AWS projects'
- : undefined
- }
- >
- <Button
- type="default"
- className="mt-2 pointer-events-auto"
- onClick={() => setPanel('ipv4')}
- disabled={
- !isAws ||
- !isProjectActive ||
- projectUpdateDisabled ||
- !(canUpdateIPv4 || ipv4)
- }
- >
- {!!ipv4
- ? 'Toggle dedicated IPv4 address'
- : 'Enable dedicated IPv4 address'}
- </Button>
- </ProjectUpdateDisabledTooltip>
- </div>
- </div>
- </ScaffoldSectionContent>
- </ScaffoldSection>
- </ScaffoldContainer>
- </>
- )}
+ <ResourceItem
+ className={resourceItemClassName}
+ onClick={canOpenPITR ? () => setPanel('pitr') : undefined}
+ media={
+ <Image
+ className="bg rounded-lg border"
+ alt="PITR"
+ width={160}
+ height={96}
+ src={
+ pitrEnabled
+ ? `${BASE_PATH}/img/pitr-on${resolvedTheme?.includes('dark') ? '' : '--light'}.svg`
+ : `${BASE_PATH}/img/pitr-off${resolvedTheme?.includes('dark') ? '' : '--light'}.svg`
+ }
+ />
+ }
+ meta={
+ <div className="flex items-center gap-4">
+ {pitrEnabled ? (
+ <Badge variant="success">Enabled</Badge>
+ ) : (
+ <Badge variant="default">Disabled</Badge>
+ )}
+ {!canOpenPITR && pitrDisabledReason && (
+ <Tooltip>
+ <TooltipTrigger>
+ <Lock strokeWidth={1.5} className="text-foreground-light" size={16} />
+ </TooltipTrigger>
+ <TooltipContent>{pitrDisabledReason}</TooltipContent>
+ </Tooltip>
+ )}
+ </div>
+ }
+ >
+ <div className="space-y-1">
+ <div>Point in time recovery</div>
+ <p className="m-0 text-foreground-light text-sm">
+ Restore your database to a specific moment in the past.
+ </p>
+ <Link
+ href={`${DOCS_URL}/guides/platform/backups#point-in-time-recovery`}
+ target="_blank"
+ rel="noreferrer"
+ className="text-link text-sm"
+ onClick={(event) => event.stopPropagation()}
+ >
+ About PITR backups
+ </Link>
+ </div>
+ </ResourceItem>
- <ScaffoldDivider />
+ {pitrAlert}
- <ScaffoldContainer>
- <ScaffoldSection className="!pb-12">
- <ScaffoldSectionDetail>
- <div className="space-y-6">
- <p className="m-0">Point in time recovery</p>
- <div className="space-y-2">
- <p className="text-sm text-foreground-light m-0">More information</p>
- <div>
- <Link
- href={`${DOCS_URL}/guides/platform/backups#point-in-time-recovery`}
- target="_blank"
- rel="noreferrer"
- >
- <div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">
- <p className="text-sm m-0">About PITR backups</p>
- <ExternalLink size={16} strokeWidth={1.5} />
- </div>
- </Link>
- </div>
- </div>
- </div>
- </ScaffoldSectionDetail>
- <ScaffoldSectionContent>
- {hasHipaaAddon && (
- <Alert_Shadcn_>
- <AlertTitle_Shadcn_>PITR cannot be changed with HIPAA</AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- All projects should have PITR enabled by default and cannot be changed with
- HIPAA enabled. Contact support for further assistance.
- </AlertDescription_Shadcn_>
- <div className="mt-4">
- <Button type="default" asChild>
- <SupportLink>Contact support</SupportLink>
- </Button>
- </div>
- </Alert_Shadcn_>
- )}
- <div className="flex space-x-6">
- <div>
- <div className="rounded-md bg-surface-100 border border-muted w-[160px] h-[96px] overflow-hidden">
- <Image
- alt="Point-In-Time-Recovery"
- width={160}
- height={96}
- src={
- pitr !== undefined
- ? `${BASE_PATH}/img/pitr-on${
- resolvedTheme?.includes('dark') ? '' : '--light'
- }.svg`
- : `${BASE_PATH}/img/pitr-off${
- resolvedTheme?.includes('dark') ? '' : '--light'
- }.svg`
- }
- />
- </div>
- </div>
- <div>
- <p className="text-sm text-foreground-light">Current option:</p>
- <p>
- {pitr !== undefined
- ? `Point in time recovery of ${(pitr.variant.meta as any)?.backup_duration_days} days is enabled`
- : 'Point in time recovery is not enabled'}
- </p>
- {!sufficientPgVersion ? (
- <Alert_Shadcn_ className="mt-2">
- <AlertTitle_Shadcn_>
- Your project is too old to enable PITR
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- <p className="text-sm leading-normal mb-2">
- Reach out to us via support if you're interested
- </p>
- <Button asChild type="default">
- <SupportLink
- queryParams={{
- projectRef,
- category: SupportCategories.SALES_ENQUIRY,
- subject: 'Project too old old for PITR',
- }}
- >
- <a>Contact support</a>
- </SupportLink>
- </Button>
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- ) : isOrioleDbInAws ? (
- <ButtonTooltip
- disabled
- type="default"
- className="mt-2"
- tooltip={{
- content: {
- side: 'bottom',
- text: 'Point in time recovery is not supported with OrioleDB',
- },
- }}
- >
- Enable point in time recovery
- </ButtonTooltip>
+ {projectSettingsCustomDomains && (
+ <ResourceItem
+ className={resourceItemClassName}
+ onClick={canOpenCustomDomain ? () => setPanel('customDomain') : undefined}
+ media={
+ <Image
+ className="bg rounded-lg border"
+ alt="Custom Domain"
+ width={160}
+ height={96}
+ src={
+ customDomainEnabled
+ ? `${BASE_PATH}/img/custom-domain-on${
+ resolvedTheme?.includes('dark') ? '' : '--light'
+ }.svg`
+ : `${BASE_PATH}/img/custom-domain-off${
+ resolvedTheme?.includes('dark') ? '' : '--light'
+ }.svg`
+ }
+ />
+ }
+ meta={
+ <div className="flex items-center gap-4">
+ {customDomainEnabled ? (
+ <Badge variant="success">Enabled</Badge>
) : (
- <ProjectUpdateDisabledTooltip
- projectUpdateDisabled={projectUpdateDisabled}
- projectNotActive={!isProjectActive}
- >
- <Button
- type="default"
- className="mt-2 pointer-events-auto"
- onClick={() => setPanel('pitr')}
- disabled={
- !isProjectActive ||
- projectUpdateDisabled ||
- !sufficientPgVersion ||
- hasHipaaAddon
- }
- >
- {!!pitr ? 'Change recovery duration' : 'Enable point in time recovery'}
- </Button>
- </ProjectUpdateDisabledTooltip>
+ <Badge variant="default">Disabled</Badge>
+ )}
+ {!canOpenCustomDomain && customDomainDisabledReason && (
+ <Tooltip>
+ <TooltipTrigger>
+ <Lock strokeWidth={1.5} className="text-foreground-light" size={16} />
+ </TooltipTrigger>
+ <TooltipContent>{customDomainDisabledReason}</TooltipContent>
+ </Tooltip>
)}
</div>
+ }
+ >
+ <div className="space-y-1">
+ <div>Custom domain</div>
+ <p className="m-0 text-foreground-light text-sm">
+ Serve your project on your own domain name.
+ </p>
+ <Link
+ href={`${DOCS_URL}/guides/platform/custom-domains`}
+ target="_blank"
+ rel="noreferrer"
+ className="text-link text-sm"
+ onClick={(event) => event.stopPropagation()}
+ >
+ About custom domains
+ </Link>
</div>
- </ScaffoldSectionContent>
- </ScaffoldSection>
- </ScaffoldContainer>
-
- {projectSettingsCustomDomains && (
- <>
- <ScaffoldDivider />
- <ScaffoldContainer>
- <ScaffoldSection className="!pb-12">
- <ScaffoldSectionDetail>
- <div className="space-y-6">
- <p className="m-0">Custom domain</p>
- <div className="space-y-2">
- <p className="text-sm text-foreground-light m-0">More information</p>
- <div>
- <Link
- href={`${DOCS_URL}/guides/platform/custom-domains`}
- target="_blank"
- rel="noreferrer"
- >
- <div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">
- <p className="text-sm m-0">About custom domains</p>
- <ExternalLink size={16} strokeWidth={1.5} />
- </div>
- </Link>
- </div>
- </div>
- </div>
- </ScaffoldSectionDetail>
- <ScaffoldSectionContent>
- <div className="flex space-x-6">
- <div>
- <div className="rounded-md bg-surface-100 border border-muted w-[160px] h-[96px] overflow-hidden">
- <img
- alt="Custom Domain"
- width={160}
- height={96}
- src={
- customDomain !== undefined
- ? `${BASE_PATH}/img/custom-domain-on${
- resolvedTheme?.includes('dark') ? '' : '--light'
- }.svg`
- : `${BASE_PATH}/img/custom-domain-off${
- resolvedTheme?.includes('dark') ? '' : '--light'
- }.svg`
- }
- />
- </div>
- </div>
- <div>
- <p className="text-sm text-foreground-light">Current option:</p>
- <p>
- {customDomain !== undefined
- ? 'Custom domain is enabled'
- : 'Custom domain is not enabled'}
- </p>
- <div className="mt-2 flex items-center gap-x-2">
- <ProjectUpdateDisabledTooltip
- projectUpdateDisabled={projectUpdateDisabled}
- projectNotActive={!isProjectActive}
- >
- <Button
- type="default"
- className="pointer-events-auto"
- onClick={() => setPanel('customDomain')}
- disabled={!isProjectActive || projectUpdateDisabled}
- >
- {!!customDomain ? 'Toggle custom domain' : 'Enable custom domain'}
- </Button>
- </ProjectUpdateDisabledTooltip>
- {!!customDomain && (
- <Button asChild type="outline">
- <Link href={`/project/${projectRef}/settings/general#custom-domains`}>
- Edit custom domain
- </Link>
- </Button>
- )}
- </div>
- </div>
- </div>
- </ScaffoldSectionContent>
- </ScaffoldSection>
- </ScaffoldContainer>
- </>
- )}
- </>
- )}
+ </ResourceItem>
+ )}
+ </ResourceList>
+ )}
- <PITRSidePanel />
- <CustomDomainSidePanel />
- <IPv4SidePanel />
- </>
+ <PITRSidePanel />
+ <CustomDomainSidePanel />
+ <IPv4SidePanel />
+ </PageSection>
+ </PageContainer>
)
}
diff --git a/apps/studio/components/interfaces/Settings/Addons/Addons.utils.test.ts b/apps/studio/components/interfaces/Settings/Addons/Addons.utils.test.ts
new file mode 100644
index 00000000000..525d3a5f6d4
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/Addons/Addons.utils.test.ts
@@ -0,0 +1,215 @@
+import { describe, expect, it } from 'vitest'
+
+import {
+ getCustomDomainDisabledReason,
+ getIPv4DisabledReason,
+ getPitrAlertState,
+ getPitrDisabledReason,
+} from './Addons.utils'
+
+describe('getIPv4DisabledReason', () => {
+ it('returns the AWS-only message for non-AWS projects', () => {
+ expect(
+ getIPv4DisabledReason({
+ isAws: false,
+ isProjectActive: true,
+ projectUpdateDisabled: false,
+ canUpdateIPv4: true,
+ ipv4Enabled: false,
+ })
+ ).toBe('Dedicated IPv4 address is only available for AWS projects')
+ })
+
+ it('returns the inactive-project message before other checks', () => {
+ expect(
+ getIPv4DisabledReason({
+ isAws: true,
+ isProjectActive: false,
+ projectUpdateDisabled: true,
+ canUpdateIPv4: false,
+ ipv4Enabled: false,
+ })
+ ).toBe('Project must be active to update IPv4')
+ })
+
+ it('returns the updates-disabled message when project updates are blocked', () => {
+ expect(
+ getIPv4DisabledReason({
+ isAws: true,
+ isProjectActive: true,
+ projectUpdateDisabled: true,
+ canUpdateIPv4: true,
+ ipv4Enabled: false,
+ })
+ ).toBe('Project updates are currently disabled')
+ })
+
+ it('returns the IPv6 requirement when IPv4 cannot be added yet', () => {
+ expect(
+ getIPv4DisabledReason({
+ isAws: true,
+ isProjectActive: true,
+ projectUpdateDisabled: false,
+ canUpdateIPv4: false,
+ ipv4Enabled: false,
+ })
+ ).toBe('You can only add IPv4 when your project network configuration is set to IPv6')
+ })
+
+ it('returns undefined when IPv4 is already enabled', () => {
+ expect(
+ getIPv4DisabledReason({
+ isAws: true,
+ isProjectActive: true,
+ projectUpdateDisabled: false,
+ canUpdateIPv4: false,
+ ipv4Enabled: true,
+ })
+ ).toBeUndefined()
+ })
+})
+
+describe('getPitrDisabledReason', () => {
+ it('returns the inactive-project message first', () => {
+ expect(
+ getPitrDisabledReason({
+ isProjectActive: false,
+ projectUpdateDisabled: true,
+ hasHipaaAddon: true,
+ sufficientPgVersion: false,
+ isOrioleDbInAws: true,
+ })
+ ).toBe('Project must be active to update PITR')
+ })
+
+ it('returns the updates-disabled message before feature-specific checks', () => {
+ expect(
+ getPitrDisabledReason({
+ isProjectActive: true,
+ projectUpdateDisabled: true,
+ hasHipaaAddon: true,
+ sufficientPgVersion: false,
+ isOrioleDbInAws: true,
+ })
+ ).toBe('Project updates are currently disabled')
+ })
+
+ it('returns the HIPAA message when HIPAA is enabled', () => {
+ expect(
+ getPitrDisabledReason({
+ isProjectActive: true,
+ projectUpdateDisabled: false,
+ hasHipaaAddon: true,
+ sufficientPgVersion: true,
+ isOrioleDbInAws: false,
+ })
+ ).toBe('PITR cannot be changed with HIPAA enabled')
+ })
+
+ it('returns the legacy-project message when the database version is too old', () => {
+ expect(
+ getPitrDisabledReason({
+ isProjectActive: true,
+ projectUpdateDisabled: false,
+ hasHipaaAddon: false,
+ sufficientPgVersion: false,
+ isOrioleDbInAws: false,
+ })
+ ).toBe('Your project is too old to enable PITR')
+ })
+
+ it('returns the OrioleDB message when PITR is unsupported', () => {
+ expect(
+ getPitrDisabledReason({
+ isProjectActive: true,
+ projectUpdateDisabled: false,
+ hasHipaaAddon: false,
+ sufficientPgVersion: true,
+ isOrioleDbInAws: true,
+ })
+ ).toBe('Point in time recovery is not supported with OrioleDB')
+ })
+
+ it('returns undefined when PITR can be updated', () => {
+ expect(
+ getPitrDisabledReason({
+ isProjectActive: true,
+ projectUpdateDisabled: false,
+ hasHipaaAddon: false,
+ sufficientPgVersion: true,
+ isOrioleDbInAws: false,
+ })
+ ).toBeUndefined()
+ })
+})
+
+describe('getCustomDomainDisabledReason', () => {
+ it('returns the inactive-project message', () => {
+ expect(
+ getCustomDomainDisabledReason({
+ isProjectActive: false,
+ projectUpdateDisabled: true,
+ })
+ ).toBe('Project must be active to update custom domain')
+ })
+
+ it('returns the updates-disabled message when applicable', () => {
+ expect(
+ getCustomDomainDisabledReason({
+ isProjectActive: true,
+ projectUpdateDisabled: true,
+ })
+ ).toBe('Project updates are currently disabled')
+ })
+
+ it('returns undefined when the custom domain panel can be opened', () => {
+ expect(
+ getCustomDomainDisabledReason({
+ isProjectActive: true,
+ projectUpdateDisabled: false,
+ })
+ ).toBeUndefined()
+ })
+})
+
+describe('getPitrAlertState', () => {
+ it('prefers the HIPAA alert over other blocking reasons', () => {
+ expect(
+ getPitrAlertState({
+ hasHipaaAddon: true,
+ sufficientPgVersion: false,
+ isOrioleDbInAws: true,
+ })
+ ).toBe('hipaa')
+ })
+
+ it('returns the legacy-project alert when HIPAA is not enabled', () => {
+ expect(
+ getPitrAlertState({
+ hasHipaaAddon: false,
+ sufficientPgVersion: false,
+ isOrioleDbInAws: true,
+ })
+ ).toBe('legacy-project')
+ })
+
+ it('returns the OrioleDB alert when it is the remaining blocker', () => {
+ expect(
+ getPitrAlertState({
+ hasHipaaAddon: false,
+ sufficientPgVersion: true,
+ isOrioleDbInAws: true,
+ })
+ ).toBe('orioledb')
+ })
+
+ it('returns undefined when no PITR alert is needed', () => {
+ expect(
+ getPitrAlertState({
+ hasHipaaAddon: false,
+ sufficientPgVersion: true,
+ isOrioleDbInAws: false,
+ })
+ ).toBeUndefined()
+ })
+})
diff --git a/apps/studio/components/interfaces/Settings/Addons/Addons.utils.ts b/apps/studio/components/interfaces/Settings/Addons/Addons.utils.ts
new file mode 100644
index 00000000000..95729611108
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/Addons/Addons.utils.ts
@@ -0,0 +1,116 @@
+export interface IPv4DisabledReasonOptions {
+ isAws: boolean
+ isProjectActive: boolean
+ projectUpdateDisabled: boolean
+ canUpdateIPv4: boolean
+ ipv4Enabled: boolean
+}
+
+export const getIPv4DisabledReason = ({
+ isAws,
+ isProjectActive,
+ projectUpdateDisabled,
+ canUpdateIPv4,
+ ipv4Enabled,
+}: IPv4DisabledReasonOptions) => {
+ if (!isAws) {
+ return 'Dedicated IPv4 address is only available for AWS projects'
+ }
+
+ if (!isProjectActive) {
+ return 'Project must be active to update IPv4'
+ }
+
+ if (projectUpdateDisabled) {
+ return 'Project updates are currently disabled'
+ }
+
+ if (!canUpdateIPv4 && !ipv4Enabled) {
+ return 'You can only add IPv4 when your project network configuration is set to IPv6'
+ }
+
+ return undefined
+}
+
+export interface PitrDisabledReasonOptions {
+ isProjectActive: boolean
+ projectUpdateDisabled: boolean
+ hasHipaaAddon: boolean
+ sufficientPgVersion: boolean
+ isOrioleDbInAws: boolean
+}
+
+export const getPitrDisabledReason = ({
+ isProjectActive,
+ projectUpdateDisabled,
+ hasHipaaAddon,
+ sufficientPgVersion,
+ isOrioleDbInAws,
+}: PitrDisabledReasonOptions) => {
+ if (!isProjectActive) {
+ return 'Project must be active to update PITR'
+ }
+
+ if (projectUpdateDisabled) {
+ return 'Project updates are currently disabled'
+ }
+
+ if (hasHipaaAddon) {
+ return 'PITR cannot be changed with HIPAA enabled'
+ }
+
+ if (!sufficientPgVersion) {
+ return 'Your project is too old to enable PITR'
+ }
+
+ if (isOrioleDbInAws) {
+ return 'Point in time recovery is not supported with OrioleDB'
+ }
+
+ return undefined
+}
+
+export interface CustomDomainDisabledReasonOptions {
+ isProjectActive: boolean
+ projectUpdateDisabled: boolean
+}
+
+export const getCustomDomainDisabledReason = ({
+ isProjectActive,
+ projectUpdateDisabled,
+}: CustomDomainDisabledReasonOptions) => {
+ if (!isProjectActive) {
+ return 'Project must be active to update custom domain'
+ }
+
+ if (projectUpdateDisabled) {
+ return 'Project updates are currently disabled'
+ }
+
+ return undefined
+}
+
+export type PitrAlertState = 'hipaa' | 'legacy-project' | 'orioledb' | undefined
+
+export const getPitrAlertState = ({
+ hasHipaaAddon,
+ sufficientPgVersion,
+ isOrioleDbInAws,
+}: Pick<
+ PitrDisabledReasonOptions,
+ 'hasHipaaAddon' | 'sufficientPgVersion' | 'isOrioleDbInAws'
+>) => {
+ if (hasHipaaAddon) {
+ return 'hipaa'
+ }
+
+ if (!sufficientPgVersion) {
+ return 'legacy-project'
+ }
+
+ if (isOrioleDbInAws) {
+ return 'orioledb'
+ }
+
+ return undefined
+}
diff --git a/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx
index 8541721f47e..b17248b2562 100644
--- a/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx
@@ -1,12 +1,12 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useFlag, useParams } from 'common'
+import { UpgradeToPro } from 'components/ui/UpgradeToPro'
import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon-remove-mutation'
import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
import type { AddonVariantId } from 'data/subscriptions/types'
import { useCheckEntitlements } from 'hooks/misc/useCheckEntitlements'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { DOCS_URL } from 'lib/constants'
import { formatCurrency } from 'lib/helpers'
import { AlertCircle } from 'lucide-react'
@@ -15,11 +15,9 @@ import { useEffect, useState } from 'react'
import { toast } from 'sonner'
import { useAddonsPagePanel } from 'state/addons-page'
import {
- Alert,
Alert_Shadcn_,
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
- Button,
cn,
Radio,
SidePanel,
@@ -29,7 +27,6 @@ import { DocsButton } from '@/components/ui/DocsButton'
const CustomDomainSidePanel = () => {
const { ref: projectRef } = useParams()
- const { data: organization } = useSelectedOrganizationQuery()
const customDomainsDisabledDueToQuota = useFlag('customDomainsDisabledDueToQuota')
const [selectedOption, setSelectedOption] = useState<string>('cd_none')
@@ -215,28 +212,19 @@ const CustomDomainSidePanel = () => {
{hasChanges && selectedOption !== 'cd_none' && (
<p className="text-sm text-foreground-light">
- There are no immediate charges. The addon is billed at the end of your billing cycle
+ There are no immediate charges. The add-on is billed at the end of your billing cycle
based on your usage and prorated to the hour.
</p>
)}
{!hasAccessToCustomDomain && (
- <Alert
- withIcon
- variant="info"
- title="Custom domains are unavailable on the Free Plan"
- actions={
- <Button asChild type="default">
- <Link
- href={`/org/${organization?.slug}/billing?panel=subscriptionPlan&source=customDomainSidePanel`}
- >
- View available plans
- </Link>
- </Button>
- }
- >
- Upgrade your plan to add a custom domain to your project
- </Alert>
+ <UpgradeToPro
+ addon="customDomain"
+ source="customDomainSidePanel"
+ featureProposition="enable custom domains"
+ primaryText="Custom domains are a Pro Plan add-on"
+ secondaryText="Enable the add-on to serve your project on your own domain name."
+ />
)}
</div>
</SidePanel.Content>
diff --git a/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx
index a381a9c9326..3d8498e64c2 100644
--- a/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx
@@ -2,27 +2,25 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { DocsButton } from 'components/ui/DocsButton'
import { InlineLink } from 'components/ui/InlineLink'
+import { UpgradeToPro } from 'components/ui/UpgradeToPro'
import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon-remove-mutation'
import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
import type { AddonVariantId } from 'data/subscriptions/types'
import { useCheckEntitlements } from 'hooks/misc/useCheckEntitlements'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useIsAwsCloudProvider } from 'hooks/misc/useSelectedProject'
import { DOCS_URL } from 'lib/constants'
import { formatCurrency } from 'lib/helpers'
-import Link from 'next/link'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
import { useAddonsPagePanel } from 'state/addons-page'
-import { Button, cn, RadioGroup_Shadcn_, RadioGroupLargeItem_Shadcn_, SidePanel } from 'ui'
+import { cn, RadioGroup_Shadcn_, RadioGroupLargeItem_Shadcn_, SidePanel } from 'ui'
import { Admonition } from 'ui-patterns'
const IPv4SidePanel = () => {
const isAws = useIsAwsCloudProvider()
const { ref: projectRef } = useParams()
- const { data: organization } = useSelectedOrganizationQuery()
const [selectedOption, setSelectedOption] = useState<string>('ipv4_none')
@@ -229,16 +227,13 @@ const IPv4SidePanel = () => {
)}
{!hasAccessToIPv4 && (
- <Admonition type="note" title="IPv4 add-on is unavailable on the Free Plan">
- <p>Upgrade your plan to enable an IPv4 address for your project</p>
- <Button asChild type="default">
- <Link
- href={`/org/${organization?.slug}/billing?panel=subscriptionPlan&source=ipv4SidePanel`}
- >
- View available plans
- </Link>
- </Button>
- </Admonition>
+ <UpgradeToPro
+ addon="ipv4"
+ source="ipv4SidePanel"
+ featureProposition="connect from IPv4-only networks"
+ primaryText="Dedicated IPv4 address is a Pro Plan add-on"
+ secondaryText="Enable the add-on to connect to your project from IPv4-only networks."
+ />
)}
</div>
</SidePanel.Content>
diff --git a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
index 0b16d1677e9..4ffcb3234db 100644
--- a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
@@ -321,7 +321,7 @@ const PITRSidePanel = () => {
{hasChanges && selectedOption !== 'pitr_0' && (
<p className="text-sm text-foreground-light">
- There are no immediate charges. The addon is billed at the end of your billing cycle
+ There are no immediate charges. The add-on is billed at the end of your billing cycle
based on your usage and prorated to the hour.
</p>
)}
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx
index 06980dd0218..046cf0e20ee 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx
@@ -26,6 +26,13 @@ export function useProjectSettingsGotoCommands(options?: CommandOptions) {
useRegisterCommands(
COMMAND_MENU_SECTIONS.NAVIGATE,
[
+ {
+ id: 'nav-project-settings-add-ons',
+ name: 'Add-ons',
+ value: 'Add-ons addons add ons add on add-on',
+ route: `/project/${ref}/settings/addons`,
+ defaultHidden: true,
+ },
{
id: 'nav-project-settings-general',
name: 'General Settings',
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
index da1ce946586..50454aba17e 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
@@ -105,7 +105,7 @@ export const useGenerateSettingsMenu = () => {
disabled: !isProjectActive,
},
{
- name: 'Add Ons',
+ name: 'Add-ons',
key: 'addons',
url: `/project/${ref}/settings/addons`,
items: [],
diff --git a/apps/studio/components/ui/RequestUpgradeToBillingOwners.tsx b/apps/studio/components/ui/RequestUpgradeToBillingOwners.tsx
index 5b4bf6735d5..a8f57a2a921 100644
--- a/apps/studio/components/ui/RequestUpgradeToBillingOwners.tsx
+++ b/apps/studio/components/ui/RequestUpgradeToBillingOwners.tsx
@@ -43,7 +43,7 @@ const formId = 'request-upgrade-form'
interface RequestUpgradeToBillingOwnersProps {
block?: boolean
plan?: PlanRequest
- addon?: 'pitr' | 'customDomain' | 'spendCap' | 'computeSize'
+ addon?: 'pitr' | 'customDomain' | 'ipv4' | 'spendCap' | 'computeSize'
/** Used in the default message template, e.g: "Upgrade to ..." */
featureProposition?: string
className?: string
@@ -82,7 +82,13 @@ export const RequestUpgradeToBillingOwners = ({
})
const formattedAddonName =
- addon === 'pitr' ? 'PITR' : addon === 'customDomain' ? 'Custom Domain' : ''
+ addon === 'pitr'
+ ? 'PITR'
+ : addon === 'customDomain'
+ ? 'Custom domain'
+ : addon === 'ipv4'
+ ? 'dedicated IPv4 address'
+ : ''
const target = !!project
? `for the project "${project?.name}"`
diff --git a/apps/studio/components/ui/Resource/ResourceItem.tsx b/apps/studio/components/ui/Resource/ResourceItem.tsx
index 20b35b33e48..4ee3a6debb0 100644
--- a/apps/studio/components/ui/Resource/ResourceItem.tsx
+++ b/apps/studio/components/ui/Resource/ResourceItem.tsx
@@ -32,7 +32,7 @@ export const ResourceItem = forwardRef<HTMLDivElement, ResourceItemProps>(
className={cn(
'flex items-center justify-between text-sm gap-4',
'!border-b-0',
- onClick && 'cursor-pointer hover:bg-surface-200',
+ onClick && 'cursor-pointer transition-colors duration-150 hover:bg-surface-200',
className
)}
onClick={onClick}
diff --git a/apps/studio/components/ui/UpgradePlanButton.tsx b/apps/studio/components/ui/UpgradePlanButton.tsx
index 1842ab7f0e7..5043fe54bf0 100644
--- a/apps/studio/components/ui/UpgradePlanButton.tsx
+++ b/apps/studio/components/ui/UpgradePlanButton.tsx
@@ -19,7 +19,7 @@ interface UpgradePlanButtonProps {
source: string
variant?: 'default' | 'primary'
plan?: 'Pro' | 'Team' | 'Enterprise'
- addon?: 'pitr' | 'customDomain' | 'spendCap' | 'computeSize'
+ addon?: 'pitr' | 'customDomain' | 'ipv4' | 'spendCap' | 'computeSize'
/** Used in the default message template for request upgrade dialog, e.g: "Upgrade to ..." */
featureProposition?: string
disabled?: boolean
diff --git a/apps/studio/components/ui/UpgradeToPro.tsx b/apps/studio/components/ui/UpgradeToPro.tsx
index 4f743c404c0..e7059d417d9 100644
--- a/apps/studio/components/ui/UpgradeToPro.tsx
+++ b/apps/studio/components/ui/UpgradeToPro.tsx
@@ -9,7 +9,7 @@ interface UpgradeToProProps {
primaryText: string
secondaryText: string
plan?: 'Pro' | 'Team' | 'Enterprise'
- addon?: 'pitr' | 'customDomain' | 'spendCap' | 'computeSize'
+ addon?: 'pitr' | 'customDomain' | 'ipv4' | 'spendCap' | 'computeSize'
/** Used in the default message template for request upgrade dialog, e.g: "Upgrade to ..." */
featureProposition?: string
/** As an override for the button text in both upgrade + request to upgrade scenario */
diff --git a/apps/studio/pages/project/[ref]/settings/addons.tsx b/apps/studio/pages/project/[ref]/settings/addons.tsx
index c24befee049..4f81a3fd833 100644
--- a/apps/studio/pages/project/[ref]/settings/addons.tsx
+++ b/apps/studio/pages/project/[ref]/settings/addons.tsx
@@ -1,23 +1,26 @@
import { Addons } from 'components/interfaces/Settings/Addons/Addons'
import DefaultLayout from 'components/layouts/DefaultLayout'
import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'
-import {
- ScaffoldContainer,
- ScaffoldDescription,
- ScaffoldHeader,
- ScaffoldTitle,
-} from 'components/layouts/Scaffold'
import type { NextPageWithLayout } from 'types'
+import {
+ PageHeader,
+ PageHeaderDescription,
+ PageHeaderMeta,
+ PageHeaderSummary,
+ PageHeaderTitle,
+} from 'ui-patterns/PageHeader'
const ProjectAddons: NextPageWithLayout = () => {
return (
<>
- <ScaffoldContainer>
- <ScaffoldHeader>
- <ScaffoldTitle>Add ons</ScaffoldTitle>
- <ScaffoldDescription>Level up your project with add-ons</ScaffoldDescription>
- </ScaffoldHeader>
- </ScaffoldContainer>
+ <PageHeader size="default">
+ <PageHeaderMeta>
+ <PageHeaderSummary>
+ <PageHeaderTitle>Add-ons</PageHeaderTitle>
+ <PageHeaderDescription>Level up your project with add-ons</PageHeaderDescription>
+ </PageHeaderSummary>
+ </PageHeaderMeta>
+ </PageHeader>
<Addons />
</>
)
@@ -25,7 +28,7 @@ const ProjectAddons: NextPageWithLayout = () => {
ProjectAddons.getLayout = (page) => (
<DefaultLayout>
- <SettingsLayout title="Add ons">{page}</SettingsLayout>
+ <SettingsLayout title="Add-ons">{page}</SettingsLayout>
</DefaultLayout>
)
export default ProjectAddons
diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts
index 367fd1cd9f6..06cd6463049 100644
--- a/packages/common/telemetry-constants.ts
+++ b/packages/common/telemetry-constants.ts
@@ -2761,7 +2761,7 @@ export interface RequestUpgradeModalOpenedEvent {
/** Target plan being requested */
requestedPlan: 'Pro' | 'Team' | 'Enterprise'
/** Addon being requested, if applicable */
- addon?: 'pitr' | 'customDomain' | 'spendCap' | 'computeSize'
+ addon?: 'pitr' | 'customDomain' | 'ipv4' | 'spendCap' | 'computeSize'
/** Current organization plan */
currentPlan?: string
/** Feature context driving the upgrade request */
@@ -2782,7 +2782,7 @@ export interface RequestUpgradeSubmittedEvent {
/** Target plan being requested */
requestedPlan: 'Pro' | 'Team' | 'Enterprise'
/** Addon being requested, if applicable */
- addon?: 'pitr' | 'customDomain' | 'spendCap' | 'computeSize'
+ addon?: 'pitr' | 'customDomain' | 'ipv4' | 'spendCap' | 'computeSize'
/** Current organization plan */
currentPlan?: string
}