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 <joshenlimek@gmail.com>
This commit is contained in:
Ivan VasilovandJoshen Lim authored and GitHub committed 2025-07-23 15:06:53 +08:00
1 parent 478ca3cb8e
commit 2bec311971
2 files changed
+29 -13

No files matched your search

@@ -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>
+16 -2
View File
@@ -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>