Skip to content

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

Only show upgrade button if project is on free tier

Joshen Limaef1ef1e7f62
diff --git a/studio/components/interfaces/BillingV2/Usage/Activity.tsx b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
index ddc4ded287c..973d9b64350 100644
--- a/studio/components/interfaces/BillingV2/Usage/Activity.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
@@ -17,6 +17,7 @@ import SectionContent from './SectionContent'
import SectionHeader from './SectionHeader'
import { USAGE_CATEGORIES } from './Usage.constants'
import { getUpgradeUrl } from './Usage.utils'
+import { PRICING_TIER_PRODUCT_IDS } from 'lib/constants'
export interface ActivityProps {
projectRef: string
@@ -31,6 +32,7 @@ const Activity = ({ projectRef }: ActivityProps) => {
const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === 'activity')
const upgradeUrl = getUpgradeUrl(projectRef, subscription)
+ const isFreeTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.FREE
const { data: mauData, isLoading: isLoadingMauData } = useDailyStatsQuery({
projectRef,
@@ -173,13 +175,15 @@ const Activity = ({ projectRef }: ActivityProps) => {
</div>
) : null}
</div>
- <Link href={upgradeUrl}>
- <a>
- <Button type="default" size="tiny">
- Upgrade project
- </Button>
- </a>
- </Link>
+ {isFreeTier && (
+ <Link href={upgradeUrl}>
+ <a>
+ <Button type="default" size="tiny">
+ Upgrade project
+ </Button>
+ </a>
+ </Link>
+ )}
</div>
<SparkBar
type="horizontal"
diff --git a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
index 2f020a7a3f8..53b986e8694 100644
--- a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
@@ -9,7 +9,7 @@ import {
useProjectUsageQuery,
} from 'data/usage/project-usage-query'
import dayjs from 'dayjs'
-import { USAGE_APPROACHING_THRESHOLD } from 'lib/constants'
+import { PRICING_TIER_PRODUCT_IDS, USAGE_APPROACHING_THRESHOLD } from 'lib/constants'
import { formatBytes } from 'lib/helpers'
import Link from 'next/link'
import { Button, IconAlertTriangle } from 'ui'
@@ -32,6 +32,7 @@ const Bandwidth = ({ projectRef }: BandwidthProps) => {
const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === 'bandwidth')
const upgradeUrl = getUpgradeUrl(projectRef, subscription)
+ const isFreeTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.FREE
const { data: dbEgressData, isLoading: isLoadingDbEgressData } = useDailyStatsQuery({
projectRef,
@@ -107,13 +108,15 @@ const Bandwidth = ({ projectRef }: BandwidthProps) => {
</div>
) : null}
</div>
- <Link href={upgradeUrl}>
- <a>
- <Button type="default" size="tiny">
- Upgrade project
- </Button>
- </a>
- </Link>
+ {isFreeTier && (
+ <Link href={upgradeUrl}>
+ <a>
+ <Button type="default" size="tiny">
+ Upgrade project
+ </Button>
+ </a>
+ </Link>
+ )}
</div>
<SparkBar
type="horizontal"
diff --git a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
index fe3239fb059..789a96cf027 100644
--- a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
@@ -33,6 +33,7 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {
const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === 'sizeCount')
const upgradeUrl = getUpgradeUrl(projectRef, subscription)
+ const isFreeTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.FREE
const { data: dbSizeData, isLoading: isLoadingDbSizeData } = useDailyStatsQuery({
projectRef,
@@ -124,13 +125,15 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {
</div>
) : null}
</div>
- <Link href={upgradeUrl}>
- <a>
- <Button type="default" size="tiny">
- Upgrade project
- </Button>
- </a>
- </Link>
+ {isFreeTier && (
+ <Link href={upgradeUrl}>
+ <a>
+ <Button type="default" size="tiny">
+ Upgrade project
+ </Button>
+ </a>
+ </Link>
+ )}
</div>
<SparkBar
type="horizontal"
diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.tsx b/studio/components/interfaces/BillingV2/Usage/Usage.tsx
index 68db6068849..c58343844a8 100644
--- a/studio/components/interfaces/BillingV2/Usage/Usage.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Usage.tsx
@@ -1,19 +1,17 @@
import clsx from 'clsx'
import { useParams } from 'common'
-import ShimmeringLoader from 'components/ui/ShimmeringLoader'
-import { useProjectsQuery } from 'data/projects/projects-query'
import { useProjectSubscriptionQuery } from 'data/subscriptions/project-subscription-query'
import { useProjectUsageQuery } from 'data/usage/project-usage-query'
+import dayjs from 'dayjs'
import Link from 'next/link'
import { useRef, useState } from 'react'
-import { Button, IconAlertCircle, IconCheckCircle, IconLoader, Listbox, Toggle } from 'ui'
+import { Button, IconAlertCircle, IconCheckCircle, IconLoader, Listbox } from 'ui'
import Activity from './Activity'
import Bandwidth from './Bandwidth'
import Infrastructure from './Infrastructure'
import SizeAndCounts from './SizeAndCounts'
import { USAGE_CATEGORIES, USAGE_STATUS } from './Usage.constants'
import { getUsageStatus } from './Usage.utils'
-import dayjs from 'dayjs'
const Usage = () => {
const { ref } = useParams()