From 2bec311971bfc76fac2470920f909f2d2b92442e Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Wed, 23 Jul 2025 10:06:53 +0300 Subject: [PATCH] fix: Make the database.new redirect work (#37370) * Add a special case for /new/last-visited-org * Handle the case where last visited org is null. Don't show an admonition if the org slug is _. * Smol fix to disable oauth apps request if slug is _, and also dont prematurely show no perms UI state --------- Co-authored-by: Joshen Lim --- .../interfaces/Organization/OrgNotFound.tsx | 24 ++++++++++--------- apps/studio/pages/new/[slug].tsx | 18 ++++++++++++-- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/apps/studio/components/interfaces/Organization/OrgNotFound.tsx b/apps/studio/components/interfaces/Organization/OrgNotFound.tsx index 673c8e116c0..2da3c4f293d 100644 --- a/apps/studio/components/interfaces/Organization/OrgNotFound.tsx +++ b/apps/studio/components/interfaces/Organization/OrgNotFound.tsx @@ -15,17 +15,19 @@ export const OrgNotFound = ({ slug }: { slug?: string }) => { return ( <> - - The selected organization does not exist or you don't have permission to access it.{' '} - {slug ? ( - <> - Contact the owner or administrator to create a new project in the {slug}{' '} - organization. - - ) : ( - <>Contact the owner or administrator to create a new project. - )} - + {slug !== '_' && ( + + The selected organization does not exist or you don't have permission to access it.{' '} + {slug ? ( + <> + Contact the owner or administrator to create a new project in the {slug}{' '} + organization. + + ) : ( + <>Contact the owner or administrator to create a new project. + )} + + )}

Select an organization to create your new project from

diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsx index 2ba15120023..99d23500a1b 100644 --- a/apps/studio/pages/new/[slug].tsx +++ b/apps/studio/pages/new/[slug].tsx @@ -146,6 +146,15 @@ const Wizard: NextPageWithLayout = () => { '' ) + // This is to make the database.new redirect work correctly. The database.new redirect should be set to supabase.com/dashboard/new/last-visited-org + if (slug === 'last-visited-org') { + if (lastVisitedOrganization) { + router.replace(`/new/${lastVisitedOrganization}`, undefined, { shallow: true }) + } else { + router.replace(`/new/_`, undefined, { shallow: true }) + } + } + const { mutate: sendEvent } = useSendEventMutation() const projectCreationDisabled = useFlag('disableProjectCreationAndUpdate') @@ -156,7 +165,10 @@ const Wizard: NextPageWithLayout = () => { { enabled: isFreePlan } ) - const { data: approvedOAuthApps } = useAuthorizedAppsQuery({ slug }, { enabled: !isFreePlan }) + const { data: approvedOAuthApps } = useAuthorizedAppsQuery( + { slug }, + { enabled: !isFreePlan && slug !== '_' } + ) const hasOAuthApps = approvedOAuthApps && approvedOAuthApps.length > 0 @@ -623,7 +635,9 @@ const Wizard: NextPageWithLayout = () => { /> )} - {!isAdmin && !orgNotFound && } + {isOrganizationsSuccess && !isAdmin && !orgNotFound && ( + + )} {orgNotFound && }