mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
24e8333c54
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Adds feature flag for controlling region unavailability. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Region options now display availability badges, tooltips, and status-specific notices. * Restricted regions remain selectable so users can review their availability status. * Project creation provides a clear field-level message when a selected region is unavailable and prompts users to choose another region. * **Bug Fixes** * Region availability messaging now consistently reflects platform status and configured restrictions. * Availability warnings clear after selecting an eligible region. * Region checks now cover both dynamic and static provider regions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
32 lines
797 B
TypeScript
32 lines
797 B
TypeScript
import { useFlag } from 'common'
|
|
import { useMemo } from 'react'
|
|
|
|
import {
|
|
parseRestrictedRegions,
|
|
resolveRegionRestriction,
|
|
RESTRICTED_REGIONS_FLAG_KEY,
|
|
} from './RegionSelector.utils'
|
|
|
|
type RegionLike = {
|
|
code: string
|
|
status?: string
|
|
}
|
|
|
|
export function useRegionRestriction() {
|
|
const restrictedRegionsFlag = useFlag<string | boolean>(RESTRICTED_REGIONS_FLAG_KEY)
|
|
const restrictedRegions = useMemo(
|
|
() => parseRestrictedRegions(restrictedRegionsFlag),
|
|
[restrictedRegionsFlag]
|
|
)
|
|
|
|
const getRegionRestriction = (region: RegionLike | undefined) =>
|
|
region === undefined
|
|
? undefined
|
|
: resolveRegionRestriction({
|
|
platformStatus: region.status,
|
|
flagRestriction: restrictedRegions[region.code],
|
|
})
|
|
|
|
return { getRegionRestriction }
|
|
}
|