Skip to content

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

Remove SparkBar and excess limits if limits is 0

Joshen Lim6c6a3346b624
diff --git a/studio/components/interfaces/BillingV2/Usage/Activity.tsx b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
index 375ba50c6cf..06a3958462e 100644
--- a/studio/components/interfaces/BillingV2/Usage/Activity.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
@@ -191,18 +191,20 @@ const Activity = ({ projectRef }: ActivityProps) => {
</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}
- />
+ {usageMeta.limit > 0 && (
+ <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">
@@ -214,19 +216,21 @@ const Activity = ({ projectRef }: ActivityProps) => {
<p className="text-xs">{(usageMeta?.limit ?? 0).toLocaleString()}</p>
)}
</div>
- <div className="flex items-center justify-between border-b py-1">
+ <div className="flex items-center justify-between 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>
+ {usageMeta.limit > 0 && (
+ <div className="flex items-center justify-between border-t 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 className="space-y-1">
diff --git a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
index e53fbfa7d59..c00f263b898 100644
--- a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
@@ -120,35 +120,41 @@ const Bandwidth = ({ projectRef }: BandwidthProps) => {
</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}
- />
+ {usageMeta?.limit > 0 && (
+ <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>
- <p className="text-xs">{formatBytes(usageMeta?.limit ?? 0)}</p>
+ <p className="text-xs">
+ {usageMeta?.limit === 0 ? 'Unlimited' : formatBytes(usageMeta?.limit ?? 0)}
+ </p>
</div>
- <div className="flex items-center justify-between border-b py-1">
+ <div className="flex items-center justify-between py-1">
<p className="text-xs text-scale-1000">Used</p>
<p className="text-xs">{formatBytes(usageMeta?.usage ?? 0)}</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">
- {usageExcess < 0 ? formatBytes(0) : formatBytes(usageExcess)}
- </p>
- </div>
+ {usageMeta?.limit > 0 && (
+ <div className="flex items-center justify-between border-t py-1">
+ <p className="text-xs text-scale-1000">Extra volume used this month</p>
+ <p className="text-xs">
+ {usageExcess < 0 ? formatBytes(0) : formatBytes(usageExcess)}
+ </p>
+ </div>
+ )}
</div>
</div>
<div className="space-y-1">
@@ -170,7 +176,7 @@ const Bandwidth = ({ projectRef }: BandwidthProps) => {
</div>
) : (
<UsageBarChart
- hasQuota
+ hasQuota={usageMeta?.limit > 0}
name={attribute.name}
unit={attribute.unit}
attribute={attribute.attribute}
diff --git a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
index b355f05b3f6..70f6b975475 100644
--- a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
@@ -135,18 +135,20 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {
</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}
- />
+ {usageMeta.limit > 0 && (
+ <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">
@@ -158,7 +160,7 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {
: (usageMeta?.limit ?? 0).toLocaleString()}
</p>
</div>
- <div className="flex items-center justify-between border-b py-1">
+ <div className="flex items-center justify-between py-1">
<p className="text-xs text-scale-1000">Used</p>
<p className="text-xs">
{attribute.unit === 'bytes'
@@ -166,18 +168,20 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {
: (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">
- {usageExcess < 0
- ? attribute.unit === 'bytes'
- ? formatBytes(0)
- : 0
- : attribute.unit === 'bytes'
- ? formatBytes(usageExcess)
- : usageExcess.toLocaleString()}
- </p>
- </div>
+ {usageMeta.limit > 0 && (
+ <div className="flex items-center justify-between border-t py-1">
+ <p className="text-xs text-scale-1000">Extra volume used this month</p>
+ <p className="text-xs">
+ {usageExcess < 0
+ ? attribute.unit === 'bytes'
+ ? formatBytes(0)
+ : 0
+ : attribute.unit === 'bytes'
+ ? formatBytes(usageExcess)
+ : usageExcess.toLocaleString()}
+ </p>
+ </div>
+ )}
</div>
</div>
@@ -238,16 +242,6 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {
</SectionContent>
)
})}
- <UsageBarChart
- hasQuota
- name={'Sample'}
- unit={'percentage'}
- attribute={'sample_data'}
- data={generateUsageData('sample_data', 30)}
- yLimit={50}
- yLeftMargin={0}
- quotaWarningType={isFreeTier || isProTier ? 'danger' : 'warning'}
- />
</>
)
}
diff --git a/studio/components/interfaces/BillingV2/Usage/UsageBarChart.tsx b/studio/components/interfaces/BillingV2/Usage/UsageBarChart.tsx
index 191c7e583ef..2e2dbddae43 100644
--- a/studio/components/interfaces/BillingV2/Usage/UsageBarChart.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/UsageBarChart.tsx
@@ -101,7 +101,7 @@ const UsageBarChart = ({
<Cell
key={`${entry.period_start}`}
className={
- yLimit !== undefined && Number(entry[attribute]) >= yLimit
+ yLimit !== undefined && Number(entry[attribute]) >= yLimit && hasQuota
? quotaWarningClass
: 'fill-scale-1200'
}