Skip to content

Commit

Permalink
upcoming: [M3-8209] - Region label updates (linode#10702)
Browse files Browse the repository at this point in the history
## Description 📝
When the Gecko GA flag is true:
- Display Country, City instead of City, State anywhere there is a region label
- Ensure Linode Create v2 displays Country, City

## How to test 🧪
### Prerequisites
(How to setup test environment)
- Ensure your account has the `new-dc-testing`, `edge_testing` and `edge_compute` customer tags

### Verification steps
(How to verify changes)
- Check region labels throughout the app
- Regions should display as Country, City with the gecko flag on and as normal with the flag off
  • Loading branch information
hana-akamai authored Jul 24, 2024
1 parent 3c49ca5 commit 9f4d09d
Show file tree
Hide file tree
Showing 66 changed files with 458 additions and 224 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Region label updates ([#10702](https://github.com/linode/manager/pull/10702))
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ export const useIsGeckoEnabled = () => {
const flags = useFlags();
const isGeckoGA = flags?.gecko2?.enabled && flags.gecko2.ga;
const isGeckoBeta = flags.gecko2?.enabled && !flags.gecko2?.ga;
const { data: regions } = useRegionsQuery(isGeckoGA);
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGA,
});

const hasDistributedRegionCapability = regions?.some((region: Region) =>
region.capabilities.includes('Distributed Plans')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { useLocation } from 'react-router-dom';
import { Notice } from 'src/components/Notice/Notice';
import { Paper } from 'src/components/Paper';
import { RegionSelect } from 'src/components/RegionSelect/RegionSelect';
import { isDistributedRegionSupported } from 'src/components/RegionSelect/RegionSelect.utils';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import {
isDistributedRegionSupported,
useIsGeckoEnabled,
} from 'src/components/RegionSelect/RegionSelect.utils';
import { TwoStepRegionSelect } from 'src/components/RegionSelect/TwoStepRegionSelect';
import { RegionHelperText } from 'src/components/SelectRegionPanel/RegionHelperText';
import { Typography } from 'src/components/Typography';
Expand Down Expand Up @@ -72,7 +74,9 @@ export const SelectRegionPanel = (props: SelectRegionPanelProps) => {

const { isGeckoGAEnabled } = useIsGeckoEnabled();

const { data: regions } = useRegionsQuery(isGeckoGAEnabled);
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const isCloning = /clone/i.test(params.type);
const isFromLinodeCreate = location.pathname.includes('/linodes/create');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';

import { Box } from 'src/components/Box';
import { CircleProgress } from 'src/components/CircleProgress';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { Typography } from 'src/components/Typography';
import { useAccountNetworkTransfer } from 'src/queries/account/transfer';
import { useRegionsQuery } from 'src/queries/regions/regions';
Expand All @@ -26,7 +27,10 @@ export const TransferDisplay = React.memo(({ spacingTop }: Props) => {
isError,
isLoading,
} = useAccountNetworkTransfer();
const { data: regions } = useRegionsQuery();
const { isGeckoGAEnabled } = useIsGeckoEnabled();
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const generalPoolUsagePct = calculatePoolUsagePct(generalPoolUsage);
const regionTransferPools = getRegionTransferPools(generalPoolUsage, regions);
Expand Down
12 changes: 9 additions & 3 deletions packages/manager/src/containers/regions.container.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Region } from '@linode/api-v4/lib/regions';
import { APIError } from '@linode/api-v4/lib/types';
import * as React from 'react';

import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { useRegionsQuery } from 'src/queries/regions/regions';

import type { Region } from '@linode/api-v4/lib/regions';
import type { APIError } from '@linode/api-v4/lib/types';

export interface RegionsProps {
regionsData: Region[];
regionsError?: APIError[];
Expand All @@ -25,7 +27,11 @@ export interface RegionsProps {
export const withRegions = <Props>(
Component: React.ComponentType<Props & RegionsProps>
) => (props: Props) => {
const { data, error, isLoading } = useRegionsQuery();
const { isGeckoGAEnabled } = useIsGeckoEnabled();
const { data, error, isLoading } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

return React.createElement(Component, {
regionsData: data ?? [],
regionsError: error ?? undefined,
Expand Down
9 changes: 7 additions & 2 deletions packages/manager/src/features/Backups/BackupLinodeRow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Linode, PriceObject } from '@linode/api-v4';
import * as React from 'react';

import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { TableCell } from 'src/components/TableCell';
import { TableRow } from 'src/components/TableRow';
import { Typography } from 'src/components/Typography';
Expand All @@ -12,6 +12,8 @@ import {
UNKNOWN_PRICE,
} from 'src/utilities/pricing/constants';

import type { Linode, PriceObject } from '@linode/api-v4';

interface Props {
error?: string;
linode: Linode;
Expand All @@ -20,7 +22,10 @@ interface Props {
export const BackupLinodeRow = (props: Props) => {
const { error, linode } = props;
const { data: type } = useTypeQuery(linode.type ?? '', Boolean(linode.type));
const { data: regions } = useRegionsQuery();
const { isGeckoGAEnabled } = useIsGeckoEnabled();
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const backupsMonthlyPrice:
| PriceObject['monthly']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import {
Invoice,
InvoiceItem,
Payment,
getInvoiceItems,
} from '@linode/api-v4/lib/account';
import { Theme, styled } from '@mui/material/styles';
import { getInvoiceItems } from '@linode/api-v4/lib/account';
import { styled } from '@mui/material/styles';
import Grid from '@mui/material/Unstable_Grid2';
import { DateTime } from 'luxon';
import * as React from 'react';
import { makeStyles } from 'tss-react/mui';

import { Currency } from 'src/components/Currency';
import { DateTimeDisplay } from 'src/components/DateTimeDisplay';
import Select, { Item } from 'src/components/EnhancedSelect/Select';
import Select from 'src/components/EnhancedSelect/Select';
import { InlineMenuAction } from 'src/components/InlineMenuAction/InlineMenuAction';
import { Link } from 'src/components/Link';
import OrderBy from 'src/components/OrderBy';
import Paginate from 'src/components/Paginate';
import { PaginationFooter } from 'src/components/PaginationFooter/PaginationFooter';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { Table } from 'src/components/Table';
import { TableBody } from 'src/components/TableBody';
import { TableCell } from 'src/components/TableCell';
Expand Down Expand Up @@ -47,6 +43,10 @@ import { getAll } from 'src/utilities/getAll';

import { getTaxID } from '../../billingUtils';

import type { Invoice, InvoiceItem, Payment } from '@linode/api-v4/lib/account';
import type { Theme } from '@mui/material/styles';
import type { Item } from 'src/components/EnhancedSelect/Select';

const useStyles = makeStyles()((theme: Theme) => ({
activeSince: {
marginRight: theme.spacing(1.25),
Expand Down Expand Up @@ -187,7 +187,10 @@ export const BillingActivityPanel = (props: Props) => {

const { data: profile } = useProfile();
const { data: account } = useAccount();
const { data: regions } = useRegionsQuery();
const { isGeckoGAEnabled } = useIsGeckoEnabled();
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const isAkamaiCustomer = account?.billing_source === 'akamai';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import {
Account,
Invoice,
InvoiceItem,
getInvoice,
getInvoiceItems,
} from '@linode/api-v4/lib/account';
import { APIError } from '@linode/api-v4/lib/types';
import { getInvoice, getInvoiceItems } from '@linode/api-v4/lib/account';
import KeyboardArrowLeft from '@mui/icons-material/KeyboardArrowLeft';
import Grid from '@mui/material/Unstable_Grid2';
import { useTheme } from '@mui/material/styles';
import Grid from '@mui/material/Unstable_Grid2';
import * as React from 'react';
import { useParams } from 'react-router-dom';

Expand All @@ -20,6 +13,7 @@ import { IconButton } from 'src/components/IconButton';
import { Link } from 'src/components/Link';
import { Notice } from 'src/components/Notice/Notice';
import { Paper } from 'src/components/Paper';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { Typography } from 'src/components/Typography';
import { printInvoice } from 'src/features/Billing/PdfGenerator/PdfGenerator';
import { useFlags } from 'src/hooks/useFlags';
Expand All @@ -28,18 +22,24 @@ import { useRegionsQuery } from 'src/queries/regions/regions';
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
import { getAll } from 'src/utilities/getAll';

import { invoiceCreatedAfterDCPricingLaunch } from '../PdfGenerator/utils';
import { getShouldUseAkamaiBilling } from '../billingUtils';
import { invoiceCreatedAfterDCPricingLaunch } from '../PdfGenerator/utils';
import { InvoiceTable } from './InvoiceTable';

import type { Account, Invoice, InvoiceItem } from '@linode/api-v4/lib/account';
import type { APIError } from '@linode/api-v4/lib/types';

export const InvoiceDetail = () => {
const { invoiceId } = useParams<{ invoiceId: string }>();
const theme = useTheme();

const csvRef = React.useRef<any>();

const { data: account } = useAccount();
const { data: regions } = useRegionsQuery();
const { isGeckoGAEnabled } = useIsGeckoEnabled();
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const [invoice, setInvoice] = React.useState<Invoice | undefined>(undefined);
const [items, setItems] = React.useState<InvoiceItem[] | undefined>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { InvoiceItem } from '@linode/api-v4/lib/account';
import { APIError } from '@linode/api-v4/lib/types';
import * as React from 'react';

import { Currency } from 'src/components/Currency';
import { DateTimeDisplay } from 'src/components/DateTimeDisplay';
import Paginate from 'src/components/Paginate';
import { PaginationFooter } from 'src/components/PaginationFooter/PaginationFooter';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { Table } from 'src/components/Table';
import { TableBody } from 'src/components/TableBody';
import { TableCell } from 'src/components/TableCell';
Expand All @@ -19,6 +18,9 @@ import { useRegionsQuery } from 'src/queries/regions/regions';

import { getInvoiceRegion } from '../PdfGenerator/utils';

import type { InvoiceItem } from '@linode/api-v4/lib/account';
import type { APIError } from '@linode/api-v4/lib/types';

interface Props {
errors?: APIError[];
items?: InvoiceItem[];
Expand All @@ -29,11 +31,14 @@ interface Props {
export const InvoiceTable = (props: Props) => {
const MIN_PAGE_SIZE = 25;

const { isGeckoGAEnabled } = useIsGeckoEnabled();
const {
data: regions,
error: regionsError,
isLoading: regionsLoading,
} = useRegionsQuery();
} = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const { errors, items, loading, shouldShowRegion } = props;
const NUM_COLUMNS = shouldShowRegion ? 9 : 8;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';

import { RegionSelect } from 'src/components/RegionSelect/RegionSelect';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { useRegionsQuery } from 'src/queries/regions/regions';

import { REGION, RESOURCES } from '../Utils/constants';
Expand All @@ -18,7 +19,10 @@ export interface CloudPulseRegionSelectProps {

export const CloudPulseRegionSelect = React.memo(
(props: CloudPulseRegionSelectProps) => {
const { data: regions } = useRegionsQuery();
const { isGeckoGAEnabled } = useIsGeckoEnabled();
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const [selectedRegion, setSelectedRegion] = React.useState<string>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import type { Theme } from '@mui/material/styles';
import type { Item } from 'src/components/EnhancedSelect/Select';
import type { PlanSelectionType } from 'src/features/components/PlansPanel/types';
import type { ExtendedIP } from 'src/utilities/ipUtils';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';

const useStyles = makeStyles()((theme: Theme) => ({
btnCtn: {
Expand Down Expand Up @@ -193,12 +194,15 @@ const DatabaseCreate = () => {
const { classes } = useStyles();
const history = useHistory();
const flags = useFlags();
const { isGeckoGAEnabled } = useIsGeckoEnabled();

const {
data: regionsData,
error: regionsError,
isLoading: regionsLoading,
} = useRegionsQuery();
} = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const {
data: engines,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { Region } from '@linode/api-v4';
import {
Database,
DatabaseInstance,
DatabaseType,
} from '@linode/api-v4/lib/databases/types';
import { useTheme } from '@mui/material/styles';
import * as React from 'react';

import { Box } from 'src/components/Box';
import { CircleProgress } from 'src/components/CircleProgress';
import { ErrorState } from 'src/components/ErrorState/ErrorState';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { TooltipIcon } from 'src/components/TooltipIcon';
import { useDatabaseTypesQuery } from 'src/queries/databases/databases';
import { useInProgressEvents } from 'src/queries/events/events';
Expand All @@ -27,6 +22,13 @@ import {
StyledTitleTypography,
} from './DatabaseResizeCurrentConfiguration.style';

import type { Region } from '@linode/api-v4';
import type {
Database,
DatabaseInstance,
DatabaseType,
} from '@linode/api-v4/lib/databases/types';

interface Props {
database: Database;
}
Expand All @@ -42,7 +44,10 @@ export const DatabaseResizeCurrentConfiguration = ({ database }: Props) => {
isLoading: typesLoading,
} = useDatabaseTypesQuery();
const theme = useTheme();
const { data: regions } = useRegionsQuery();
const { isGeckoGAEnabled } = useIsGeckoEnabled();
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const region = regions?.find((r: Region) => r.id === database.region);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { Region } from '@linode/api-v4';
import {
Database,
DatabaseInstance,
DatabaseType,
} from '@linode/api-v4/lib/databases/types';
import { Theme } from '@mui/material/styles';
import * as React from 'react';
import { makeStyles } from 'tss-react/mui';

import { Box } from 'src/components/Box';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { TooltipIcon } from 'src/components/TooltipIcon';
import { Typography } from 'src/components/Typography';
import { useDatabaseTypesQuery } from 'src/queries/databases/databases';
Expand All @@ -20,6 +14,14 @@ import { convertMegabytesTo } from 'src/utilities/unitConversions';
import { databaseEngineMap } from '../../DatabaseLanding/DatabaseRow';
import { DatabaseStatusDisplay } from '../DatabaseStatusDisplay';

import type { Region } from '@linode/api-v4';
import type {
Database,
DatabaseInstance,
DatabaseType,
} from '@linode/api-v4/lib/databases/types';
import type { Theme } from '@mui/material/styles';

const useStyles = makeStyles()((theme: Theme) => ({
configs: {
fontSize: '0.875rem',
Expand Down Expand Up @@ -54,7 +56,10 @@ export const DatabaseSummaryClusterConfiguration = (props: Props) => {
const { database } = props;

const { data: types } = useDatabaseTypesQuery();
const { data: regions } = useRegionsQuery();
const { isGeckoGAEnabled } = useIsGeckoEnabled();
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

const region = regions?.find((r: Region) => r.id === database.region);

Expand Down
Loading

0 comments on commit 9f4d09d

Please sign in to comment.