Skip to content

Commit bd95e9a

Browse files
authored
Chore/link to usage (supabase#36404)
* Add link to usage page * Add usage button
1 parent 7f39249 commit bd95e9a

File tree

1 file changed

+26
-0
lines changed
  • apps/studio/components/interfaces/Organization/BillingSettings

1 file changed

+26
-0
lines changed

apps/studio/components/interfaces/Organization/BillingSettings/Restriction.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
77
import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button } from 'ui'
88
import { CriticalIcon, WarningIcon } from 'ui'
99
import { PricingMetric } from 'data/analytics/org-daily-stats-query'
10+
import { usePathname } from 'next/navigation'
1011

1112
export const Restriction = () => {
1213
const org = useSelectedOrganization()
1314
const { data: usage, isSuccess: isSuccessOrgUsage } = useOrgUsageQuery({ orgSlug: org?.slug })
1415

16+
const pathname = usePathname()
17+
const isUsagePage = pathname?.endsWith('/usage')
18+
1519
const hasExceededAnyLimits = Boolean(
1620
usage?.usages.find(
1721
(metric) =>
@@ -69,6 +73,11 @@ export const Restriction = () => {
6973
{org.plan.id === 'free' ? 'Upgrade plan' : 'Change spend cap'}
7074
</Link>
7175
</Button>
76+
{!isUsagePage && (
77+
<Button key="view-usage-button" asChild type="default">
78+
<Link href={`/org/${org?.slug}/usage`}>View usage</Link>
79+
</Button>
80+
)}
7281
<Button asChild type="default" icon={<ExternalLink />}>
7382
<a href="https://supabase.com/docs/guides/platform/cost-control#spend-cap">
7483
About spend cap
@@ -106,6 +115,13 @@ export const Restriction = () => {
106115
{org.plan.id === 'free' ? 'Upgrade plan' : 'Disable spend cap'}
107116
</Link>
108117
</Button>
118+
119+
{!isUsagePage && (
120+
<Button key="view-usage-button" asChild type="default">
121+
<Link href={`/org/${org?.slug}/usage`}>View usage</Link>
122+
</Button>
123+
)}
124+
109125
<Button asChild type="default" icon={<ExternalLink />}>
110126
<a href="https://supabase.com/docs/guides/platform/billing-faq#fair-use-policy">
111127
About Fair Use Policy
@@ -141,6 +157,11 @@ export const Restriction = () => {
141157
{org.plan.id === 'free' ? 'Upgrade plan' : 'Disable spend cap'}
142158
</Link>
143159
</Button>
160+
{!isUsagePage && (
161+
<Button key="view-usage-button" asChild type="default">
162+
<Link href={`/org/${org?.slug}/usage`}>View usage</Link>
163+
</Button>
164+
)}
144165
<Button asChild type="default" icon={<ExternalLink />}>
145166
<a href="https://supabase.com/docs/guides/platform/billing-faq#fair-use-policy">
146167
About Fair Use Policy
@@ -177,6 +198,11 @@ export const Restriction = () => {
177198
{org.plan.id === 'free' ? 'Upgrade plan' : 'Disable spend cap'}
178199
</Link>
179200
</Button>
201+
{!isUsagePage && (
202+
<Button key="view-usage-button" asChild type="default">
203+
<Link href={`/org/${org?.slug}/usage`}>View usage</Link>
204+
</Button>
205+
)}
180206
<Button asChild type="default" icon={<ExternalLink />}>
181207
<a href="https://supabase.com/docs/guides/platform/billing-faq#fair-use-policy">
182208
About Fair Use Policy

0 commit comments

Comments
 (0)