mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 23:49:03 +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>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
/**
|
|
* Builds an org-scoped URL for the wildcard org route (/org/_).
|
|
*
|
|
* When `slug` is undefined or empty, the destination is the org project list at
|
|
* /org/<orgSlug>. When `slug` has segments, the sub-path is preserved so the
|
|
* user lands on the equivalent page for the chosen org. A `hash` is kept so
|
|
* section deep links (e.g. /org/_/general#data-privacy) survive the picker.
|
|
*/
|
|
export function buildOrgUrl({
|
|
slug,
|
|
orgSlug,
|
|
queryString,
|
|
hash,
|
|
}: {
|
|
slug: string[] | undefined
|
|
orgSlug: string
|
|
queryString: string
|
|
hash?: string
|
|
}): string {
|
|
const qs = queryString ? `?${queryString}` : ''
|
|
const fragment = hash ? `#${hash.replace(/^#/, '')}` : ''
|
|
if (!slug?.length) {
|
|
return `/org/${orgSlug}${qs}${fragment}`
|
|
}
|
|
return `/org/${orgSlug}/${slug.join('/')}${qs}${fragment}`
|
|
}
|
|
|
|
// Invite is expired if older than 24hrs
|
|
export function isInviteExpired(timestamp: string) {
|
|
const inviteDate = new Date(timestamp)
|
|
const now = new Date()
|
|
const timeBetween = now.valueOf() - inviteDate.valueOf()
|
|
if (timeBetween / 1000 / 60 / 60 < 24) {
|
|
return false
|
|
}
|
|
return true
|
|
}
|