mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 07:59: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>
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import { describe, expect, test } from 'vitest'
|
|
|
|
import { buildOrgUrl } from './Organization.utils'
|
|
|
|
describe('buildOrgUrl', () => {
|
|
describe('when slug is undefined (bare /org/_ route)', () => {
|
|
test('returns the org project list url', () => {
|
|
expect(buildOrgUrl({ slug: undefined, orgSlug: 'my-org', queryString: '' })).toBe(
|
|
'/org/my-org'
|
|
)
|
|
})
|
|
|
|
test('appends query string when present', () => {
|
|
expect(buildOrgUrl({ slug: undefined, orgSlug: 'my-org', queryString: 'foo=bar' })).toBe(
|
|
'/org/my-org?foo=bar'
|
|
)
|
|
})
|
|
|
|
test('does not append a bare ? when query string is empty', () => {
|
|
expect(buildOrgUrl({ slug: undefined, orgSlug: 'my-org', queryString: '' })).not.toContain(
|
|
'?'
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('when slug is an array (sub-path route)', () => {
|
|
test('preserves a single-segment sub-path', () => {
|
|
expect(buildOrgUrl({ slug: ['general'], orgSlug: 'my-org', queryString: '' })).toBe(
|
|
'/org/my-org/general'
|
|
)
|
|
})
|
|
|
|
test('preserves a multi-segment sub-path', () => {
|
|
expect(
|
|
buildOrgUrl({ slug: ['settings', 'billing'], orgSlug: 'my-org', queryString: '' })
|
|
).toBe('/org/my-org/settings/billing')
|
|
})
|
|
|
|
test('appends query string when present', () => {
|
|
expect(
|
|
buildOrgUrl({ slug: ['general'], orgSlug: 'my-org', queryString: 'foo=1&bar=2' })
|
|
).toBe('/org/my-org/general?foo=1&bar=2')
|
|
})
|
|
|
|
test('does not append a bare ? when query string is empty', () => {
|
|
expect(buildOrgUrl({ slug: ['general'], orgSlug: 'my-org', queryString: '' })).not.toContain(
|
|
'?'
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('when a hash is present', () => {
|
|
test('keeps the hash on a sub-path', () => {
|
|
expect(
|
|
buildOrgUrl({
|
|
slug: ['general'],
|
|
orgSlug: 'my-org',
|
|
queryString: '',
|
|
hash: 'data-privacy',
|
|
})
|
|
).toBe('/org/my-org/general#data-privacy')
|
|
})
|
|
|
|
test('puts the hash after the query string', () => {
|
|
expect(
|
|
buildOrgUrl({
|
|
slug: ['general'],
|
|
orgSlug: 'my-org',
|
|
queryString: 'foo=bar',
|
|
hash: '#data-privacy',
|
|
})
|
|
).toBe('/org/my-org/general?foo=bar#data-privacy')
|
|
})
|
|
|
|
test('does not append a bare # when the hash is empty', () => {
|
|
expect(
|
|
buildOrgUrl({ slug: ['general'], orgSlug: 'my-org', queryString: '', hash: '' })
|
|
).not.toContain('#')
|
|
})
|
|
})
|
|
})
|