mirror of
https://github.com/supabase/supabase.git
synced 2026-05-11 10:49:48 +08:00
Scripts currently use CJS, which is causing a bit of a mess when trying to use shared utilities from the app. Converting everything to ESM so there are fewer conflicts when adding new scripts going forward.
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import { pick } from 'lodash-es'
|
|
|
|
/**
|
|
* Gets the Notion team to send feedback to based on the pathname.
|
|
*/
|
|
const getLinearTeam = (pathname: string) => {
|
|
const DEFAULT_TEAM = 'Docs'
|
|
|
|
// Pathname has format `/guides/(team)/**`
|
|
const pathParts = pathname.split('/')
|
|
|
|
if (pathParts[1] !== 'guides' || !pathParts[2]) return DEFAULT_TEAM
|
|
|
|
switch (pathParts[2]) {
|
|
case 'database':
|
|
return 'Postgres'
|
|
case 'auth':
|
|
return 'Auth'
|
|
case 'storage':
|
|
return 'Storage'
|
|
case 'functions':
|
|
return 'Functions'
|
|
case 'realtime':
|
|
return 'Realtime'
|
|
case 'ai':
|
|
return 'AI'
|
|
case 'local-development':
|
|
case 'self-hosting':
|
|
case 'deployment':
|
|
return 'Dev Workflows'
|
|
case 'integrations':
|
|
return 'API'
|
|
case 'security':
|
|
return 'Security'
|
|
case 'platform':
|
|
case 'monitoring-troubleshooting':
|
|
return 'Infra'
|
|
default:
|
|
return DEFAULT_TEAM
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gets the tab selection state from the URL search params.
|
|
*
|
|
* Sanitizes by including only those search params that are explicitly marked
|
|
* as query groups.
|
|
*/
|
|
const getSanitizedTabParams = () => {
|
|
const searchParams = new URLSearchParams(window.location.search)
|
|
const queryGroups = searchParams.getAll('queryGroups')
|
|
|
|
return pick(Object.fromEntries(searchParams.entries()), queryGroups)
|
|
}
|
|
|
|
export { getLinearTeam, getSanitizedTabParams }
|