import PartnerIcon from 'components/ui/PartnerIcon' import { PARTNER_TO_NAME } from 'components/ui/PartnerManagedResource' import { useAwsRedirectQuery } from 'data/integrations/aws-redirect-query' import { useVercelRedirectQuery } from 'data/integrations/vercel-redirect-query' import { useCustomContent } from 'hooks/custom-content/useCustomContent' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { withAuth } from 'hooks/misc/withAuth' import { MANAGED_BY } from 'lib/constants/infrastructure' import { buildStudioPageTitle } from 'lib/page-title' import { ExternalLink } from 'lucide-react' import Head from 'next/head' import { useRouter } from 'next/router' import type { PropsWithChildren } from 'react' import { Alert_Shadcn_, AlertTitle_Shadcn_, Button, cn } from 'ui' import { useRegisterOrgMenu } from './OrganizationLayout/useRegisterOrgMenu' interface OrganizationLayoutProps { title: string } // [Joshen] Just for page title generation for org settings pages const settingsPages = ['general', 'security', 'sso', 'apps', 'audit', 'documents'] const OrganizationLayoutContent = ({ children, title, }: PropsWithChildren) => { const router = useRouter() const { data: selectedOrganization } = useSelectedOrganizationQuery() const { appTitle } = useCustomContent(['app:title']) // Keep title intent close to each page (getLayout) to avoid route-to-title drift in this layout. const isSettingsSurface = settingsPages.some((x) => router.pathname.endsWith(x)) const pageTitle = buildStudioPageTitle({ section: title, surface: isSettingsSurface ? 'Organization Settings' : undefined, org: selectedOrganization?.name, brand: appTitle || 'Supabase', }) const vercelQuery = useVercelRedirectQuery( { installationId: selectedOrganization?.partner_id }, { enabled: selectedOrganization?.managed_by === MANAGED_BY.VERCEL_MARKETPLACE } ) const awsQuery = useAwsRedirectQuery( { organizationSlug: selectedOrganization?.slug }, { enabled: selectedOrganization?.managed_by === MANAGED_BY.AWS_MARKETPLACE } ) // Select the appropriate query based on partner const { data, isSuccess } = selectedOrganization?.managed_by === MANAGED_BY.AWS_MARKETPLACE ? awsQuery : vercelQuery return (
{pageTitle && ( {pageTitle} )} {selectedOrganization && selectedOrganization?.managed_by !== 'supabase' && ( This organization is managed by {PARTNER_TO_NAME[selectedOrganization.managed_by]}. )}
{children}
) } const OrganizationLayout = ({ children, title }: PropsWithChildren) => { useRegisterOrgMenu() return {children} } export default withAuth(OrganizationLayout)