Skip to content

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

fix: Make the database.new redirect work (#37370)

Ivan Vasilov2bec311971bf
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 (
<>
- <Admonition type="danger">
- 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 <code>{slug}</code>{' '}
- organization.
- </>
- ) : (
- <>Contact the owner or administrator to create a new project.</>
- )}
- </Admonition>
+ {slug !== '_' && (
+ <Admonition type="danger">
+ 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 <code>{slug}</code>{' '}
+ organization.
+ </>
+ ) : (
+ <>Contact the owner or administrator to create a new project.</>
+ )}
+ </Admonition>
+ )}
<h3 className="text-sm">Select an organization to create your new project from</h3>
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 && <NotOrganizationOwnerWarning slug={slug} />}
+ {isOrganizationsSuccess && !isAdmin && !orgNotFound && (
+ <NotOrganizationOwnerWarning slug={slug} />
+ )}
{orgNotFound && <OrgNotFound slug={slug} />}
</Panel.Content>