diff --git a/apps/code/src/renderer/features/auth/components/OAuthControls.tsx b/apps/code/src/renderer/features/auth/components/OAuthControls.tsx index 421e354e7..e6e15b2b8 100644 --- a/apps/code/src/renderer/features/auth/components/OAuthControls.tsx +++ b/apps/code/src/renderer/features/auth/components/OAuthControls.tsx @@ -1,7 +1,6 @@ import { useOAuthFlow } from "@features/auth/hooks/useOAuthFlow"; import { Callout, Flex, Spinner } from "@radix-ui/themes"; import posthogIcon from "@renderer/assets/images/posthog-icon.svg"; -import { REGION_LABELS } from "@shared/types/regions"; import { RegionSelect } from "./RegionSelect"; export function OAuthControls() { @@ -15,7 +14,13 @@ export function OAuthControls() { } = useOAuthFlow(); return ( - <> + + + {errorMessage && ( {errorMessage} @@ -50,15 +55,6 @@ export function OAuthControls() { )} {isPending ? "Cancel" : "Sign in / sign up with PostHog"} - - - - - + ); } diff --git a/apps/code/src/renderer/features/auth/components/RegionSelect.tsx b/apps/code/src/renderer/features/auth/components/RegionSelect.tsx index 46126463d..ee00c1497 100644 --- a/apps/code/src/renderer/features/auth/components/RegionSelect.tsx +++ b/apps/code/src/renderer/features/auth/components/RegionSelect.tsx @@ -1,82 +1,82 @@ -import { Flex, Select, Text } from "@radix-ui/themes"; +import { Flex, Text } from "@radix-ui/themes"; import { IS_DEV } from "@shared/constants/environment"; -import type { CloudRegion } from "@shared/types/regions"; -import { useState } from "react"; +import { type CloudRegion, REGION_LABELS } from "@shared/types/regions"; interface RegionSelectProps { region: CloudRegion; - regionLabel: string; onRegionChange: (region: CloudRegion) => void; disabled?: boolean; } +const LOGIN_GRID_REGIONS: CloudRegion[] = ["us", "eu"]; + export function RegionSelect({ region, - regionLabel, onRegionChange, disabled = false, }: RegionSelectProps) { - const [expanded, setExpanded] = useState(false); - - if (!expanded) { - return ( - - - {regionLabel} - {" \u00B7 "} - - - - ); - } - return ( - + - + PostHog region - - + + Pick where your data lives - { - onRegionChange(value as CloudRegion); - setExpanded(false); - }} - size="2" - disabled={disabled} - > - - - US Cloud - EU Cloud - {IS_DEV && Development} - - +
+ {LOGIN_GRID_REGIONS.map((regionKey) => ( + onRegionChange(regionKey)} + /> + ))} +
+ {IS_DEV && ( + onRegionChange("dev")} + /> + )}
); } + +function RegionPickerOptionButton({ + regionKey, + selected, + disabled, + onSelect, +}: { + regionKey: CloudRegion; + selected: boolean; + disabled: boolean; + onSelect: () => void; +}) { + const { flag, label, hint } = REGION_LABELS[regionKey]; + return ( + + ); +} diff --git a/apps/code/src/renderer/features/settings/components/sections/AccountSettings.tsx b/apps/code/src/renderer/features/settings/components/sections/AccountSettings.tsx index 0fcd3265d..31c7705ad 100644 --- a/apps/code/src/renderer/features/settings/components/sections/AccountSettings.tsx +++ b/apps/code/src/renderer/features/settings/components/sections/AccountSettings.tsx @@ -7,7 +7,7 @@ import { import { useSeat } from "@hooks/useSeat"; import { SignOut } from "@phosphor-icons/react"; import { Avatar, Badge, Button, Flex, Spinner, Text } from "@radix-ui/themes"; -import { REGION_LABELS } from "@shared/types/regions"; +import { formatRegionBadge } from "@shared/types/regions"; export function AccountSettings() { const isAuthenticated = useAuthStateValue( @@ -66,7 +66,7 @@ export function AccountSettings() { {cloudRegion && ( - {REGION_LABELS[cloudRegion]} + {formatRegionBadge(cloudRegion)} )} {seat && ( diff --git a/apps/code/src/shared/types/regions.ts b/apps/code/src/shared/types/regions.ts index af8cc5b52..65bcb3f70 100644 --- a/apps/code/src/shared/types/regions.ts +++ b/apps/code/src/shared/types/regions.ts @@ -1,7 +1,30 @@ export type CloudRegion = "us" | "eu" | "dev"; -export const REGION_LABELS: Record = { - us: "πŸ‡ΊπŸ‡Έ US Cloud", - eu: "πŸ‡ͺπŸ‡Ί EU Cloud", - dev: "πŸ› οΈ Development", +export interface RegionLabel { + flag: string; + label: string; + hint: string; +} + +export const REGION_LABELS: Record = { + us: { + flag: "πŸ‡ΊπŸ‡Έ", + label: "US Cloud", + hint: "us.posthog.com", + }, + eu: { + flag: "πŸ‡ͺπŸ‡Ί", + label: "EU Cloud", + hint: "eu.posthog.com", + }, + dev: { + flag: "πŸ› οΈ", + label: "Local development", + hint: "localhost:8010", + }, }; + +export function formatRegionBadge(region: CloudRegion): string { + const entry = REGION_LABELS[region]; + return `${entry.flag} ${entry.label}`; +}