Skip to content

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

Small refactor in OrganizationDropdown

Joshen Lim1fbd7c8240c2
diff --git a/studio/components/layouts/AppLayout/AppHeader.tsx b/studio/components/layouts/AppLayout/AppHeader.tsx
index 60feb13dbfe..5ea83c6e56a 100644
--- a/studio/components/layouts/AppLayout/AppHeader.tsx
+++ b/studio/components/layouts/AppLayout/AppHeader.tsx
@@ -37,7 +37,7 @@ const AppHeader = () => {
<FeedbackDropdown alt />
<NotificationsPopover alt />
<HelpPopover alt />
- <SettingsButton slug={organization?.slug ?? ''} />
+ <SettingsButton />
</div>
<div className="flex items-center gap-3">
<UserSettingsDropdown />
diff --git a/studio/components/layouts/AppLayout/OrganizationDropdown.tsx b/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
index f5408e47440..035e4073307 100644
--- a/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
+++ b/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
@@ -32,7 +32,11 @@ const OrganizationDropdown = () => {
const slug = selectedOrganization?.slug
const orgName = selectedOrganization?.name
- const { data: subscription, isSuccess } = useOrgSubscriptionQuery({ orgSlug: slug })
+ const isOrgBilling = !!selectedOrganization?.subscription_id
+ const { data: subscription, isSuccess } = useOrgSubscriptionQuery(
+ { orgSlug: slug },
+ { enabled: isOrgBilling }
+ )
const [open, setOpen] = useState(false)
const popoverOffset = (orgNameRef.current?.offsetWidth ?? 0) + 12
diff --git a/studio/components/layouts/AppLayout/SettingsButton.tsx b/studio/components/layouts/AppLayout/SettingsButton.tsx
index ef22d069887..7576d779903 100644
--- a/studio/components/layouts/AppLayout/SettingsButton.tsx
+++ b/studio/components/layouts/AppLayout/SettingsButton.tsx
@@ -1,11 +1,15 @@
-import Link from 'next/link'
-import { Button, IconSettings } from 'ui'
import * as Tooltip from '@radix-ui/react-tooltip'
+import { useSelectedOrganization } from 'hooks'
+import Link from 'next/link'
+import { IconSettings } from 'ui'
+
+const SettingsButton = () => {
+ const selectedOrganization = useSelectedOrganization()
+ const slug = selectedOrganization?.slug
-const SettingsButton = ({ slug }: { slug: string }) => {
return (
<Tooltip.Root delayDuration={0}>
- <Link href={`/org/${slug}/general`} passHref>
+ <Link href={slug ? `/org/${slug}/general` : '/'} passHref>
<Tooltip.Trigger type="button" asChild className="px-1">
<a>
<IconSettings size={18} strokeWidth={1.5} className="text-scale-1100" />