Skip to content

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

Hide tables and charts for attributes that are not avialable in the plan

Joshen Lim36bc464ed75b
diff --git a/studio/components/interfaces/BillingV2/Usage/Activity.tsx b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
index 5c9004705d2..9cad0bb469d 100644
--- a/studio/components/interfaces/BillingV2/Usage/Activity.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
@@ -159,74 +159,78 @@ const Activity = ({ projectRef }: ActivityProps) => {
section={attribute}
includedInPlan={usageMeta?.available_in_plan}
>
- <div className="space-y-2">
- <div className="flex items-center justify-between">
- <div className="flex items-center space-x-4">
- <p className="text-sm">
- {attribute.name} {subscription?.tier.key.toLowerCase()} quota usage
- </p>
- {usageRatio >= 1 ? (
- <div className="flex items-center space-x-2 min-w-[115px]">
- <IconAlertTriangle size={14} strokeWidth={2} className={exceededLimitStyle} />
- <p className={`text-sm ${exceededLimitStyle}`}>Exceeded limit</p>
+ {usageMeta?.available_in_plan && (
+ <>
+ <div className="space-y-2">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center space-x-4">
+ <p className="text-sm">
+ {attribute.name} {subscription?.tier.key.toLowerCase()} quota usage
+ </p>
+ {usageRatio >= 1 ? (
+ <div className="flex items-center space-x-2 min-w-[115px]">
+ <IconAlertTriangle
+ size={14}
+ strokeWidth={2}
+ className={exceededLimitStyle}
+ />
+ <p className={`text-sm ${exceededLimitStyle}`}>Exceeded limit</p>
+ </div>
+ ) : usageRatio >= USAGE_APPROACHING_THRESHOLD ? (
+ <div className="flex items-center space-x-2 min-w-[115px]">
+ <IconAlertTriangle size={14} strokeWidth={2} className="text-amber-900" />
+ <p className="text-sm text-amber-900">Approaching limit</p>
+ </div>
+ ) : null}
</div>
- ) : usageRatio >= USAGE_APPROACHING_THRESHOLD ? (
- <div className="flex items-center space-x-2 min-w-[115px]">
- <IconAlertTriangle size={14} strokeWidth={2} className="text-amber-900" />
- <p className="text-sm text-amber-900">Approaching limit</p>
+ {isFreeTier && (
+ <Link href={upgradeUrl}>
+ <a>
+ <Button type="default" size="tiny">
+ Upgrade project
+ </Button>
+ </a>
+ </Link>
+ )}
+ </div>
+ <SparkBar
+ type="horizontal"
+ barClass={clsx(
+ usageRatio >= 1
+ ? 'bg-red-900'
+ : usageRatio >= USAGE_APPROACHING_THRESHOLD
+ ? 'bg-amber-900'
+ : 'bg-scale-1100'
+ )}
+ value={usageMeta?.usage ?? 0}
+ max={usageMeta?.limit ?? 0}
+ />
+ <div>
+ <div className="flex items-center justify-between border-b py-1">
+ <p className="text-xs text-scale-1000">
+ Included in {subscription?.tier.name.toLowerCase()}
+ </p>
+ {usageMeta?.limit === -1 ? (
+ <p className="text-xs">None</p>
+ ) : (
+ <p className="text-xs">{(usageMeta?.limit ?? 0).toLocaleString()}</p>
+ )}
</div>
- ) : null}
- </div>
- {isFreeTier && (
- <Link href={upgradeUrl}>
- <a>
- <Button type="default" size="tiny">
- Upgrade project
- </Button>
- </a>
- </Link>
- )}
- </div>
- <SparkBar
- type="horizontal"
- barClass={clsx(
- usageRatio >= 1
- ? 'bg-red-900'
- : usageRatio >= USAGE_APPROACHING_THRESHOLD
- ? 'bg-amber-900'
- : 'bg-scale-1100'
- )}
- value={usageMeta?.usage ?? 0}
- max={usageMeta?.limit ?? 0}
- />
- <div>
- <div className="flex items-center justify-between border-b py-1">
- <p className="text-xs text-scale-1000">
- Included in {subscription?.tier.name.toLowerCase()}
- </p>
- {usageMeta?.limit === -1 ? (
- <p className="text-xs">None</p>
- ) : (
- <p className="text-xs">{(usageMeta?.limit ?? 0).toLocaleString()}</p>
- )}
- </div>
- <div className="flex items-center justify-between border-b py-1">
- <p className="text-xs text-scale-1000">Used</p>
- <p className="text-xs">{(usageMeta?.usage ?? 0).toLocaleString()}</p>
- </div>
- <div className="flex items-center justify-between py-1">
- <p className="text-xs text-scale-1000">Extra volume used this month</p>
- <p className="text-xs">
- {((usageMeta?.limit ?? 0) === -1 || usageExcess < 0
- ? 0
- : usageExcess
- ).toLocaleString()}
- </p>
+ <div className="flex items-center justify-between border-b py-1">
+ <p className="text-xs text-scale-1000">Used</p>
+ <p className="text-xs">{(usageMeta?.usage ?? 0).toLocaleString()}</p>
+ </div>
+ <div className="flex items-center justify-between py-1">
+ <p className="text-xs text-scale-1000">Extra volume used this month</p>
+ <p className="text-xs">
+ {((usageMeta?.limit ?? 0) === -1 || usageExcess < 0
+ ? 0
+ : usageExcess
+ ).toLocaleString()}
+ </p>
+ </div>
+ </div>
</div>
- </div>
- </div>
- {usageMeta?.available_in_plan && (
- <>
<div className="space-y-1">
<p>{attribute.name} over time</p>
{attribute.chartDescription.split('\n').map((paragraph, idx) => (
diff --git a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
index 9e0b4ebf08e..72e4c55b783 100644
--- a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
@@ -79,7 +79,7 @@ const Infrastructure = ({ projectRef }: InfrastructureProps) => {
: undefined
return (
- <SectionContent key={attribute.key} section={attribute}>
+ <SectionContent key={attribute.key} section={attribute} lastKnownValue={lastKnownValue}>
{attribute.key === 'disk_io_budget' && (
// [Joshen] Eventually should show the overview of the io bandwidth in mbps for burst, baseline and duration
<>
@@ -91,31 +91,6 @@ const Infrastructure = ({ projectRef }: InfrastructureProps) => {
bandwidth.
</p>
</div>
- {/* <div>
- <div className="flex items-center justify-between border-b py-1">
- <p className="text-xs text-scale-1000">
- Included in {subscription?.tier.name.toLowerCase()}
- </p>
- {usageMeta?.limit === -1 ? (
- <p className="text-xs">None</p>
- ) : (
- <p className="text-xs">{(usageMeta?.limit ?? 0).toLocaleString()}</p>
- )}
- </div>
- <div className="flex items-center justify-between border-b py-1">
- <p className="text-xs text-scale-1000">Used</p>
- <p className="text-xs">{(usageMeta?.usage ?? 0).toLocaleString()}</p>
- </div>
- <div className="flex items-center justify-between py-1">
- <p className="text-xs text-scale-1000">Extra volume used this month</p>
- <p className="text-xs">
- {((usageMeta?.limit ?? 0) === -1 || usageExcess < 0
- ? 0
- : usageExcess
- ).toLocaleString()}
- </p>
- </div>
- </div> */}
</>
)}
<div className="space-y-1">
diff --git a/studio/components/interfaces/BillingV2/Usage/SectionContent.tsx b/studio/components/interfaces/BillingV2/Usage/SectionContent.tsx
index a610d2570b4..ee8b97fea12 100644
--- a/studio/components/interfaces/BillingV2/Usage/SectionContent.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/SectionContent.tsx
@@ -6,11 +6,13 @@ import Link from 'next/link'
export interface SectionContent {
section: CategoryAttribute
includedInPlan?: boolean
+ lastKnownValue?: string
}
const SectionContent = ({
section,
includedInPlan,
+ lastKnownValue,
children,
}: PropsWithChildren<SectionContent>) => {
const { name, description, docsUrl } = section
@@ -45,6 +47,9 @@ const SectionContent = ({
</Link>
</div>
)}
+ {lastKnownValue !== undefined && (
+ <p className="text-xs text-scale-1000">Last updated at: {lastKnownValue}</p>
+ )}
</div>
</div>
<div className="col-span-12 md:col-span-7 space-y-6">{children}</div>