mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem There was no way to link straight to the Data privacy section (Supabase Assistant opt-in level) of an organization's general settings. The link could only point at the top of the page. The org picker behind `/org/_/<path>` also dropped any `#hash`, so a link that works without knowing the org slug couldn't reach a section. ## Solution The Data privacy section on organization general settings now has the `data-privacy` id, so Studio's hash scroll handling scrolls to it. The `/org/_` organization picker now keeps the URL hash when it sends the user to the chosen org, the same way it already keeps the path and query string. So `/org/_/general#data-privacy` lands on the opt-in setting for whichever org the user picks. ## How to verify 1. Open `/dashboard/org/<slug>/general#data-privacy` in the preview: the page scrolls to the Data privacy section with the Supabase Assistant Opt-in Level setting. 2. Open `/dashboard/org/_/general#data-privacy`, then pick an organization: the URL becomes `/dashboard/org/<slug>/general#data-privacy` and the page scrolls to Data privacy. 3. Open `/dashboard/org/_/general` with no hash, then pick an organization: the page opens at the top, as before. ## Checks Ran `tsc --noEmit` for apps/studio, eslint (both the standard and the type-checked config) on the changed files, `pnpm exec oxfmt --check` on the changed files, and `vitest run components/interfaces/Organization/Organization.utils.test.ts`, which has new cases for hash handling in `buildOrgUrl`. ## Checklist - [x] I have read the [Contributing Guidelines](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] I have checked that the change works in the preview deployment Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
98 lines
3.4 KiB
TypeScript
98 lines
3.4 KiB
TypeScript
import { useLocation } from '@tanstack/react-router'
|
|
import { cn } from 'ui'
|
|
import { PageContainer } from 'ui-patterns/PageContainer'
|
|
import {
|
|
PageHeader,
|
|
PageHeaderMeta,
|
|
PageHeaderSummary,
|
|
PageHeaderTitle,
|
|
} from 'ui-patterns/PageHeader'
|
|
import { PageSection } from 'ui-patterns/PageSection'
|
|
|
|
import {
|
|
Header,
|
|
LoadingCardView,
|
|
NoOrganizationsState,
|
|
} from '@/components/interfaces/Home/ProjectList/EmptyStates'
|
|
import { buildOrgUrl } from '@/components/interfaces/Organization/Organization.utils'
|
|
import { OrganizationCard } from '@/components/interfaces/Organization/OrganizationCard'
|
|
import { useOrganizationsQuery } from '@/data/organizations/organizations-query'
|
|
import { useCustomContent } from '@/hooks/custom-content/useCustomContent'
|
|
import { withAuth } from '@/hooks/misc/withAuth'
|
|
import { buildStudioPageTitle } from '@/lib/page-title'
|
|
|
|
function SelectOrganization() {
|
|
const { pathname, searchStr, hash } = useLocation()
|
|
// `/org/_/billing` → ['billing']; the splat route nests under the `/org/_` route,
|
|
// which renders this page, so the trailing path is read from the location
|
|
const trailingSegments = pathname
|
|
.replace(/^\/org\/_\/?/, '')
|
|
.split('/')
|
|
.filter(Boolean)
|
|
const routeSlug = trailingSegments.length > 0 ? trailingSegments : undefined
|
|
const { appTitle } = useCustomContent(['app:title'])
|
|
const queryString = searchStr.replace(/^\?/, '')
|
|
|
|
const { data: organizations, isPending: isLoading } = useOrganizationsQuery()
|
|
const pageTitle = buildStudioPageTitle({
|
|
section: 'Select an organization',
|
|
surface: 'Organizations',
|
|
brand: appTitle || 'Supabase',
|
|
})
|
|
|
|
return (
|
|
<>
|
|
<title>{pageTitle}</title>
|
|
<meta name="description" content="Supabase Studio" />
|
|
<Header />
|
|
<div className="flex w-full min-h-0 grow flex-col items-stretch">
|
|
<PageHeader>
|
|
<PageHeaderMeta>
|
|
<PageHeaderSummary>
|
|
<PageHeaderTitle>Select an organization to continue</PageHeaderTitle>
|
|
</PageHeaderSummary>
|
|
</PageHeaderMeta>
|
|
</PageHeader>
|
|
<PageContainer>
|
|
<PageSection className="last:pb-6">
|
|
<div
|
|
className="grow overflow-y-auto"
|
|
style={{ maxHeight: 'calc(100vh - 49px - 64px)' }}
|
|
>
|
|
<div className="w-full mx-auto flex flex-col gap-y-8">
|
|
{isLoading ? (
|
|
<LoadingCardView />
|
|
) : organizations?.length === 0 ? (
|
|
<NoOrganizationsState />
|
|
) : (
|
|
<ul
|
|
className={cn(
|
|
'w-full mx-auto grid grid-cols-1 gap-4',
|
|
'sm:grid-cols-1 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3'
|
|
)}
|
|
>
|
|
{organizations?.map((org) => (
|
|
<OrganizationCard
|
|
key={org.id}
|
|
organization={org}
|
|
href={buildOrgUrl({
|
|
slug: routeSlug,
|
|
orgSlug: org.slug,
|
|
queryString,
|
|
hash,
|
|
})}
|
|
/>
|
|
))}
|
|
</ul>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</PageSection>
|
|
</PageContainer>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export const SelectOrganizationPage = withAuth(SelectOrganization)
|