From df4d9ab7f165521dcce1df2446cde618f881836f Mon Sep 17 00:00:00 2001 From: Banks Nussman Date: Wed, 12 Apr 2023 14:16:51 -0400 Subject: [PATCH 1/7] add france to eupore list --- .../variants/RegionSelect/RegionSelect.tsx | 47 +++++-------------- .../variants/RegionSelect/index.ts | 2 +- .../SelectRegionPanel/SelectRegionPanel.tsx | 2 +- .../DatabaseCreate/DatabaseCreate.tsx | 2 +- .../src/features/Images/ImageUpload.tsx | 2 +- .../CreateCluster/CreateCluster.tsx | 2 +- .../BucketLanding/ClusterSelect.tsx | 2 +- .../Volumes/VolumeCreate/CreateVolumeForm.tsx | 2 +- .../linodes/MigrateLinode/ConfigureForm.tsx | 3 +- 9 files changed, 20 insertions(+), 44 deletions(-) diff --git a/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/RegionSelect.tsx b/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/RegionSelect.tsx index e6fbc89cb26..03f35e44ae0 100644 --- a/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/RegionSelect.tsx +++ b/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/RegionSelect.tsx @@ -9,8 +9,6 @@ import SG from 'flag-icons/flags/4x3/sg.svg'; import US from 'flag-icons/flags/4x3/us.svg'; import { groupBy } from 'ramda'; import * as React from 'react'; -import { makeStyles } from '@mui/styles'; -import { Theme } from '@mui/material/styles'; import SingleValue from 'src/components/EnhancedSelect/components/SingleValue'; import Select, { BaseSelectProps, @@ -32,16 +30,8 @@ interface Props extends Omit { export const flags = { au: () => , us: () => , - sg: () => , - jp: () => ( - - ), + sg: () => , + jp: () => , uk: () => , eu: () => , de: () => , @@ -52,33 +42,22 @@ export const flags = { export const selectStyles = { menuList: (base: any) => ({ ...base, maxHeight: `40vh !important` }), }; -const useStyles = makeStyles((theme: Theme) => ({ - root: { - '& svg': { - '& g': { - // Super hacky fix for Firefox rendering of some flag icons that had a clip-path property. - clipPath: 'none !important' as 'none', - }, - }, - '& #singapore, #japan': { - border: `1px solid ${theme.color.border3}`, - }, - }, -})); export const getRegionOptions = (regions: Region[]) => { - const groupedRegions = groupBy((thisRegion) => { - if (thisRegion.country.match(/(us|ca)/)) { + const groupedRegions = groupBy((region) => { + const country = region.country.toLowerCase(); + if (['us', 'ca'].includes(country)) { return 'North America'; } - if (thisRegion.country.match(/(de|uk|eu)/)) { + if (['de', 'uk', 'eu', 'fr'].includes(country)) { return 'Europe'; } - if (thisRegion.country.match(/(jp|sg|in|au)/)) { + if (['jp', 'sg', 'in', 'au'].includes(country)) { return 'Asia Pacific'; } return 'Other'; }, regions); + return ['North America', 'Europe', 'Asia Pacific', 'Other'].reduce( (accum, thisGroup) => { if ( @@ -137,7 +116,7 @@ const sortRegions = (region1: RegionItem, region2: RegionItem) => { return 0; }; -const SelectRegionPanel: React.FC = (props) => { +export const RegionSelect = React.memo((props: Props) => { const { label, disabled, @@ -168,12 +147,10 @@ const SelectRegionPanel: React.FC = (props) => { [handleSelection] ); - const classes = useStyles(); - const options = React.useMemo(() => getRegionOptions(regions), [regions]); return ( -
+