Files
supabase/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants.ts
T
Joshen LimandJonathan Summers-Muir 3620ca8ebe RR Scaffolding Work (#18658)
* Init demo world map for read replicas

* Update package.json

* Scaffold and mock data for flow view of project settings infrastructure configuration

* Shift map stuff and install deck.gl to experiment

* Flesh out map view a bit more

* Scaffold deploy new replica panel

* Add restart replica option

* Add animations, shift node generation into utils, attempt to show region nodes

* Experiments

* General improvement to chart and map UI

* Improve some copy writing for restart and drop replica modals

* Simplify loading, error, success states in DatabaseSettings

* Scaffold DB selection in connection string section

* Link replica node to connection string

* Scaffold database selection for SQL editor

* Make DatabaseSelector into a component

* Add database selector to infra activity

* Update

* Hide read replicas UI behind a feature flag

* Update flags

* Update package-lock

---------

Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
2023-11-27 12:50:19 +08:00

143 lines
3.6 KiB
TypeScript

import { AWS_REGIONS, AWS_REGIONS_KEYS } from 'lib/constants'
export interface DatabaseConfiguration {
id: number
type: 'PRIMARY' | 'READ_REPLICA'
cloud_provider: 'AWS' | 'FLY'
region: string
size: string
status: string
inserted_at: string
}
export interface Region {
key: AWS_REGIONS_KEYS
name: string
region: string
coordinates: [number, number]
}
// ReactFlow is scaling everything by the factor of 2
export const NODE_WIDTH = 560
export const NODE_ROW_HEIGHT = 50
export const NODE_SEP = 20
export const MOCK_DATABASES: DatabaseConfiguration[] = [
{
id: 1,
type: 'PRIMARY',
cloud_provider: 'AWS',
region: 'ap-southeast-1b',
size: 't4g.micro',
status: 'ACTIVE_HEALTHY',
inserted_at: '2023-11-01 06:47:46.837002',
},
{
id: 2,
type: 'READ_REPLICA',
cloud_provider: 'AWS',
region: 'ap-northeast-1',
size: 't4g.micro',
status: 'ACTIVE_HEALTHY',
inserted_at: '2023-11-01 06:47:46.837002',
},
{
id: 3,
type: 'READ_REPLICA',
cloud_provider: 'AWS',
region: 'ap-southeast-1b',
size: 't4g.micro',
status: 'ACTIVE_HEALTHY',
inserted_at: '2023-11-01 06:47:46.837002',
},
{
id: 4,
type: 'READ_REPLICA',
cloud_provider: 'AWS',
region: 'ap-northeast-2',
size: 't4g.micro',
status: 'ACTIVE_HEALTHY',
inserted_at: '2023-11-01 06:47:46.837002',
},
{
id: 5,
type: 'READ_REPLICA',
cloud_provider: 'AWS',
region: 'eu-central-1',
size: 't4g.micro',
status: 'ACTIVE_HEALTHY',
inserted_at: '2023-11-01 06:47:46.837002',
},
{
id: 6,
type: 'READ_REPLICA',
cloud_provider: 'AWS',
region: 'eu-central-1',
size: 't4g.micro',
status: 'ACTIVE_HEALTHY',
inserted_at: '2023-11-01 06:47:46.837002',
},
{
id: 7,
type: 'READ_REPLICA',
cloud_provider: 'AWS',
region: 'ap-southeast-1',
size: 't4g.micro',
status: 'ACTIVE_HEALTHY',
inserted_at: '2023-11-01 06:47:46.837002',
},
{
id: 8,
type: 'READ_REPLICA',
cloud_provider: 'AWS',
region: 'ap-southeast-1',
size: 't4g.micro',
status: 'ACTIVE_HEALTHY',
inserted_at: '2023-11-01 06:47:46.837002',
},
]
// [Joshen] Coordinates from https://github.com/jsonmaur/aws-regions/issues/11
const AWS_REGIONS_COORDINATES: { [key: string]: [number, number] } = {
SOUTHEAST_ASIA: [103.8, 1.37],
NORTHEAST_ASIA: [139.42, 35.41],
NORTHEAST_ASIA_2: [126.98, 37.56],
CENTRAL_CANADA: [-73.6, 45.5],
WEST_US: [-121.96, 37.35],
EAST_US: [-78.45, 38.13],
WEST_EU: [-8, 53],
WEST_EU_2: [-0.1, 51],
CENTRAL_EU: [8, 50],
SOUTH_ASIA: [72.88, 19.08],
OCEANIA: [151.2, -33.86],
SOUTH_AMERICA: [-46.38, -23.34],
}
const AWS_REGIONS_VALUES: { [key: string]: string } = {
SOUTHEAST_ASIA: 'ap-southeast-1',
NORTHEAST_ASIA: 'ap-northeast-1',
NORTHEAST_ASIA_2: 'ap-northeast-2',
CENTRAL_CANADA: 'ca-central-1',
WEST_US: 'us-west-1',
EAST_US: 'es-east-1',
WEST_EU: 'eu-west-1',
WEST_EU_2: 'eu-west-2',
CENTRAL_EU: 'eu-central-1',
SOUTH_ASIA: 'ap-south-1',
OCEANIA: 'ap-southeast-2',
SOUTH_AMERICA: 'sa-east-1',
}
// [Joshen] Just to make sure that we just depend on AWS_REGIONS to determine available
// regions for replicas. Just FYI - might need to update this if we support Fly in future
export const AVAILABLE_REPLICA_REGIONS: Region[] = Object.keys(AWS_REGIONS)
.map((key) => {
return {
key: key as AWS_REGIONS_KEYS,
name: AWS_REGIONS[key as AWS_REGIONS_KEYS],
region: AWS_REGIONS_VALUES[key],
coordinates: AWS_REGIONS_COORDINATES[key],
}
})
.filter((x) => x.coordinates !== undefined)