Skip to content

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

cleanup

Kevin Grüneberg23e5ad76d5fc
diff --git a/studio/components/interfaces/BillingV2/Usage/Activity.tsx b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
index 2038079fbc7..b6bb88ef7c1 100644
--- a/studio/components/interfaces/BillingV2/Usage/Activity.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
@@ -1,8 +1,7 @@
import { useDailyStatsQuery } from 'data/analytics/daily-stats-query'
-import { USAGE_CATEGORIES } from './Usage.constants'
import { DataPoint } from 'data/analytics/constants'
import { ProjectSubscriptionResponse } from 'data/subscriptions/project-subscription-v2-query'
-import UsageFoo from './UsageFoo'
+import UsageSection from './UsageSection'
export interface ActivityProps {
projectRef: string
@@ -12,8 +11,6 @@ export interface ActivityProps {
}
const Activity = ({ projectRef, subscription, startDate, endDate }: ActivityProps) => {
- const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === 'activity')
-
const { data: mauData, isLoading: isLoadingMauData } = useDailyStatsQuery({
projectRef,
attribute: 'total_auth_billing_period_mau',
@@ -108,12 +105,10 @@ const Activity = ({ projectRef, subscription, startDate, endDate }: ActivityProp
},
}
- if (categoryMeta === undefined) return null
-
return (
- <UsageFoo
+ <UsageSection
projectRef={projectRef}
- categoryMeta={categoryMeta}
+ categoryKey='activity'
chartMeta={chartMeta}
subscription={subscription}
/>
diff --git a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
index 9c76f21ed2e..c013dc314b0 100644
--- a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
@@ -1,8 +1,7 @@
import { DataPoint } from 'data/analytics/constants'
import { useDailyStatsQuery } from 'data/analytics/daily-stats-query'
-import { USAGE_CATEGORIES } from './Usage.constants'
import { ProjectSubscriptionResponse } from 'data/subscriptions/project-subscription-v2-query'
-import UsageFoo from './UsageFoo'
+import UsageSection from './UsageSection'
export interface BandwidthProps {
projectRef: string
@@ -12,8 +11,6 @@ export interface BandwidthProps {
}
const Bandwidth = ({ projectRef, subscription, startDate, endDate }: BandwidthProps) => {
- const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === 'bandwidth')
-
const { data: dbEgressData, isLoading: isLoadingDbEgressData } = useDailyStatsQuery({
projectRef,
attribute: 'total_egress_modified',
@@ -47,12 +44,10 @@ const Bandwidth = ({ projectRef, subscription, startDate, endDate }: BandwidthPr
},
}
- if (categoryMeta === undefined) return null
-
return (
- <UsageFoo
+ <UsageSection
projectRef={projectRef}
- categoryMeta={categoryMeta}
+ categoryKey='bandwidth'
chartMeta={chartMeta}
subscription={subscription}
/>
diff --git a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
index f5716aa0f4c..2f66c88e095 100644
--- a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
@@ -1,8 +1,7 @@
import { useDailyStatsQuery } from 'data/analytics/daily-stats-query'
-import { USAGE_CATEGORIES } from './Usage.constants'
import { DataPoint } from 'data/analytics/constants'
import { ProjectSubscriptionResponse } from 'data/subscriptions/project-subscription-v2-query'
-import UsageFoo from './UsageFoo'
+import UsageSection from './UsageSection'
export interface SizeAndCountsProps {
projectRef: string
@@ -12,8 +11,6 @@ export interface SizeAndCountsProps {
}
const SizeAndCounts = ({ projectRef, startDate, endDate, subscription }: SizeAndCountsProps) => {
- const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === 'sizeCount')
-
const { data: dbSizeData, isLoading: isLoadingDbSizeData } = useDailyStatsQuery({
projectRef,
attribute: 'total_db_size_bytes',
@@ -61,12 +58,10 @@ const SizeAndCounts = ({ projectRef, startDate, endDate, subscription }: SizeAnd
},
}
- if (categoryMeta === undefined) return null
-
return (
- <UsageFoo
+ <UsageSection
projectRef={projectRef}
- categoryMeta={categoryMeta}
+ categoryKey='sizeCount'
chartMeta={chartMeta}
subscription={subscription}
/>
diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.constants.tsx b/studio/components/interfaces/BillingV2/Usage/Usage.constants.tsx
index 4f18fead725..c5433c5abbe 100644
--- a/studio/components/interfaces/BillingV2/Usage/Usage.constants.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Usage.constants.tsx
@@ -30,6 +30,8 @@ export interface CategoryAttribute {
) => JSX.Element | null
}
+export type CategoryMetaKey = 'infra' | 'bandwidth' | 'sizeCount' | 'activity'
+
export interface CategoryMeta {
key: 'infra' | 'bandwidth' | 'sizeCount' | 'activity'
name: string
diff --git a/studio/components/interfaces/BillingV2/Usage/UsageFoo.tsx b/studio/components/interfaces/BillingV2/Usage/UsageSection.tsx
similarity index 95%
rename from studio/components/interfaces/BillingV2/Usage/UsageFoo.tsx
rename to studio/components/interfaces/BillingV2/Usage/UsageSection.tsx
index 6b3e4374484..db512cd7ad2 100644
--- a/studio/components/interfaces/BillingV2/Usage/UsageFoo.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/UsageSection.tsx
@@ -1,6 +1,6 @@
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import SectionHeader from './SectionHeader'
-import { CategoryMeta } from './Usage.constants'
+import { CategoryMetaKey, USAGE_CATEGORIES } from './Usage.constants'
import {
ProjectUsageResponse,
UsageMetric,
@@ -19,17 +19,21 @@ import { formatBytes } from 'lib/helpers'
import UsageBarChart from './UsageBarChart'
import Panel from 'components/ui/Panel'
-interface UsageFooProps {
+interface UsageSectionProps {
projectRef: string
- categoryMeta: CategoryMeta
+ categoryKey: CategoryMetaKey
subscription: ProjectSubscriptionResponse | undefined
chartMeta: {
[key: string]: { data: DataPoint[]; margin: number; isLoading: boolean; hasNoData: boolean }
}
}
-const UsageFoo = ({ projectRef, categoryMeta, chartMeta, subscription }: UsageFooProps) => {
+const UsageSection = ({ projectRef, categoryKey, chartMeta, subscription }: UsageSectionProps) => {
const { data: usage } = useProjectUsageQuery({ projectRef })
+ const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === categoryKey)
+
+ if (!categoryMeta) return null
+
const usageBasedBilling = subscription?.usage_billing_enabled
const exceededLimitStyle = !usageBasedBilling ? 'text-red-900' : 'text-amber-900'
@@ -188,4 +192,4 @@ const UsageFoo = ({ projectRef, categoryMeta, chartMeta, subscription }: UsageFo
)
}
-export default UsageFoo
+export default UsageSection