mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
The current add-ons page only lists a subset of available add-ons, which often causes confusion with things like Advanced MFA Auth (customers cant find where to configure it). The revised add-on page covers all potentially configured project add-ons including replicas and advanced disk. This should help the customer locate configured add-ons and at the same time discover potentially interesting add-ons. This can be enhanced further in the future with "smart" suggestions based on usage.
591 lines
21 KiB
TypeScript
591 lines
21 KiB
TypeScript
import { Link } from '@tanstack/react-router'
|
|
import { useFlag, useParams } from 'common'
|
|
import {
|
|
CopyIcon,
|
|
CpuIcon,
|
|
GlobeIcon,
|
|
HardDriveIcon,
|
|
HistoryIcon,
|
|
LinkIcon,
|
|
MessageSquareLockIcon,
|
|
ScrollTextIcon,
|
|
WorkflowIcon,
|
|
} from 'lucide-react'
|
|
import { Fragment, type ReactNode } from 'react'
|
|
import { Button } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
import { PageContainer } from 'ui-patterns/PageContainer'
|
|
import {
|
|
PageSection,
|
|
PageSectionContent,
|
|
PageSectionMeta,
|
|
PageSectionSummary,
|
|
PageSectionTitle,
|
|
} from 'ui-patterns/PageSection'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { AddonCategory, AddonRow, type AddonRowProps } from './AddonRow'
|
|
import {
|
|
countActiveDatabases,
|
|
countReadReplicas,
|
|
formatMonthlyAddonPrice,
|
|
getActiveCountLabel,
|
|
getAdvancedDiskDetail,
|
|
getCustomDomainDisabledReason,
|
|
getIPv4DisabledReason,
|
|
getLowestPaidPrice,
|
|
getPitrAlertState,
|
|
getPitrDisabledReason,
|
|
isAdvancedDiskEnabled,
|
|
isComputeAddonEnabled,
|
|
LOG_DRAIN_PRICE_LABEL,
|
|
PIPELINES_PRICE_LABEL,
|
|
SMS_MFA_PRICE_LABEL,
|
|
} from './Addons.utils'
|
|
import CustomDomainSidePanel from './CustomDomainSidePanel'
|
|
import IPv4SidePanel from './IPv4SidePanel'
|
|
import { PitrAlert } from './PitrAlert'
|
|
import PITRSidePanel from './PITRSidePanel'
|
|
import {
|
|
countSelectedAddons,
|
|
getAddons,
|
|
subscriptionHasHipaaAddon,
|
|
} from '@/components/interfaces/Billing/Subscription/Subscription.utils'
|
|
import { formatRoundedCurrency } from '@/components/interfaces/Organization/BillingSettings/Subscription/PlanChangeSummary.utils'
|
|
import { getMonthlyComputePrice } from '@/components/interfaces/Project/ResumeProjectCost.utils'
|
|
import { AlertError } from '@/components/ui/AlertError'
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import { HighAvailabilityDisabledSectionNotice } from '@/components/ui/HighAvailability/HighAvailabilityDisabledSectionNotice'
|
|
import { InlineLink } from '@/components/ui/InlineLink'
|
|
import { ResourceList } from '@/components/ui/Resource/ResourceList'
|
|
import { HorizontalShimmerWithIcon } from '@/components/ui/Shimmers'
|
|
import { UpgradeToPro } from '@/components/ui/UpgradeToPro'
|
|
import { useAuthConfigQuery } from '@/data/auth/auth-config-query'
|
|
import { useDiskAttributesQuery } from '@/data/config/disk-attributes-query'
|
|
import { useProjectSettingsV2Query } from '@/data/config/project-settings-v2-query'
|
|
import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
|
|
import { useOrgSubscriptionQuery } from '@/data/subscriptions/org-subscription-query'
|
|
import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
|
import {
|
|
useIsAwsCloudProvider,
|
|
useIsHighAvailability,
|
|
useIsOrioleDbInAws,
|
|
useIsProjectActive,
|
|
useSelectedProjectQuery,
|
|
} from '@/hooks/misc/useSelectedProject'
|
|
import { getComputeSizeLabel } from '@/lib/compute-labels'
|
|
import { DOCS_URL } from '@/lib/constants'
|
|
import { getDatabaseMajorVersion, getSemanticVersion } from '@/lib/helpers'
|
|
import { useAddonsPagePanel } from '@/state/addons-page'
|
|
|
|
const ADDON_GROUPS = ['Networking', 'Database', 'Observability', 'Auth'] as const
|
|
const FREE_PLAN_REASON = 'Upgrade to Pro to configure add-ons'
|
|
|
|
type AddonGroup = (typeof ADDON_GROUPS)[number]
|
|
|
|
type AddonDestination =
|
|
| '/project/$ref/settings/infrastructure'
|
|
| '/project/$ref/database/pipelines'
|
|
| '/project/$ref/settings/log-drains'
|
|
| '/project/$ref/auth/mfa'
|
|
|
|
type AddonAction =
|
|
| { type: 'panel'; disabledReason?: string; onClick: () => void }
|
|
| { type: 'link'; to: AddonDestination; hash?: string }
|
|
|
|
type AddonEntry = Omit<AddonRowProps, 'action'> & {
|
|
id: string
|
|
group: AddonGroup
|
|
action: AddonAction
|
|
footer?: ReactNode
|
|
}
|
|
|
|
/** Maps a query to AddonRow loading/error props. Failed reads without cached data surface as errors, not inactive. */
|
|
const getReadState = (query: { isLoading: boolean; isError: boolean; data: unknown }) => ({
|
|
isLoading: query.isLoading,
|
|
isError: query.isError && query.data === undefined,
|
|
})
|
|
|
|
const AddonActionButton = ({
|
|
action,
|
|
isFreePlan,
|
|
projectRef,
|
|
}: {
|
|
action: AddonAction
|
|
isFreePlan: boolean
|
|
projectRef?: string
|
|
}) => {
|
|
if (action.type === 'panel') {
|
|
const disabledReason = isFreePlan ? FREE_PLAN_REASON : action.disabledReason
|
|
return (
|
|
<ButtonTooltip
|
|
size="tiny"
|
|
disabled={Boolean(disabledReason)}
|
|
onClick={action.onClick}
|
|
tooltip={{ content: { side: 'bottom', text: disabledReason } }}
|
|
>
|
|
Configure
|
|
</ButtonTooltip>
|
|
)
|
|
}
|
|
|
|
if (isFreePlan) {
|
|
return (
|
|
<ButtonTooltip
|
|
size="tiny"
|
|
disabled
|
|
tooltip={{ content: { side: 'bottom', text: FREE_PLAN_REASON } }}
|
|
>
|
|
Configure
|
|
</ButtonTooltip>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Button asChild size="tiny">
|
|
<Link to={action.to} params={{ ref: projectRef ?? '' }} hash={action.hash}>
|
|
Configure
|
|
</Link>
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
const AddonsLoadingSkeleton = () => (
|
|
<PageSection>
|
|
<PageSectionContent>
|
|
<ResourceList>
|
|
{Array.from({ length: 3 }).map((_, index) => (
|
|
<div key={index} className="flex items-center gap-3 border-b px-4 py-3 last:border-b-0">
|
|
<ShimmeringLoader className="size-8 shrink-0 rounded-lg py-0" />
|
|
<div className="flex-1">
|
|
<HorizontalShimmerWithIcon />
|
|
</div>
|
|
</div>
|
|
))}
|
|
</ResourceList>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)
|
|
|
|
const AddonsBillingSidebar = ({
|
|
isFreePlan,
|
|
orgSlug,
|
|
}: {
|
|
isFreePlan: boolean
|
|
orgSlug?: string
|
|
}) => (
|
|
<aside aria-label="Billing" className="flex flex-col gap-3 @4xl:pt-12">
|
|
<div className="flex flex-col gap-1">
|
|
<h2 className="text-sm text-foreground">Billed by the hour</h2>
|
|
<p className="text-sm text-foreground-light">
|
|
Add-ons are charged with your plan at the end of each billing cycle. Remove one and you stop
|
|
paying for it.
|
|
</p>
|
|
</div>
|
|
{/* The upcoming invoice breakdown only renders for paid plans */}
|
|
<Link
|
|
to="/org/$slug/billing"
|
|
params={{ slug: orgSlug ?? '_' }}
|
|
hash={isFreePlan ? undefined : 'breakdown'}
|
|
className="text-link self-start text-sm"
|
|
>
|
|
{isFreePlan ? 'Organization billing' : 'View upcoming invoice'}
|
|
</Link>
|
|
</aside>
|
|
)
|
|
|
|
export const Addons = () => {
|
|
const { ref: projectRef } = useParams()
|
|
const { setPanel } = useAddonsPagePanel()
|
|
const isAws = useIsAwsCloudProvider()
|
|
const isProjectActive = useIsProjectActive()
|
|
const isOrioleDbInAws = useIsOrioleDbInAws() === true
|
|
const isHighAvailability = useIsHighAvailability()
|
|
|
|
const {
|
|
projectSettingsCustomDomains,
|
|
projectAddonsDedicatedIpv4Address,
|
|
projectSettingsLogDrains,
|
|
databaseReplication,
|
|
infrastructureReadReplicas,
|
|
} = useIsFeatureEnabled([
|
|
'project_settings:custom_domains',
|
|
'project_addons:dedicated_ipv4_address',
|
|
'project_settings:log_drains',
|
|
'database:replication',
|
|
'infrastructure:read_replicas',
|
|
])
|
|
|
|
const { data: selectedOrg } = useSelectedOrganizationQuery()
|
|
const { data: selectedProject } = useSelectedProjectQuery()
|
|
const parentProjectRef = selectedProject?.parent_project_ref
|
|
const isFreePlan = selectedOrg?.plan?.id === 'free'
|
|
|
|
const { data: settings } = useProjectSettingsV2Query({ projectRef })
|
|
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: selectedOrg?.slug })
|
|
|
|
const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')
|
|
const hasHipaaAddon = subscriptionHasHipaaAddon(subscription) && settings?.is_sensitive === true
|
|
|
|
// Only projects of version greater than supabase-postgrest-14.1.0.44 can use PITR
|
|
const hasSufficientPgVersion =
|
|
// introduced as generatedSemantic version could be < 141044 even if actual version is indeed past it
|
|
// eg. 15.1.1.2 leads to 15112
|
|
getDatabaseMajorVersion(selectedProject?.dbVersion ?? '') > 14 ||
|
|
getSemanticVersion(selectedProject?.dbVersion ?? '') >= 141044
|
|
|
|
const {
|
|
data: addons,
|
|
error,
|
|
isPending: isLoading,
|
|
isError,
|
|
isSuccess,
|
|
} = useProjectAddonsQuery({ projectRef })
|
|
|
|
const selectedAddons = addons?.selected_addons ?? []
|
|
const availableAddons = addons?.available_addons ?? []
|
|
const { pitr, customDomain, ipv4, computeInstance } = getAddons(selectedAddons)
|
|
|
|
// These add-ons are configured on their own pages, so we only read their state here
|
|
const replicasQuery = useReadReplicasQuery(
|
|
{ projectRef },
|
|
{ enabled: infrastructureReadReplicas }
|
|
)
|
|
const diskQuery = useDiskAttributesQuery({ projectRef }, { enabled: isAws })
|
|
const authConfigQuery = useAuthConfigQuery({ projectRef })
|
|
|
|
const advancedDiskEnabled = isAdvancedDiskEnabled(diskQuery.data?.attributes)
|
|
const replicaCount = countReadReplicas(replicasQuery.data ?? [], projectRef)
|
|
// Each database, including read replicas, gets its own IPv4 address and is billed for it
|
|
const activeDatabaseCount = countActiveDatabases(replicasQuery.data ?? [], projectRef)
|
|
// Log drains and pipelines are billed per instance, so the project's add-ons carry their counts
|
|
const logDrainCount = countSelectedAddons(selectedAddons, 'log_drain')
|
|
const pipelineCount = countSelectedAddons(selectedAddons, 'etl_pipeline')
|
|
const computeSize = computeInstance?.variant.identifier
|
|
const computeEnabled = isComputeAddonEnabled(computeSize)
|
|
const computeDetail =
|
|
computeEnabled && computeInstance
|
|
? `${formatRoundedCurrency(getMonthlyComputePrice(computeInstance.variant))} / month`
|
|
: 'from $5.00 / month'
|
|
const smsMfaEnabled =
|
|
authConfigQuery.data?.MFA_PHONE_ENROLL_ENABLED === true ||
|
|
authConfigQuery.data?.MFA_PHONE_VERIFY_ENABLED === true
|
|
|
|
const canUpdateIPv4 = settings?.db_ip_addr_config === 'ipv6'
|
|
const ipv4Enabled = ipv4 !== undefined
|
|
const pitrEnabled = pitr !== undefined
|
|
const customDomainEnabled = customDomain !== undefined
|
|
|
|
// HIPAA projects must have 28-day PITR. Once enabled it is locked; until then it can be enabled.
|
|
const hasHipaaCompliantPitr = pitr?.variant.identifier === 'pitr_28'
|
|
const isPitrLockedByHipaa = hasHipaaAddon && hasHipaaCompliantPitr
|
|
|
|
const ipv4DisabledReason = getIPv4DisabledReason({
|
|
isAws,
|
|
isProjectActive,
|
|
projectUpdateDisabled,
|
|
canUpdateIPv4,
|
|
ipv4Enabled,
|
|
isHighAvailability,
|
|
})
|
|
const pitrDisabledReason = getPitrDisabledReason({
|
|
isProjectActive,
|
|
projectUpdateDisabled,
|
|
hasHipaaAddon: isPitrLockedByHipaa,
|
|
sufficientPgVersion: hasSufficientPgVersion,
|
|
isOrioleDbInAws,
|
|
isHighAvailability,
|
|
})
|
|
const customDomainDisabledReason = getCustomDomainDisabledReason({
|
|
isProjectActive,
|
|
projectUpdateDisabled,
|
|
isHighAvailability,
|
|
})
|
|
const pitrAlertState = getPitrAlertState({
|
|
hasHipaaAddon,
|
|
hasHipaaCompliantPitr,
|
|
sufficientPgVersion: hasSufficientPgVersion,
|
|
isOrioleDbInAws,
|
|
})
|
|
|
|
const lowestIpv4Price = getLowestPaidPrice(availableAddons, 'ipv4')
|
|
const lowestCustomDomainPrice = getLowestPaidPrice(availableAddons, 'custom_domain')
|
|
const lowestPitrPrice = getLowestPaidPrice(availableAddons, 'pitr')
|
|
|
|
const allEntries: Array<AddonEntry | false> = [
|
|
projectAddonsDedicatedIpv4Address && {
|
|
id: 'ipv4',
|
|
group: 'Networking',
|
|
icon: GlobeIcon,
|
|
title: 'Dedicated IPv4 address',
|
|
description: 'Reserve a dedicated IPv4 address for your project.',
|
|
docsUrl: `${DOCS_URL}/guides/platform/ipv4-address`,
|
|
isEnabled: ipv4Enabled,
|
|
status: ipv4Enabled ? 'Enabled' : undefined,
|
|
detail: ipv4Enabled
|
|
? formatMonthlyAddonPrice(ipv4.variant.price * activeDatabaseCount)
|
|
: formatMonthlyAddonPrice(lowestIpv4Price, 'from '),
|
|
action: {
|
|
type: 'panel',
|
|
disabledReason: ipv4DisabledReason,
|
|
onClick: () => setPanel('ipv4'),
|
|
},
|
|
},
|
|
projectSettingsCustomDomains && {
|
|
id: 'custom-domain',
|
|
group: 'Networking',
|
|
icon: LinkIcon,
|
|
title: 'Custom domain',
|
|
description: 'Serve your project on your own domain name.',
|
|
docsUrl: `${DOCS_URL}/guides/platform/custom-domains`,
|
|
isEnabled: customDomainEnabled,
|
|
status: customDomainEnabled ? 'Enabled' : undefined,
|
|
detail: customDomainEnabled
|
|
? formatMonthlyAddonPrice(customDomain.variant.price)
|
|
: formatMonthlyAddonPrice(lowestCustomDomainPrice),
|
|
action: {
|
|
type: 'panel',
|
|
disabledReason: customDomainDisabledReason,
|
|
onClick: () => setPanel('customDomain'),
|
|
},
|
|
},
|
|
{
|
|
id: 'compute',
|
|
group: 'Database',
|
|
icon: CpuIcon,
|
|
title: 'Compute size',
|
|
description: 'Choose the CPU and memory available to your database.',
|
|
docsUrl: `${DOCS_URL}/guides/platform/compute-and-disk`,
|
|
isEnabled: computeEnabled,
|
|
status: computeEnabled
|
|
? `${getComputeSizeLabel(computeSize) ?? 'Custom'} Compute`
|
|
: undefined,
|
|
detail: computeDetail,
|
|
action: {
|
|
type: 'link',
|
|
to: '/project/$ref/settings/infrastructure',
|
|
hash: 'compute',
|
|
},
|
|
},
|
|
infrastructureReadReplicas && {
|
|
id: 'read-replicas',
|
|
group: 'Database',
|
|
icon: CopyIcon,
|
|
title: 'Read replicas',
|
|
description: 'Deploy read-only copies of your database across regions.',
|
|
docsUrl: `${DOCS_URL}/guides/platform/read-replicas`,
|
|
isEnabled: replicaCount > 0,
|
|
...getReadState(replicasQuery),
|
|
status: replicaCount > 0 ? getActiveCountLabel(replicaCount) : undefined,
|
|
detail: 'Billed per replica',
|
|
action: {
|
|
type: 'link',
|
|
to: '/project/$ref/settings/infrastructure',
|
|
hash: 'read-replicas',
|
|
},
|
|
},
|
|
{
|
|
id: 'pitr',
|
|
group: 'Database',
|
|
icon: HistoryIcon,
|
|
title: 'Point in time recovery',
|
|
description: 'Restore your database to a specific moment in the past.',
|
|
docsUrl: `${DOCS_URL}/guides/platform/backups#point-in-time-recovery`,
|
|
isEnabled: pitrEnabled,
|
|
status: pitrEnabled ? 'Enabled' : undefined,
|
|
detail: pitrEnabled
|
|
? formatMonthlyAddonPrice(pitr.variant.price)
|
|
: formatMonthlyAddonPrice(lowestPitrPrice, 'from '),
|
|
action: {
|
|
type: 'panel',
|
|
disabledReason: pitrDisabledReason,
|
|
onClick: () => setPanel('pitr'),
|
|
},
|
|
footer: (
|
|
<PitrAlert
|
|
state={pitrAlertState}
|
|
projectRef={projectRef}
|
|
disabledReason={pitrDisabledReason}
|
|
onEnablePitr={() => setPanel('pitr')}
|
|
/>
|
|
),
|
|
},
|
|
isAws && {
|
|
id: 'advanced-disk',
|
|
group: 'Database',
|
|
icon: HardDriveIcon,
|
|
title: 'Advanced Disk',
|
|
description: 'Provision IOPS and throughput, or configure a high-performance disk.',
|
|
docsUrl: `${DOCS_URL}/guides/platform/compute-and-disk#disk`,
|
|
isEnabled: advancedDiskEnabled,
|
|
...getReadState(diskQuery),
|
|
status: advancedDiskEnabled ? 'Enabled' : undefined,
|
|
detail: getAdvancedDiskDetail(diskQuery.data?.attributes),
|
|
action: {
|
|
type: 'link',
|
|
to: '/project/$ref/settings/infrastructure',
|
|
hash: 'advanced',
|
|
},
|
|
},
|
|
databaseReplication && {
|
|
id: 'pipelines',
|
|
group: 'Database',
|
|
icon: WorkflowIcon,
|
|
title: 'Pipelines',
|
|
description: 'Replicate database changes to external destinations.',
|
|
docsUrl: `${DOCS_URL}/guides/database/replication/pipelines`,
|
|
isEnabled: pipelineCount > 0,
|
|
status: pipelineCount > 0 ? getActiveCountLabel(pipelineCount) : undefined,
|
|
detail: PIPELINES_PRICE_LABEL,
|
|
action: {
|
|
type: 'link',
|
|
to: '/project/$ref/database/pipelines',
|
|
},
|
|
},
|
|
projectSettingsLogDrains && {
|
|
id: 'log-drains',
|
|
group: 'Observability',
|
|
icon: ScrollTextIcon,
|
|
title: 'Log drains',
|
|
description: 'Send your project logs to external destinations.',
|
|
docsUrl: `${DOCS_URL}/guides/telemetry/log-drains`,
|
|
isEnabled: logDrainCount > 0,
|
|
status: logDrainCount > 0 ? getActiveCountLabel(logDrainCount) : undefined,
|
|
detail: LOG_DRAIN_PRICE_LABEL,
|
|
action: {
|
|
type: 'link',
|
|
to: '/project/$ref/settings/log-drains',
|
|
},
|
|
},
|
|
{
|
|
id: 'sms-mfa',
|
|
group: 'Auth',
|
|
icon: MessageSquareLockIcon,
|
|
title: 'Advanced Multi-Factor Auth - SMS',
|
|
description: 'Let users verify sign-ins with a code sent by SMS.',
|
|
docsUrl: `${DOCS_URL}/guides/auth/auth-mfa/phone`,
|
|
isEnabled: smsMfaEnabled,
|
|
...getReadState(authConfigQuery),
|
|
status: smsMfaEnabled ? 'Enabled' : undefined,
|
|
detail: SMS_MFA_PRICE_LABEL,
|
|
action: {
|
|
type: 'link',
|
|
to: '/project/$ref/auth/mfa',
|
|
hash: 'sms-mfa',
|
|
},
|
|
},
|
|
]
|
|
const entries = allEntries.filter((entry): entry is AddonEntry => entry !== false)
|
|
|
|
const activeEntries = entries.filter((entry) => entry.isEnabled)
|
|
const availableGroups = ADDON_GROUPS.map((group) => ({
|
|
group,
|
|
entries: entries.filter((entry) => entry.group === group && !entry.isEnabled),
|
|
})).filter(({ entries: groupEntries }) => groupEntries.length > 0)
|
|
|
|
const renderEntry = ({ id, group: _group, action, footer, ...rowProps }: AddonEntry) => (
|
|
<Fragment key={id}>
|
|
<AddonRow
|
|
{...rowProps}
|
|
action={
|
|
<AddonActionButton action={action} isFreePlan={isFreePlan} projectRef={projectRef} />
|
|
}
|
|
/>
|
|
{footer}
|
|
</Fragment>
|
|
)
|
|
|
|
return (
|
|
<PageContainer size="default">
|
|
<div className="grid pb-16 @4xl:grid-cols-[minmax(0,1fr)_15rem] @4xl:gap-x-12">
|
|
<div className="min-w-0">
|
|
<div className="flex flex-col gap-4 pt-12 empty:hidden">
|
|
{isFreePlan && (
|
|
<UpgradeToPro
|
|
primaryText="Upgrade to Pro to use add-ons"
|
|
secondaryText="Add-ons aren't available on the Free plan. Upgrade to configure compute, backups, networking and more."
|
|
source="addons"
|
|
/>
|
|
)}
|
|
<HighAvailabilityDisabledSectionNotice
|
|
title="Add-ons unavailable on High Availability projects"
|
|
description="We're working to bring add-ons to High Availability projects. Contact support if this is blocking your work."
|
|
/>
|
|
{parentProjectRef && (
|
|
<Admonition
|
|
type="default"
|
|
title="You are currently on a preview branch of your project"
|
|
>
|
|
Updating add-ons here will only apply to this preview branch. To manage add-ons for
|
|
your main branch, please visit the{' '}
|
|
<InlineLink href={`/project/${parentProjectRef}/settings/addons`}>
|
|
main branch
|
|
</InlineLink>
|
|
.
|
|
</Admonition>
|
|
)}
|
|
</div>
|
|
|
|
{/* Always mounted so screen readers register the region before its text changes */}
|
|
<div role="status" aria-live="polite" className="sr-only">
|
|
{isSuccess &&
|
|
`Add-ons loaded. ${activeEntries.length} ${activeEntries.length === 1 ? 'add-on' : 'add-ons'} active.`}
|
|
</div>
|
|
|
|
{isLoading && <AddonsLoadingSkeleton />}
|
|
|
|
{isError && (
|
|
<PageSection>
|
|
<PageSectionContent>
|
|
<AlertError error={error} subject="Failed to retrieve project add-ons" />
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)}
|
|
|
|
{isSuccess && activeEntries.length > 0 && (
|
|
<PageSection>
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Active</PageSectionTitle>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent>
|
|
<ResourceList>{activeEntries.map(renderEntry)}</ResourceList>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)}
|
|
|
|
{isSuccess && availableGroups.length > 0 && (
|
|
<PageSection>
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Available</PageSectionTitle>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent className="flex flex-col gap-4">
|
|
{availableGroups.map(({ group, entries: groupEntries }) => (
|
|
<AddonCategory key={group} label={group}>
|
|
{groupEntries.map(renderEntry)}
|
|
</AddonCategory>
|
|
))}
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)}
|
|
</div>
|
|
|
|
<AddonsBillingSidebar isFreePlan={isFreePlan} orgSlug={selectedOrg?.slug} />
|
|
</div>
|
|
|
|
{!isHighAvailability && (
|
|
<>
|
|
<PITRSidePanel />
|
|
<CustomDomainSidePanel />
|
|
<IPv4SidePanel />
|
|
</>
|
|
)}
|
|
</PageContainer>
|
|
)
|
|
}
|