Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: assets and utilities clean up #9041

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions packages/manager/config/environments/beta

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('Migrate Linode With Firewall', () => {
cy.wait('@getRegions');
cy.findByText('Dallas, TX').should('be.visible');
getClick('[data-qa-checked="false"]');
cy.findByText(`United States: Dallas, TX`).should('be.visible');
cy.findByText(`North America: Dallas, TX`).should('be.visible');
containsClick(selectRegionString);

ui.regionSelect.findItemByRegionName('Singapore, SG').click();
Expand Down
8 changes: 0 additions & 8 deletions packages/manager/src/__data__/withLinodeActions.ts

This file was deleted.

Binary file removed packages/manager/src/assets/default/cube.png
Binary file not shown.
Binary file removed packages/manager/src/assets/distros/Alpine.png
Binary file not shown.
Binary file removed packages/manager/src/assets/distros/Arch.png
Binary file not shown.
Binary file removed packages/manager/src/assets/distros/CentOS.png
Binary file not shown.
Binary file not shown.
Binary file removed packages/manager/src/assets/distros/Debian.png
Binary file not shown.
Binary file removed packages/manager/src/assets/distros/Fedora.png
Binary file not shown.
Binary file removed packages/manager/src/assets/distros/Gentoo.png
Binary file not shown.
Binary file removed packages/manager/src/assets/distros/OpenSUSE.png
Binary file not shown.
Binary file removed packages/manager/src/assets/distros/Slackware.png
Binary file not shown.
Binary file removed packages/manager/src/assets/distros/Ubuntu.png
Binary file not shown.
18 changes: 0 additions & 18 deletions packages/manager/src/assets/noscript/styles.css

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ import SingleValue from 'src/components/EnhancedSelect/components/SingleValue';
import { Region } from '@linode/api-v4/lib/regions';
import RegionOption, { RegionItem } from './RegionOption';
import { Flag } from 'src/components/Flag';
import {
CONTINENT_CODE_TO_CONTINENT,
COUNTRY_CODE_TO_CONTINENT_CODE,
ContinentNames,
} from './utils';
import { ContinentNames } from './utils';
import { getRegionCountryGroup } from 'src/utilities/formatRegion';

interface Props<IsClearable extends boolean>
extends Omit<
Expand Down Expand Up @@ -47,16 +44,7 @@ export const getRegionOptions = (regions: Region[]) => {
};

for (const region of regions) {
const country = region.country.toUpperCase();

const continentCode =
COUNTRY_CODE_TO_CONTINENT_CODE[
country as keyof typeof COUNTRY_CODE_TO_CONTINENT_CODE
];

const group = continentCode
? CONTINENT_CODE_TO_CONTINENT[continentCode] ?? 'Other'
: 'Other';
const group = getRegionCountryGroup(region);

groups[group].push({
label: `${region.label} (${region.id})`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Tooltip from 'src/components/core/Tooltip';
import Link from 'src/components/Link';
import TableCell from 'src/components/TableCell';
import TableRow from 'src/components/TableRow';
import capitalize from 'src/utilities/capitalize';
import HighlightedMarkdown from 'src/components/HighlightedMarkdown';
import { capitalize } from 'src/utilities/capitalize';
import { StatusIcon, Status } from 'src/components/StatusIcon/StatusIcon';
import { AccountMaintenance } from '@linode/api-v4/lib/account/types';
import { parseAPIDate } from 'src/utilities/date';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Theme } from '@mui/material/styles';
import { DateTimeDisplay } from 'src/components/DateTimeDisplay';
import TableCell from 'src/components/TableCell';
import TableRow from 'src/components/TableRow';
import capitalize from 'src/utilities/capitalize';
import { capitalize } from 'src/utilities/capitalize';
import { pluralize } from 'src/utilities/pluralize';
import ActionMenu from './TransfersPendingActionMenu';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Table from 'src/components/Table';
import TableCell from 'src/components/TableCell';
import TableContentWrapper from 'src/components/TableContentWrapper';
import TableRow from 'src/components/TableRow';
import capitalize from 'src/utilities/capitalize';
import { capitalize } from 'src/utilities/capitalize';
import ConfirmTransferCancelDialog from './EntityTransfersLanding/ConfirmTransferCancelDialog';
import TransferDetailsDialog from './EntityTransfersLanding/TransferDetailsDialog';
import RenderTransferRow from './RenderTransferRow';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TransferEntities } from '@linode/api-v4/lib/entity-transfers';
import capitalize from 'src/utilities/capitalize';
import { capitalize } from 'src/utilities/capitalize';

// Return the count of each transferred entity by type, for reporting to GA.
// E.g. { linodes: [ 1234 ], domains: [ 2345, 3456 ]} -> "Linodes: 1, Domains: 2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
predefinedFirewallFromRule,
protocolOptions,
} from 'src/features/Firewalls/shared';
import capitalize from 'src/utilities/capitalize';
import { capitalize } from 'src/utilities/capitalize';
import {
ExtendedIP,
stringToExtendedIP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
generateRuleLabel,
predefinedFirewallFromRule as ruleToPredefinedFirewall,
} from 'src/features/Firewalls/shared';
import capitalize from 'src/utilities/capitalize';
import { capitalize } from 'src/utilities/capitalize';
import FirewallRuleActionMenu from './FirewallRuleActionMenu';
import { Mode } from './FirewallRuleDrawer';
import { ExtendedFirewallRule, RuleStatus } from './firewallRuleEditor';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { StatusIcon } from 'src/components/StatusIcon/StatusIcon';
import TableCell from 'src/components/TableCell';
import TableRow from 'src/components/TableRow';
import { useAllFirewallDevicesQuery } from 'src/queries/firewalls';
import capitalize from 'src/utilities/capitalize';
import { capitalize } from 'src/utilities/capitalize';
import ActionMenu, { ActionHandlers } from './FirewallActionMenu';

const useStyles = makeStyles((theme: Theme) => ({
Expand Down
3 changes: 1 addition & 2 deletions packages/manager/src/features/NodeBalancers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
NodeBalancerConfigNodeFields,
NodeBalancerConfigFields,
} from './types';

import defaultNumeric from 'src/utilities/defaultNumeric';
import { defaultNumeric } from 'src/utilities/defaultNumeric';

export interface NodeBalancerConfigFieldsWithStatus
extends NodeBalancerConfigFields {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ExternalLink from 'src/components/ExternalLink';
import Notice from 'src/components/Notice';
import { Toggle } from 'src/components/Toggle';
import useOpenClose from 'src/hooks/useOpenClose';
import capitalize from 'src/utilities/capitalize';
import { capitalize } from 'src/utilities/capitalize';
import { getErrorStringOrDefault } from 'src/utilities/errorUtils';
import { bucketACLOptions, objectACLOptions } from '../utilities';

Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/features/Search/ResultGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Grid from '@mui/material/Unstable_Grid2';
import Table from 'src/components/Table';
import TableCell from 'src/components/TableCell';
import TableRow from 'src/components/TableRow';
import capitalize from 'src/utilities/capitalize';
import { capitalize } from 'src/utilities/capitalize';
import ResultRow from './ResultRow';

const useStyles = makeStyles((theme: Theme) => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/features/Search/SearchLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { ApplicationState } from 'src/store';
import { ErrorObject } from 'src/store/selectors/entitiesErrors';
import { formatLinode } from 'src/store/selectors/getSearchEntities';
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
import isNilOrEmpty from 'src/utilities/isNilOrEmpty';
import { isNilOrEmpty } from 'src/utilities/isNilOrEmpty';
import { getQueryParam } from 'src/utilities/queryParams';
import { debounce } from 'throttle-debounce';
import ResultGroup from './ResultGroup';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Notice from 'src/components/Notice';
import TextField from 'src/components/TextField';
import ImageSelect from 'src/features/Images/ImageSelect';
import getAPIErrorsFor from 'src/utilities/getAPIErrorFor';
import imageToItem from 'src/utilities/imageToItem';
import { imageToItem } from 'src/utilities/imageToItem';

const useStyles = makeStyles((theme: Theme) => ({
root: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from 'src/queries/objectStorage';
import { useAllVolumesQuery } from 'src/queries/volumes';
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
import isNilOrEmpty from 'src/utilities/isNilOrEmpty';
import { isNilOrEmpty } from 'src/utilities/isNilOrEmpty';
import { debounce } from 'throttle-debounce';
import styled, { StyleProps } from './SearchBar.styles';
import SearchSuggestion from './SearchSuggestion';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import {
handleGeneralErrors,
} from 'src/utilities/formikErrorUtils';
import { sendCreateVolumeEvent } from 'src/utilities/ga';
import isNilOrEmpty from 'src/utilities/isNilOrEmpty';
import maybeCastToNumber from 'src/utilities/maybeCastToNumber';
import { isNilOrEmpty } from 'src/utilities/isNilOrEmpty';
import { maybeCastToNumber } from 'src/utilities/maybeCastToNumber';
import ConfigSelect, {
initialValueDefaultId,
} from '../VolumeDrawer/ConfigSelect';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
handleGeneralErrors,
} from 'src/utilities/formikErrorUtils';
import { sendCreateVolumeEvent } from 'src/utilities/ga';
import maybeCastToNumber from 'src/utilities/maybeCastToNumber';
import { maybeCastToNumber } from 'src/utilities/maybeCastToNumber';
import { array, object, string } from 'yup';
import ConfigSelect from './ConfigSelect';
import LabelField from './LabelField';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Theme } from '@mui/material/styles';
import Typography from 'src/components/core/Typography';
import { RegionSelect } from 'src/components/EnhancedSelect/variants/RegionSelect';
import { useRegionsQuery } from 'src/queries/regions';
import { getHumanReadableCountry } from 'src/utilities/formatRegion';
import { getRegionCountryGroup } from 'src/utilities/formatRegion';
import { Flag } from 'src/components/Flag';

const useStyles = makeStyles((theme: Theme) => ({
Expand Down Expand Up @@ -54,7 +54,7 @@ const ConfigureForm = (props: Props) => {
<Typography>Current Region</Typography>
<div className={classes.currentRegion}>
<Flag country={country} />
<Typography>{`${getHumanReadableCountry(props.currentRegion)}: ${
<Typography>{`${getRegionCountryGroup(currentActualRegion)}: ${
currentActualRegion?.label ?? currentRegion
}`}</Typography>
</div>
Expand Down
22 changes: 0 additions & 22 deletions packages/manager/src/hooks/useForm.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/manager/src/requestableContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { APIError } from '@linode/api-v4/lib/types';
import * as React from 'react';

import { getDisplayName } from 'src/utilities';
import { APIError } from '@linode/api-v4/lib/types';
import { getDisplayName } from 'src/utilities/getDisplayName';

export interface Requestable<T> {
lastUpdated: number;
Expand Down
7 changes: 0 additions & 7 deletions packages/manager/src/utilities/allocateIPAddress.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/manager/src/utilities/capitalize.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import capitalize, { capitalizeAllWords } from './capitalize';
import { capitalize, capitalizeAllWords } from './capitalize';

describe('capitalize', () => {
it('should return capitalized string', () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/manager/src/utilities/capitalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ export const capitalize = (s: string) => {
return s.charAt(0).toUpperCase() + s.slice(1);
};

export default capitalize;

export const capitalizeAllWords = (s: string) => {
return s.split(' ').map(capitalize).join(' ');
};
26 changes: 1 addition & 25 deletions packages/manager/src/utilities/defaultNumeric.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
// import { compose, curry, defaultTo, isEmpty, not, when } from 'ramda';

/**
* LEGACY IMPLEMENTATION.
*
* Leaving just in case something breaks later down the line
* but I'm 99% sure the function below is doing the same thing as
* this
*/
// export default curry((defaultValue: number, v?: null | string | number) =>
// compose(
// defaultTo(defaultValue),
// when(
// compose(
// not,
// isEmpty
// ),
// (value: string) => +value
// )
// )(v)
// );

/**
* function useful for parsing user input and defaulting to a specified value
* when the user input is blank
*/
const defaultNumeric = (
export const defaultNumeric = (
defaultValue: number,
value?: null | string | number
) => {
Expand All @@ -36,5 +14,3 @@ const defaultNumeric = (
? valueToNumber
: defaultValue;
};

export default defaultNumeric;
4 changes: 1 addition & 3 deletions packages/manager/src/utilities/escapeStringForCLI.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const escapeStringForCLI = (value: string) => {
export const escapeStringForCLI = (value: string) => {
return value.replace(/(["'$`\\])/g, '\\$1');
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a potential for some more cleanup, possibly in a separate PR: This util essentially does the same as https://github.com/linode/manager/blob/develop/packages/manager/src/utilities/generate-cli.ts#L2-L10. However the one in generate-cli is more comprehensive in what it handles. Do we want to move forward with just one solution?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made myself a note to revisit this


export default escapeStringForCLI;
31 changes: 18 additions & 13 deletions packages/manager/src/utilities/formatRegion.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
export const getHumanReadableCountry = (regionSlug: string) => {
if (regionSlug.match(/(us)/gim)) {
return 'United States';
}
if (regionSlug.match(/(ca)/gim)) {
return 'Canada';
}
if (regionSlug.match(/(de|uk|eu)/gim)) {
return 'Europe';
}
if (regionSlug.match(/(jp|sg|in|ap)/gim)) {
return 'Asia';
import { Region } from '@linode/api-v4';
import {
COUNTRY_CODE_TO_CONTINENT_CODE,
CONTINENT_CODE_TO_CONTINENT,
} from 'src/components/EnhancedSelect/variants/RegionSelect/utils';

export const getRegionCountryGroup = (region: Region | undefined) => {
if (!region) {
return 'Other';
}
return 'Other';

const continentCode =
COUNTRY_CODE_TO_CONTINENT_CODE[
region.country.toUpperCase() as keyof typeof COUNTRY_CODE_TO_CONTINENT_CODE
];

return continentCode
? CONTINENT_CODE_TO_CONTINENT[continentCode] ?? 'Other'
: 'Other';
};

export const isEURegion = (region: string | null | undefined) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/utilities/formikErrorUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { APIError } from '@linode/api-v4/lib/types';
import { reverse } from 'ramda';
import { getAPIErrorOrDefault } from './errorUtils';
import isNilOrEmpty from './isNilOrEmpty';
import { isNilOrEmpty } from './isNilOrEmpty';

export const handleFieldErrors = (
callback: (error: unknown) => void,
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/utilities/generate-cURL.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
import escapeStringForCLI from './escapeStringForCLI';
import { escapeStringForCLI } from './escapeStringForCLI';

const headers = [
'-H "Content-Type: application/json" \\',
Expand Down
5 changes: 0 additions & 5 deletions packages/manager/src/utilities/getItemByID.ts

This file was deleted.

Loading