Skip to content

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

Add toggle to switch between old and new interfaces

Joshen Lima2b4e5647648
diff --git a/studio/components/interfaces/BillingV2/Usage/Activity.tsx b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
index d901ba22603..77422776165 100644
--- a/studio/components/interfaces/BillingV2/Usage/Activity.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
@@ -149,7 +149,7 @@ const Activity = ({ projectRef }: ActivityProps) => {
<SectionContent
key={attribute.key}
section={attribute}
- includedInPlan={usageMeta.available_in_plan}
+ includedInPlan={usageMeta?.available_in_plan}
>
<div className="space-y-2">
<div className="flex items-center justify-between">
@@ -211,7 +211,7 @@ const Activity = ({ projectRef }: ActivityProps) => {
</div>
</div>
</div>
- {usageMeta.available_in_plan && (
+ {usageMeta?.available_in_plan && (
<>
<div className="space-y-1">
<p>{attribute.name} over time</p>
diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.tsx b/studio/components/interfaces/BillingV2/Usage/Usage.tsx
index 69b744f0898..dc8e193dc62 100644
--- a/studio/components/interfaces/BillingV2/Usage/Usage.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Usage.tsx
@@ -6,7 +6,7 @@ import { useProjectSubscriptionQuery } from 'data/subscriptions/project-subscrip
import { useProjectUsageQuery } from 'data/usage/project-usage-query'
import Link from 'next/link'
import { useRef, useState } from 'react'
-import { Button, IconAlertCircle, IconCheckCircle, IconLoader, Listbox } from 'ui'
+import { Button, IconAlertCircle, IconCheckCircle, IconLoader, Listbox, Toggle } from 'ui'
import Activity from './Activity'
import Bandwidth from './Bandwidth'
import Infrastructure from './Infrastructure'
@@ -53,7 +53,6 @@ const Usage = () => {
<div className="border-b">
<div className="1xl:px-28 mx-auto flex flex-col px-5 lg:px-16 2xl:px-32 pt-6 space-y-4">
<h3 className="text-scale-1200 text-xl">Usage</h3>
-
<div className="flex items-center justify-between">
<div className="flex items-center space-x-4">
<Listbox
diff --git a/studio/pages/project/[ref]/settings/billing/usage.tsx b/studio/pages/project/[ref]/settings/billing/usage.tsx
index 94d6c7d5db0..5d41670e8e0 100644
--- a/studio/pages/project/[ref]/settings/billing/usage.tsx
+++ b/studio/pages/project/[ref]/settings/billing/usage.tsx
@@ -1,7 +1,7 @@
import dayjs from 'dayjs'
import { observer } from 'mobx-react-lite'
import { useEffect, useState } from 'react'
-import { IconArrowRight, Loading } from 'ui'
+import { IconArrowRight, Loading, Toggle } from 'ui'
import { NextPageWithLayout } from 'types'
import { useStore, useFlag } from 'hooks'
@@ -15,15 +15,30 @@ import ProjectUsageBars from 'components/interfaces/Settings/ProjectUsageBars/Pr
import Usage from 'components/interfaces/BillingV2/Usage/Usage'
const ProjectBillingUsage: NextPageWithLayout = () => {
- const showNewUsageUI = useFlag('usagev2')
-
- if (showNewUsageUI) return <Usage />
+ const enableUsageV2 = useFlag('usagev2')
+ const [showNewUsageUI, setShowNewUsageUI] = useState(enableUsageV2)
return (
- <div className="w-full h-full overflow-y-auto content">
- <div className="w-full mx-auto">
- <Settings />
- </div>
+ <div className="relative">
+ {enableUsageV2 && (
+ <div className="absolute top-[1.9rem] right-16 flex items-center space-x-3">
+ <Toggle
+ size="tiny"
+ checked={showNewUsageUI}
+ onChange={() => setShowNewUsageUI(!showNewUsageUI)}
+ />
+ <p className="text-xs text-scale-1100 -translate-y-[1px]">Preview new interface</p>
+ </div>
+ )}
+ {enableUsageV2 && showNewUsageUI ? (
+ <Usage />
+ ) : (
+ <div className="w-full h-full overflow-y-auto content">
+ <div className="w-full mx-auto">
+ <Settings />
+ </div>
+ </div>
+ )}
</div>
)
}