The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update chart colors for plans with and without spend cap
Joshen Limbfcdeb6a4580
diff --git a/studio/components/interfaces/BillingV2/Usage/Activity.tsx b/studio/components/interfaces/BillingV2/Usage/Activity.tsxindex 4896ed06dd2..5c9004705d2 100644--- a/studio/components/interfaces/BillingV2/Usage/Activity.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Activity.tsx@@ -12,7 +12,7 @@ import dayjs from 'dayjs'import Link from 'next/link'import { Button, IconAlertTriangle } from 'ui'import { USAGE_APPROACHING_THRESHOLD } from '../Billing.constants'-import BarChart from './BarChart'+import UsageBarChart from './UsageBarChart'import SectionContent from './SectionContent'import SectionHeader from './SectionHeader'import { USAGE_CATEGORIES } from './Usage.constants'@@ -33,6 +33,8 @@ const Activity = ({ projectRef }: ActivityProps) => {const upgradeUrl = getUpgradeUrl(projectRef, subscription)const isFreeTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.FREE+ const isProTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.PRO+ const exceededLimitStyle = isFreeTier || isProTier ? 'text-red-900' : 'text-amber-900'const { data: mauData, isLoading: isLoadingMauData } = useDailyStatsQuery({projectRef,@@ -165,13 +167,13 @@ const Activity = ({ projectRef }: ActivityProps) => {</p>{usageRatio >= 1 ? (<div className="flex items-center space-x-2 min-w-[115px]">- <IconAlertTriangle size={14} strokeWidth={2} className="text-red-900" />- <p className="text-sm text-red-900">Exceeded limit</p>+ <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-red-900">Approaching limit</p>+ <p className="text-sm text-amber-900">Approaching limit</p></div>) : null}</div>@@ -245,7 +247,7 @@ const Activity = ({ projectRef }: ActivityProps) => {<ShimmeringLoader className="w-1/2" /></div>) : (- <BarChart+ <UsageBarCharthasQuotaname={attribute.name}unit={attribute.unit}@@ -254,6 +256,7 @@ const Activity = ({ projectRef }: ActivityProps) => {yLimit={usageMeta?.limit ?? 0}yLeftMargin={chartMeta[attribute.key].margin}yFormatter={(value) => value.toLocaleString()}+ quotaWarningType={isFreeTier || isProTier ? 'danger' : 'warning'}/>)}</>diff --git a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsxindex 446ad4ac6b8..1ff38573db1 100644--- a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx@@ -13,7 +13,7 @@ import { PRICING_TIER_PRODUCT_IDS, USAGE_APPROACHING_THRESHOLD } from 'lib/constimport { formatBytes } from 'lib/helpers'import Link from 'next/link'import { Button, IconAlertTriangle } from 'ui'-import BarChart from './BarChart'+import UsageBarChart from './UsageBarChart'import SectionContent from './SectionContent'import SectionHeader from './SectionHeader'import { USAGE_CATEGORIES } from './Usage.constants'@@ -33,6 +33,8 @@ const Bandwidth = ({ projectRef }: BandwidthProps) => {const upgradeUrl = getUpgradeUrl(projectRef, subscription)const isFreeTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.FREE+ const isProTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.PRO+ const exceededLimitStyle = isFreeTier || isProTier ? 'text-red-900' : 'text-amber-900'const { data: dbEgressData, isLoading: isLoadingDbEgressData } = useDailyStatsQuery({projectRef,@@ -100,13 +102,13 @@ const Bandwidth = ({ projectRef }: BandwidthProps) => {</p>{usageRatio >= 1 ? (<div className="flex items-center space-x-2 min-w-[115px]">- <IconAlertTriangle size={14} strokeWidth={2} className="text-red-900" />- <p className="text-sm text-red-900">Exceeded limit</p>+ <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-red-900">Approaching limit</p>+ <p className="text-sm text-amber-900">Approaching limit</p></div>) : null}</div>@@ -169,7 +171,7 @@ const Bandwidth = ({ projectRef }: BandwidthProps) => {<ShimmeringLoader className="w-1/2" /></div>) : (- <BarChart+ <UsageBarCharthasQuotaname={attribute.name}unit={attribute.unit}@@ -178,6 +180,7 @@ const Bandwidth = ({ projectRef }: BandwidthProps) => {yLimit={usageMeta?.limit ?? 0}yLeftMargin={chartMeta[attribute.key].margin}yFormatter={(value) => formatBytes(value, 1, 'GB').replace(/\s/g, '')}+ quotaWarningType={isFreeTier || isProTier ? 'danger' : 'warning'}/>)}</SectionContent>diff --git a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsxindex 7325ccd2032..9e0b4ebf08e 100644--- a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx@@ -2,7 +2,7 @@ import ShimmeringLoader from 'components/ui/ShimmeringLoader'import { useInfraMonitoringQuery } from 'data/analytics/infra-monitoring-query'import { useProjectSubscriptionQuery } from 'data/subscriptions/project-subscription-query'import dayjs from 'dayjs'-import BarChart from './BarChart'+import UsageBarChart from './UsageBarChart'import SectionContent from './SectionContent'import SectionHeader from './SectionHeader'import { USAGE_CATEGORIES } from './Usage.constants'@@ -146,7 +146,7 @@ const Infrastructure = ({ projectRef }: InfrastructureProps) => {<ShimmeringLoader className="w-1/2" /></div>) : (- <BarChart+ <UsageBarChartname={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.tsxindex 69364c9dfc8..d5efec7aea7 100644--- a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx+++ b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx@@ -14,11 +14,11 @@ import { formatBytes } from 'lib/helpers'import Link from 'next/link'import { Badge, Button, IconAlertTriangle, IconExternalLink } from 'ui'import { USAGE_APPROACHING_THRESHOLD } from '../Billing.constants'-import BarChart from './BarChart'+import UsageBarChart from './UsageBarChart'import SectionContent from './SectionContent'import SectionHeader from './SectionHeader'import { USAGE_CATEGORIES } from './Usage.constants'-import { getUpgradeUrl } from './Usage.utils'+import { generateUsageData, getUpgradeUrl } from './Usage.utils'export interface SizeAndCountsProps {projectRef: string@@ -34,6 +34,8 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {const upgradeUrl = getUpgradeUrl(projectRef, subscription)const isFreeTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.FREE+ const isProTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.PRO+ const exceededLimitStyle = isFreeTier || isProTier ? 'text-red-900' : 'text-amber-900'const { data: dbSizeData, isLoading: isLoadingDbSizeData } = useDailyStatsQuery({projectRef,@@ -115,13 +117,13 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {</p>{usageRatio >= 1 ? (<div className="flex items-center space-x-2 min-w-[115px]">- <IconAlertTriangle size={14} strokeWidth={2} className="text-red-900" />- <p className="text-sm text-red-900">Exceeded limit</p>+ <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-red-900">Approaching limit</p>+ <p className="text-sm text-amber-900">Approaching limit</p></div>) : null}</div>@@ -219,7 +221,7 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {<ShimmeringLoader className="w-1/2" /></div>) : (- <BarChart+ <UsageBarCharthasQuotaname={attribute.name}unit={attribute.unit}@@ -232,11 +234,22 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {? formatBytes(value, 1, 'GB').replace(/\s/g, ''): value.toLocaleString()}+ quotaWarningType={isFreeTier || isProTier ? 'danger' : 'warning'}/>)}</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/Usage.constants.ts b/studio/components/interfaces/BillingV2/Usage/Usage.constants.tsindex b739b75344a..d94ba87c7f7 100644--- a/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts+++ b/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts@@ -128,8 +128,9 @@ export const USAGE_CATEGORIES: {name: 'Monthly active users',unit: 'absolute',description:- 'The amount of distinct users requesting your API throughout the billing period. Resets at the beginning of every billing period.',- chartDescription: 'The data shown here is refreshed over a period of 24 hours.',+ 'The amount of distinct users requesting your API throughout the billing period.',+ chartDescription:+ 'The data shown here is refreshed over a period of 24 hours and resets at the beginning of every billing period.',},{key: 'monthly_active_sso_users',@@ -137,8 +138,9 @@ export const USAGE_CATEGORIES: {name: 'Monthly active single sign-on users',unit: 'absolute',description:- 'The amount of distinct Single Sign-On users requesting your API throughout the billing period. Resets at the beginning of every billing period.',- chartDescription: 'The data shown here is refreshed over a period of 24 hours.',+ 'The amount of distinct Single Sign-On users requesting your API throughout the billing period.',+ chartDescription:+ 'The data shown here is refreshed over a period of 24 hours and resets at the beginning of every billing period.',},{key: 'storage_image_render_count',diff --git a/studio/components/interfaces/BillingV2/Usage/BarChart.tsx b/studio/components/interfaces/BillingV2/Usage/UsageBarChart.tsxsimilarity index 92%rename from studio/components/interfaces/BillingV2/Usage/BarChart.tsxrename to studio/components/interfaces/BillingV2/Usage/UsageBarChart.tsxindex d3d86c2b816..77fecdb1abb 100644--- a/studio/components/interfaces/BillingV2/Usage/BarChart.tsx+++ b/studio/components/interfaces/BillingV2/Usage/UsageBarChart.tsx@@ -16,7 +16,7 @@ import dayjs from 'dayjs'// [Joshen] This BarChart is specifically for usage, hence not a reusable component, and not// replacing the existing BarChart in ui/Charts-export interface BarChartProps {+export interface UsageBarChartProps {data: DataPoint[]name: string // Used within the tooltipattribute: string@@ -25,9 +25,10 @@ export interface BarChartProps {yLimit?: numberyLeftMargin?: numberyFormatter?: (value: number | string) => string+ quotaWarningType?: 'warning' | 'danger'}-const BarChart = ({+const UsageBarChart = ({data,name,attribute,@@ -36,9 +37,11 @@ const BarChart = ({yLimit,yLeftMargin = 10,yFormatter,-}: BarChartProps) => {+ quotaWarningType = 'warning',+}: UsageBarChartProps) => {const yMin = 0 // We can consider passing this as a prop if there's a use case in the futureconst yMax = (yLimit ?? 0) * Y_DOMAIN_CEILING_MULTIPLIER+ const quotaWarningClass = quotaWarningType === 'warning' ? 'fill-amber-900' : 'fill-red-900'const yDomain = [yMin, yLimit ?? 0]const ticks =@@ -101,7 +104,7 @@ const BarChart = ({key={`cell-${attribute}-${idx}`}className={yLimit !== undefined && Number(entry[attribute]) >= yLimit- ? 'fill-amber-900'+ ? quotaWarningClass: 'fill-scale-1200'}/>@@ -131,4 +134,4 @@ const BarChart = ({)}-export default BarChart+export default UsageBarChart