mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 23:29:08 +03:00
* Add restrictions for orioledb technical preview * Add callouts to pgvector and postgis if orioledb * Restrict restore to new project for orioledb * Scaffold client side validation for preventing org upgrade if org has oriole db present * Hook up proper logic for oriole * Fix * Remove console log * Fix type * Disable version selector if only one version is available * chore: oriole badges * UI updates based on requests * Update copy * Fix * Dont open assistant if opt is selected * Fix * Fix * Update badge * Add feature flag for orioleDB * Feature flag oriole check in plan update --------- Co-authored-by: Paul Cioanca <paul.cioanca@supabase.io>
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import { useIsLoggedIn, useParams } from 'common'
|
|
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
|
|
import { useMemo } from 'react'
|
|
|
|
import { LOCAL_STORAGE_KEYS } from 'lib/constants'
|
|
import { useProjectByRef } from './useSelectedProject'
|
|
import { useOrganizationQuery } from 'data/organizations/organization-query'
|
|
|
|
// [Joshen] Scaffolding this first - will need to double check if this can replace useSelectedOrganization
|
|
export function useSelectedOrganizationV2({ enabled = true } = {}) {
|
|
const isLoggedIn = useIsLoggedIn()
|
|
const { ref, slug } = useParams()
|
|
|
|
const selectedProject = useProjectByRef(ref)
|
|
const localStorageSlug = useMemo(() => {
|
|
return typeof window !== 'undefined'
|
|
? localStorage.getItem(LOCAL_STORAGE_KEYS.RECENTLY_VISITED_ORGANIZATION)
|
|
: null
|
|
}, [])
|
|
|
|
const orgSlug = slug ?? selectedProject?.organization_slug ?? localStorageSlug
|
|
const { data } = useOrganizationQuery(
|
|
{ slug: orgSlug as string },
|
|
{ enabled: enabled && isLoggedIn && typeof orgSlug === 'string' }
|
|
)
|
|
|
|
return useMemo(() => {
|
|
return data
|
|
}, [data, slug, selectedProject, localStorageSlug])
|
|
}
|
|
|
|
export function useSelectedOrganization({ enabled = true } = {}) {
|
|
const isLoggedIn = useIsLoggedIn()
|
|
|
|
const { ref, slug } = useParams()
|
|
const { data } = useOrganizationsQuery({ enabled: isLoggedIn && enabled })
|
|
|
|
const selectedProject = useProjectByRef(ref)
|
|
|
|
const localStorageSlug = useMemo(() => {
|
|
return typeof window !== 'undefined'
|
|
? localStorage.getItem(LOCAL_STORAGE_KEYS.RECENTLY_VISITED_ORGANIZATION)
|
|
: null
|
|
}, [])
|
|
|
|
return useMemo(() => {
|
|
return data?.find((org) => {
|
|
if (slug !== undefined) return org.slug === slug
|
|
if (selectedProject !== undefined) return org.id === selectedProject.organization_id
|
|
if (localStorageSlug !== undefined) return org.slug === localStorageSlug
|
|
return undefined
|
|
})
|
|
}, [data, selectedProject, slug, localStorageSlug])
|
|
}
|