The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add warnings for CPU and RAM in Infrastructure and INfrastructureActivity, and fix link from UsageWarningBanner chekc usage CTA
Joshen Lim5240b741d9b7
diff --git a/studio/components/interfaces/BillingV2/Subscription/AddOns/AddOns.tsx b/studio/components/interfaces/BillingV2/Subscription/AddOns/AddOns.tsxindex 3d7c6d34e0d..444317ed056 100644--- a/studio/components/interfaces/BillingV2/Subscription/AddOns/AddOns.tsx+++ b/studio/components/interfaces/BillingV2/Subscription/AddOns/AddOns.tsx@@ -22,9 +22,7 @@ import {} from 'components/layouts/ProjectLayout/ProjectContext'import { getCloudProviderArchitecture } from 'lib/cloudprovider-utils'-export interface AddOnsProps {}--const AddOns = ({}: AddOnsProps) => {+const AddOns = () => {const { ref: projectRef } = useParams()const snap = useSubscriptionPageStateSnapshot()const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')diff --git a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsxindex 60d929e28fb..2789f1e139b 100644--- a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx@@ -14,6 +14,7 @@ import { USAGE_CATEGORIES } from './Usage.constants'import { getUpgradeUrl } from './Usage.utils'import UsageBarChart from './UsageBarChart'import { CPUWarnings, DiskIOBandwidthWarnings, RAMWarnings } from './UsageWarningAlerts'+import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'export interface InfrastructureProps {projectRef: string@@ -29,10 +30,12 @@ const Infrastructure = ({currentBillingCycleSelected,}: InfrastructureProps) => {const { data: subscription } = useProjectSubscriptionV2Query({ projectRef })+ const { data: resourceWarnings } = useResourceWarningsQuery()+ const projectResourceWarnings = resourceWarnings?.find((x) => x.project === projectRef)const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === 'infra')const upgradeUrl = getUpgradeUrl(projectRef, subscription)- const isFreeTier = subscription?.plan?.id === 'free'+ const isFreePlan = subscription?.plan?.id === 'free'const { data: addons, isLoading } = useProjectAddonsQuery({ projectRef })const selectedAddons = addons?.selected_addons ?? []@@ -127,7 +130,7 @@ const Infrastructure = ({<><DiskIOBandwidthWarningsupgradeUrl={upgradeUrl}- isFreeTier={isFreeTier}+ isFreePlan={isFreePlan}hasLatest={hasLatest}currentBillingCycleSelected={currentBillingCycleSelected}latestIoBudgetConsumption={latestIoBudgetConsumption}@@ -180,10 +183,20 @@ const Infrastructure = ({</>)}{attribute.key === 'max_cpu_usage' && (- <CPUWarnings isFreeTier={isFreeTier} upgradeUrl={upgradeUrl} />+ <CPUWarnings+ isFreePlan={isFreePlan}+ upgradeUrl={upgradeUrl}+ isBeyondThreshold={projectResourceWarnings?.is_cpu_load_beyond_threshold ?? false}+ />)}{attribute.key === 'ram_usage' && (- <RAMWarnings isFreeTier={isFreeTier} upgradeUrl={upgradeUrl} />+ <RAMWarnings+ isFreePlan={isFreePlan}+ upgradeUrl={upgradeUrl}+ isBeyondThreshold={+ projectResourceWarnings?.is_memory_and_swap_usage_beyond_threshold ?? false+ }+ />)}<div className="space-y-1">diff --git a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/CPUWarnings.tsx b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/CPUWarnings.tsxindex fe6a94f102d..818e649f4ac 100644--- a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/CPUWarnings.tsx+++ b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/CPUWarnings.tsx@@ -3,13 +3,15 @@ import Link from 'next/link'import { AlertDescription_Shadcn_, Alert_Shadcn_, Button, IconAlertCircle } from 'ui'interface CPUWarningsProps {- isFreeTier: boolean+ isFreePlan: booleanupgradeUrl: string+ isBeyondThreshold: boolean}-const CPUWarnings = ({ isFreeTier, upgradeUrl }: CPUWarningsProps) => {- // [Joshen TODO] Need to implement the necessary conditionals for rendering the warnings- const isApproaching = false+const CPUWarnings = ({ isFreePlan, upgradeUrl, isBeyondThreshold }: CPUWarningsProps) => {+ // [Joshen TODO] Need to implement the necessary conditionals for rendering the warnings once+ // endpoint is updated to return text instead of boolean+ const isApproaching = isBeyondThresholdconst isExceeded = falseif (isApproaching) {@@ -18,8 +20,8 @@ const CPUWarnings = ({ isFreeTier, upgradeUrl }: CPUWarningsProps) => {<IconAlertCircle /><AlertTitle>Your max CPU usage has exceeded 80%</AlertTitle><AlertDescription_Shadcn_>- High CPU usage could result in slower queries, disruption of daily back routines, and in- rare cases, your instance may become unresponsive. If you need more resources, consider+ High CPU usage could result in slower queries, disruption of daily back up routines, and+ in rare cases, your instance may become unresponsive. If you need more resources, considerupgrading to a larger compute add-on.</AlertDescription_Shadcn_><div className="mt-3 flex items-center space-x-2">@@ -31,7 +33,7 @@ const CPUWarnings = ({ isFreeTier, upgradeUrl }: CPUWarningsProps) => {<Link href={upgradeUrl}><a><Button type="warning">- {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}+ {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}</Button></a></Link>@@ -46,8 +48,8 @@ const CPUWarnings = ({ isFreeTier, upgradeUrl }: CPUWarningsProps) => {<IconAlertCircle /><AlertTitle>Your max CPU usage has reached 100%</AlertTitle><AlertDescription_Shadcn_>- High CPU usage could result in slower queries, disruption of daily back routines, and in- rare cases, your instance may become unresponsive. If you need more resources, consider+ High CPU usage could result in slower queries, disruption of daily back up routines, and+ in rare cases, your instance may become unresponsive. If you need more resources, considerupgrading to a larger compute add-on.</AlertDescription_Shadcn_><div className="mt-3 flex items-center space-x-2">@@ -59,7 +61,7 @@ const CPUWarnings = ({ isFreeTier, upgradeUrl }: CPUWarningsProps) => {<Link href={upgradeUrl}><a><Button type="danger">- {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}+ {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}</Button></a></Link>diff --git a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/DiskIOBandwidthWarnings.tsx b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/DiskIOBandwidthWarnings.tsxindex 0d092e75878..6d257ac3f10 100644--- a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/DiskIOBandwidthWarnings.tsx+++ b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/DiskIOBandwidthWarnings.tsx@@ -3,7 +3,7 @@ import { Alert, Button } from 'ui'// [Joshen] In the future, conditionals should be from resource exhaustion endpoint as single source of truthinterface DiskIOBandwidthWarningsProps {- isFreeTier: boolean+ isFreePlan: booleanhasLatest: booleanupgradeUrl: stringcurrentBillingCycleSelected: boolean@@ -12,7 +12,7 @@ interface DiskIOBandwidthWarningsProps {}const DiskIOBandwidthWarnings = ({- isFreeTier,+ isFreePlan,hasLatest,currentBillingCycleSelected,upgradeUrl,@@ -30,7 +30,7 @@ const DiskIOBandwidthWarnings = ({<Link href={upgradeUrl}><a><Button type="danger">- {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}+ {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}</Button></a></Link>@@ -49,7 +49,7 @@ const DiskIOBandwidthWarnings = ({<Link href={upgradeUrl}><a><Button type="danger">- {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}+ {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}</Button></a></Link>@@ -68,7 +68,7 @@ const DiskIOBandwidthWarnings = ({<Link href={upgradeUrl}><a><Button type="warning">- {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}+ {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}</Button></a></Link>@@ -92,7 +92,7 @@ const DiskIOBandwidthWarnings = ({<Link href={upgradeUrl}><a><Button type="warning">- {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}+ {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}</Button></a></Link>diff --git a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/RAMWarnings.tsx b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/RAMWarnings.tsxindex 0a106669311..8006c3d079d 100644--- a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/RAMWarnings.tsx+++ b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/RAMWarnings.tsx@@ -3,13 +3,15 @@ import Link from 'next/link'import { AlertDescription_Shadcn_, Alert_Shadcn_, Button, IconAlertCircle } from 'ui'interface RAMWarningsProps {- isFreeTier: boolean+ isFreePlan: booleanupgradeUrl: string+ isBeyondThreshold: boolean}-// [Joshen TODO] Need to implement the necessary conditionals for rendering the warnings-const RAMWarnings = ({ isFreeTier, upgradeUrl }: RAMWarningsProps) => {- const isApproaching = true+const RAMWarnings = ({ isFreePlan, upgradeUrl, isBeyondThreshold }: RAMWarningsProps) => {+ // [Joshen TODO] Need to implement the necessary conditionals for rendering the warnings once+ // endpoint is updated to return text instead of boolean+ const isApproaching = isBeyondThresholdconst isExceeded = falseif (isApproaching) {@@ -31,7 +33,7 @@ const RAMWarnings = ({ isFreeTier, upgradeUrl }: RAMWarningsProps) => {<Link href={upgradeUrl}><a><Button type="warning">- {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}+ {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}</Button></a></Link>@@ -59,7 +61,7 @@ const RAMWarnings = ({ isFreeTier, upgradeUrl }: RAMWarningsProps) => {<Link href={upgradeUrl}><a><Button type="danger">- {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}+ {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}</Button></a></Link>diff --git a/studio/components/interfaces/Settings/Addons/Addons.tsx b/studio/components/interfaces/Settings/Addons/Addons.tsxindex 88035a87b70..edff68aac31 100644--- a/studio/components/interfaces/Settings/Addons/Addons.tsx+++ b/studio/components/interfaces/Settings/Addons/Addons.tsx@@ -134,14 +134,14 @@ const Addons = () => {<ScaffoldSection><ScaffoldSectionDetail><div className="space-y-6">- <p>Optimized compute</p>+ <p className="m-0">Optimized compute</p><div className="space-y-2">- <p className="text-sm text-scale-1100">More information</p>+ <p className="text-sm text-scale-1100 m-0">More information</p><div><Link href="https://supabase.com/docs/guides/platform/compute-add-ons"><a target="_blank" rel="noreferrer"><div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">- <p className="text-sm">About compute add-ons</p>+ <p className="text-sm m-0">About compute add-ons</p><IconExternalLink size={16} strokeWidth={1.5} /></div></a>@@ -151,7 +151,7 @@ const Addons = () => {<Link href="https://supabase.com/docs/guides/database/connecting-to-postgres#connection-pooler"><a target="_blank" rel="noreferrer"><div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">- <p className="text-sm">Connection Pooler</p>+ <p className="text-sm m-0">Connection Pooler</p><IconExternalLink size={16} strokeWidth={1.5} /></div></a>@@ -339,14 +339,14 @@ const Addons = () => {<ScaffoldSection><ScaffoldSectionDetail><div className="space-y-6">- <p>Point in time recovery</p>+ <p className="m-0">Point in time recovery</p><div className="space-y-2">- <p className="text-sm text-scale-1100">More information</p>+ <p className="text-sm text-scale-1100 m-0">More information</p><div><Link href="https://supabase.com/docs/guides/platform/backups#point-in-time-recovery"><a target="_blank" rel="noreferrer"><div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">- <p className="text-sm">About PITR backups</p>+ <p className="text-sm m-0">About PITR backups</p><IconExternalLink size={16} strokeWidth={1.5} /></div></a>@@ -403,14 +403,14 @@ const Addons = () => {<ScaffoldSection><ScaffoldSectionDetail><div className="space-y-6">- <p>Custom domain</p>+ <p className="m-0">Custom domain</p><div className="space-y-2">- <p className="text-sm text-scale-1100">More information</p>+ <p className="text-sm text-scale-1100 m-0">More information</p><div><Link href="https://supabase.com/docs/guides/platform/custom-domains"><a target="_blank" rel="noreferrer"><div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">- <p className="text-sm">About custom domains</p>+ <p className="text-sm m-0">About custom domains</p><IconExternalLink size={16} strokeWidth={1.5} /></div></a>diff --git a/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx b/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsxindex caacdeee269..28e6dce7415 100644--- a/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx+++ b/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx@@ -1,8 +1,16 @@+import { useParams } from 'common'import dayjs from 'dayjs'import Link from 'next/link'import { Fragment, useMemo, useState } from 'react'+import { IconBarChart2, IconExternalLink } from 'ui'-import { useParams } from 'common'+import { getAddons } from 'components/interfaces/BillingV2/Subscription/Subscription.utils'+import {+ CPUWarnings,+ DiskIOBandwidthWarnings,+ RAMWarnings,+} from 'components/interfaces/BillingV2/Usage/UsageWarningAlerts'+import UsageBarChart from 'components/interfaces/Organization/Usage/UsageBarChart'import {ScaffoldContainer,ScaffoldDivider,@@ -19,10 +27,8 @@ import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-queimport { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'import { useSelectedOrganization } from 'hooks'import { TIME_PERIODS_BILLING, TIME_PERIODS_REPORTS } from 'lib/constants'-import { Alert, Button, IconBarChart2, IconExternalLink } from 'ui'-import { getAddons } from '../../BillingV2/Subscription/Subscription.utils'-import UsageBarChart from '../../Organization/Usage/UsageBarChart'import { INFRA_ACTIVITY_METRICS } from './Infrastructure.constants'+import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'const InfrastructureActivity = () => {const { ref: projectRef } = useParams()@@ -30,17 +36,17 @@ const InfrastructureActivity = () => {const isOrgBilling = !!organization?.subscription_idconst [dateRange, setDateRange] = useState<any>()- const currentBillingCycleSelected = true- const upgradeUrl = '/'- const categoryMeta = INFRA_ACTIVITY_METRICS.find((category) => category.key === 'infra')-const { data: subscription, isLoading: isLoadingSubscription } = useOrgSubscriptionQuery({orgSlug: organization?.slug,})const isFreePlan = subscription?.plan?.id === 'free'+ const { data: resourceWarnings } = useResourceWarningsQuery()+ const projectResourceWarnings = resourceWarnings?.find((x) => x.project === projectRef)+const { data: addons, isLoading } = useProjectAddonsQuery({ projectRef })const selectedAddons = addons?.selected_addons ?? []+const { computeInstance } = getAddons(selectedAddons)const currentComputeInstanceSpecs = computeInstance?.variant?.meta ?? {baseline_disk_io_mbs: 87,@@ -50,6 +56,27 @@ const InfrastructureActivity = () => {memory_gb: 1,}+ const currentBillingCycleSelected = useMemo(() => {+ // Selected by default+ if (!dateRange?.period_start || !dateRange?.period_end || !subscription) return true++ const { current_period_start, current_period_end } = subscription++ return (+ dayjs(dateRange.period_start.date).isSame(new Date(current_period_start * 1000)) &&+ dayjs(dateRange.period_end.date).isSame(new Date(current_period_end * 1000))+ )+ }, [dateRange, subscription])++ const upgradeUrl =+ subscription === undefined+ ? `/`+ : subscription.plan.id === 'free'+ ? `/org/${organization?.slug ?? '[slug]'}/billing#subscription`+ : `/project/${projectRef}/settings/addons`++ const categoryMeta = INFRA_ACTIVITY_METRICS.find((category) => category.key === 'infra')+const startDate = useMemo(() => {if (dateRange?.period_start?.date === 'Invalid Date') return undefined@@ -116,6 +143,13 @@ const InfrastructureActivity = () => {dateFormat,})+ const hasLatest = dayjs(endDate!).isAfter(dayjs().startOf('day'))++ const latestIoBudgetConsumption =+ hasLatest && ioBudgetData?.data?.slice(-1)?.[0]+ ? Number(ioBudgetData.data.slice(-1)[0].disk_io_consumption)+ : 0+const highestIoBudgetConsumption = Math.max(...(ioBudgetData?.data || []).map((x) => Number(x.disk_io_consumption) ?? 0),0@@ -180,11 +214,11 @@ const InfrastructureActivity = () => {<div className="sticky top-32 space-y-6"><div className="space-y-1"><div className="flex items-center space-x-2">- <p className="text-base capitalize">{attribute.name}</p>+ <p className="text-base capitalize m-0">{attribute.name}</p></div><div className="grid gap-4">{attribute.description.split('\n').map((value, idx) => (- <p key={`desc-${idx}`} className="text-sm text-scale-1000 pr-8">+ <p key={`desc-${idx}`} className="text-sm text-scale-1000 pr-8 m-0">{value}</p>))}@@ -199,7 +233,7 @@ const InfrastructureActivity = () => {<Link href={link.url}><a target="_blank" rel="noreferrer"><div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">- <p className="text-sm">{link.name}</p>+ <p className="text-sm m-0">{link.name}</p><IconExternalLink size={16} strokeWidth={1.5} /></div></a>@@ -212,46 +246,14 @@ const InfrastructureActivity = () => {<ScaffoldSectionContent>{attribute.key === 'disk_io_consumption' && (<>- {currentBillingCycleSelected && highestIoBudgetConsumption >= 100 ? (- <Alert- withIcon- variant="danger"- title="IO Budget for today has been used up"- >- <p className="mb-4">- Your workload has used up all the burst IO throughput minutes and ran at- the baseline performance. If you need consistent disk performance,- consider upgrading to a larger compute add-on.- </p>- <Link href={upgradeUrl}>- <a>- <Button type="danger">- {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}- </Button>- </a>- </Link>- </Alert>- ) : currentBillingCycleSelected && highestIoBudgetConsumption >= 80 ? (- <Alert- withIcon- variant="warning"- title="IO Budget for today is running out"- >- <p className="mb-4">- Your workload is about to use up all the burst IO throughput minutes- during the day. Once this is completely used up, your workload will run- at the baseline performance. If you need consistent disk performance,- consider upgrading to a larger compute add-on.- </p>- <Link href={upgradeUrl}>- <a>- <Button type="warning">- {isFreePlan ? 'Upgrade project' : 'Change compute add-on'}- </Button>- </a>- </Link>- </Alert>- ) : null}+ <DiskIOBandwidthWarnings+ upgradeUrl={upgradeUrl}+ isFreePlan={isFreePlan}+ hasLatest={hasLatest}+ currentBillingCycleSelected={currentBillingCycleSelected}+ latestIoBudgetConsumption={latestIoBudgetConsumption}+ highestIoBudgetConsumption={highestIoBudgetConsumption}+ /><div className="space-y-1"><p>Disk IO Bandwidth</p>@@ -302,6 +304,25 @@ const InfrastructureActivity = () => {</div></>)}+ {attribute.key === 'max_cpu_usage' && (+ <CPUWarnings+ isFreePlan={isFreePlan}+ upgradeUrl={upgradeUrl}+ isBeyondThreshold={+ projectResourceWarnings?.is_cpu_load_beyond_threshold ?? false+ }+ />+ )}+ {attribute.key === 'ram_usage' && (+ <RAMWarnings+ isFreePlan={isFreePlan}+ upgradeUrl={upgradeUrl}+ isBeyondThreshold={+ projectResourceWarnings?.is_memory_and_swap_usage_beyond_threshold ?? false+ }+ />+ )}+<div className="space-y-1"><div className="flex flex-row justify-between">{attribute.key === 'disk_io_consumption' ? (diff --git a/studio/components/ui/UsageWarnings/UsageWarningBanner.constants.ts b/studio/components/ui/UsageWarnings/UsageWarningBanner.constants.tsindex 2a6ca960637..2ef96fafd7a 100644--- a/studio/components/ui/UsageWarnings/UsageWarningBanner.constants.ts+++ b/studio/components/ui/UsageWarnings/UsageWarningBanner.constants.ts@@ -1,12 +1,13 @@// [TODO] Just double check if the docs url and correction urls are all correct+// [TODO] Correction URL should depend if V2 or V1 billingexport const RESOURCE_WARNING_MESSAGES = {is_readonly_mode_enabled: {title: 'Your project is currently in readonly mode and is no longer accepting write requests',description:'You will need to manually override read-only mode and reduce the disk size to below 95%.',docsUrl: 'https://supabase.com/docs/guides/platform/database-size#disabling-read-only-mode',- correctionUrl: undefined,buttonText: undefined,+ metric: undefined,},is_disk_io_budget_below_threshold: {title:@@ -14,16 +15,16 @@ export const RESOURCE_WARNING_MESSAGES = {description:'You will need to either optimize your performance, or upgrade your compute to a larger instance.',docsUrl: 'https://supabase.com/docs/guides/platform/exhaust-disk-io',- correctionUrl: '/project/[ref]/settings/billing/usage#disk_io',buttonText: 'Check usage',+ metric: 'disk_io',},is_disk_space_usage_beyond_threshold: {title:'Your project is about to exhaust its disk space budget, and your instance may become unresponsive once fully exhausted',description: 'Some CTA description here',docsUrl: undefined,- correctionUrl: undefined,buttonText: undefined,+ metric: undefined,},is_cpu_load_beyond_threshold: {title:@@ -31,8 +32,8 @@ export const RESOURCE_WARNING_MESSAGES = {description:'You will need to either optimize your performance or upgrade your compute to a larger instance',docsUrl: 'https://supabase.com/docs/guides/platform/exhaust-cpu',- correctionUrl: '/project/[ref]/settings/billing/usage#cpu',buttonText: 'Check usage',+ metric: 'cpu',},is_memory_and_swap_usage_beyond_threshold: {title:@@ -40,15 +41,15 @@ export const RESOURCE_WARNING_MESSAGES = {description:'You will need to either optimize your performance or upgrade your compute to a larger instance',docsUrl: 'https://supabase.com/docs/guides/platform/exhaust-ram',- correctionUrl: '/project/[ref]/settings/billing/usage#ram',buttonText: 'Check usage',+ metric: 'ram',},multiple_resource_warnings: {title:"Your project is currently exhausting multiple resources, and your instance's performance is affected",description: "Check which resources are reaching their threshold on your project's usage page.",docsUrl: undefined,- correctionUrl: '/project/[ref]/settings/billing/usage',buttonText: 'Check usage',+ metric: null,},}diff --git a/studio/components/ui/UsageWarnings/UsageWarningBanner.tsx b/studio/components/ui/UsageWarnings/UsageWarningBanner.tsxindex c3672308ae0..b000addf113 100644--- a/studio/components/ui/UsageWarnings/UsageWarningBanner.tsx+++ b/studio/components/ui/UsageWarnings/UsageWarningBanner.tsx@@ -12,15 +12,19 @@ import {import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'import { RESOURCE_WARNING_MESSAGES } from './UsageWarningBanner.constants'import { useRouter } from 'next/router'+import { useSelectedOrganization } from 'hooks'const UsageWarningBanner = () => {const { ref } = useParams()const router = useRouter()+ const organization = useSelectedOrganization()const { data: resourceWarnings } = useResourceWarningsQuery()const projectResourceWarnings = (resourceWarnings ?? [])?.find((warning) => warning.project === ref)+ const isOrgBilling = !!organization?.subscription_id+// [Joshen] Read only takes higher precedence over multiple resource warningsconst activeWarnings =projectResourceWarnings !== undefined@@ -49,19 +53,35 @@ const UsageWarningBanner = () => {? RESOURCE_WARNING_MESSAGES.multiple_resource_warnings.docsUrl: RESOURCE_WARNING_MESSAGES[activeWarnings[0] as keyof typeof RESOURCE_WARNING_MESSAGES]?.docsUrl- const correctionUrl = (+ const metric =activeWarnings.length > 1- ? RESOURCE_WARNING_MESSAGES.multiple_resource_warnings.correctionUrl+ ? RESOURCE_WARNING_MESSAGES.multiple_resource_warnings.metric: RESOURCE_WARNING_MESSAGES[activeWarnings[0] as keyof typeof RESOURCE_WARNING_MESSAGES]- ?.correctionUrl- )?.replace('[ref]', ref ?? 'default')+ ?.metric++ const correctionUrl = (+ metric === undefined+ ? undefined+ : metric === null+ ? '/project/[ref]/settings/[infra-path]'+ : `/project/[ref]/settings/[infra-path]#${metric}`+ )+ ?.replace('[ref]', ref ?? 'default')+ ?.replace('[infra-path]', isOrgBilling ? 'infrastructure' : 'billing/usage')+const buttonText =activeWarnings.length > 1? RESOURCE_WARNING_MESSAGES.multiple_resource_warnings.buttonText: RESOURCE_WARNING_MESSAGES[activeWarnings[0] as keyof typeof RESOURCE_WARNING_MESSAGES]?.buttonText- if (activeWarnings.length === 0 || router.pathname.includes('/usage')) return null+ // Don't show banner if no warnings, or on usage/infra page+ if (+ activeWarnings.length === 0 ||+ router.pathname.endsWith('/usage') ||+ router.pathname.endsWith('/infrastructure')+ )+ return nullreturn (<Alert_Shadcn_