Skip to content

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

chore: improve project nav with org-billing

Kevin Grünebergefb3febc45f2
diff --git a/studio/components/interfaces/Organization/Usage/Usage.tsx b/studio/components/interfaces/Organization/Usage/Usage.tsx
index aeb0ab2933e..342a56a95e5 100644
--- a/studio/components/interfaces/Organization/Usage/Usage.tsx
+++ b/studio/components/interfaces/Organization/Usage/Usage.tsx
@@ -11,10 +11,12 @@ import { useProjectsQuery } from 'data/projects/projects-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useSelectedOrganization } from 'hooks'
import { TIME_PERIODS_BILLING, TIME_PERIODS_REPORTS } from 'lib/constants'
-import { Listbox } from 'ui'
+import { Button, IconExternalLink, IconInfo, Listbox } from 'ui'
import Activity from './Activity'
import Bandwidth from './Bandwidth'
import SizeAndCounts from './SizeAndCounts'
+import InformationBox from 'components/ui/InformationBox'
+import Link from 'next/link'
const Usage = () => {
const { slug, projectRef } = useParams()
@@ -122,8 +124,8 @@ const Usage = () => {
<Listbox.Option
key="all-projects"
id="all-projects"
- value="all-projects"
label="All projects"
+ value="all-projects"
>
All projects
</Listbox.Option>
@@ -153,6 +155,36 @@ const Usage = () => {
</div>
</ScaffoldContainer>
+ {selectedProjectRef && (
+ <ScaffoldContainer className="mt-5">
+ <InformationBox
+ title="Usage filtered by project"
+ description={
+ <div className="space-y-3">
+ <p>
+ You are currently viewing usage for a specific project. Since your organization is
+ using the new organization-level-billing, the included quota is for your whole
+ organization and not per-project. For billing purposes, we sum up usage from all
+ your projects. To view your usage quota, remove the project filter.
+ </p>
+ <div>
+ <Link href="https://www.notion.so/supabase/Organization-Level-Billing-9c159d69375b4af095f0b67881276582?pvs=4">
+ <a target="_blank" rel="noreferrer">
+ <Button type="default" icon={<IconExternalLink strokeWidth={1.5} />}>
+ Documentation
+ </Button>
+ </a>
+ </Link>
+ </div>
+ </div>
+ }
+ defaultVisibility
+ hideCollapse
+ icon={<IconInfo />}
+ />
+ </ScaffoldContainer>
+ )}
+
<Bandwidth
orgSlug={slug as string}
projectRef={selectedProjectRef}
diff --git a/studio/components/layouts/ProjectSettingsLayout/SettingsLayout.tsx b/studio/components/layouts/ProjectSettingsLayout/SettingsLayout.tsx
index 2793fa28c80..56adaff0c5a 100644
--- a/studio/components/layouts/ProjectSettingsLayout/SettingsLayout.tsx
+++ b/studio/components/layouts/ProjectSettingsLayout/SettingsLayout.tsx
@@ -18,7 +18,7 @@ const SettingsLayout = ({ title, children }: PropsWithChildren<SettingsLayoutPro
const { ui, meta } = useStore()
const project = useSelectedProject()
const organization = useSelectedOrganization()
- const isOrgBilling = !!organization?.subscription_id
+
// billing pages live under /billing/invoices and /billing/subscription, etc
// so we need to pass the [5]th part of the url to the menu
@@ -27,7 +27,7 @@ const SettingsLayout = ({ title, children }: PropsWithChildren<SettingsLayoutPro
: router.pathname.split('/')[4]
const isVaultEnabled = useFlag('vaultExtension')
- const menuRoutes = generateSettingsMenu(ref, project, isVaultEnabled, isOrgBilling)
+ const menuRoutes = generateSettingsMenu(ref, project, organization, isVaultEnabled)
useEffect(() => {
if (ui.selectedProjectRef) {
diff --git a/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.ts b/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.ts
index bf9ebf7cfaf..7d0dedac8b0 100644
--- a/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.ts
+++ b/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.ts
@@ -1,16 +1,18 @@
-import { ProjectBase } from 'types'
+import { Organization, ProjectBase } from 'types'
import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
import { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'
export const generateSettingsMenu = (
ref?: string,
project?: ProjectBase,
- isVaultEnabled: boolean = false,
- isOrgBilling: boolean = false
+ organization?: Organization,
+ isVaultEnabled: boolean = false
): ProductMenuGroup[] => {
const isProjectBuilding = project?.status === PROJECT_STATUS.COMING_UP
const buildingUrl = `/project/${ref}/building`
+ const isOrgBilling = !!organization?.subscription_id
+
if (isOrgBilling) {
return [
{
@@ -84,6 +86,24 @@ export const generateSettingsMenu = (
: []),
],
},
+
+ {
+ title: 'Billing',
+ items: [
+ {
+ name: 'Subscription',
+ key: 'subscription',
+ url: `/org/${organization?.slug}/billing`,
+ items: [],
+ },
+ {
+ name: 'Usage',
+ key: 'usage',
+ url: `/org/${organization?.slug}/usage?projectRef=${ref}`,
+ items: [],
+ },
+ ],
+ },
]
} else {
return [