Skip to content

Commit

Permalink
refactor: [M3-8815] – Migrate TextField component to ui package (l…
Browse files Browse the repository at this point in the history
  • Loading branch information
dwiley-akamai authored Nov 21, 2024
1 parent d8812c4 commit 9c92ef8
Show file tree
Hide file tree
Showing 130 changed files with 218 additions and 256 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11290-removed-1732046225737.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Removed
---

`TextField` component and `convertToKebabCase` utility function (migrated to `ui` package) ([#11290](https://github.com/linode/manager/pull/11290))
3 changes: 1 addition & 2 deletions packages/manager/src/components/ActionMenu/ActionMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { TooltipIcon } from '@linode/ui';
import { TooltipIcon, convertToKebabCase } from '@linode/ui';
import { IconButton, ListItemText } from '@mui/material';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import * as React from 'react';

import KebabIcon from 'src/assets/icons/kebab.svg';
import { convertToKebabCase } from 'src/utilities/convertToKebobCase';

export interface Action {
disabled?: boolean;
Expand Down
7 changes: 2 additions & 5 deletions packages/manager/src/components/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { CircleProgress } from '@linode/ui';
import { Box, InputAdornment } from '@linode/ui';
import { Box, CircleProgress, InputAdornment, TextField } from '@linode/ui';
import CloseIcon from '@mui/icons-material/Close';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import MuiAutocomplete from '@mui/material/Autocomplete';
import React from 'react';

import { TextField } from 'src/components/TextField';

import {
CustomPopper,
SelectedIcon,
StyledListItem,
} from './Autocomplete.styles';

import type { TextFieldProps } from '@linode/ui';
import type { AutocompleteProps } from '@mui/material/Autocomplete';
import type { TextFieldProps } from 'src/components/TextField';

export interface EnhancedAutocompleteProps<
T extends { label: string },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Box } from '@linode/ui';
import { Box, TextField } from '@linode/ui';
import { styled } from '@mui/material/styles';
import * as React from 'react';

import { CopyTooltip } from 'src/components/CopyTooltip/CopyTooltip';
import { TextField } from 'src/components/TextField';

import { DownloadTooltip } from '../DownloadTooltip';

import type { TextFieldProps } from '@linode/ui';
import type { CopyTooltipProps } from 'src/components/CopyTooltip/CopyTooltip';
import type { TextFieldProps } from 'src/components/TextField';

export interface CopyableTextFieldProps extends TextFieldProps {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { CircleProgress } from '@linode/ui';
import { CircleProgress, TextField } from '@linode/ui';
import { IconButton, InputAdornment } from '@linode/ui';
import Clear from '@mui/icons-material/Clear';
import Search from '@mui/icons-material/Search';
import { styled } from '@mui/material/styles';
import * as React from 'react';
import { debounce } from 'throttle-debounce';

import { TextField } from 'src/components/TextField';

import type { TextFieldProps } from 'src/components/TextField';
import type { TextFieldProps } from '@linode/ui';

export interface DebouncedSearchProps extends TextFieldProps {
className?: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/manager/src/components/Drawer.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Button } from '@linode/ui';
import { Button, TextField } from '@linode/ui';
import { action } from '@storybook/addon-actions';
import React from 'react';

import { ActionsPanel } from './ActionsPanel/ActionsPanel';
import { Drawer } from './Drawer';
import { TextField } from './TextField';
import { Typography } from './Typography';

import type { Meta, StoryObj } from '@storybook/react';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Box, Button, fadeIn } from '@linode/ui';
import { Box, Button, TextField, fadeIn } from '@linode/ui';
import Edit from '@mui/icons-material/Edit';
import { styled } from '@mui/material/styles';

import { TextField } from 'src/components/TextField';
import { Typography } from 'src/components/Typography';

import type { EditableTextVariant } from './EditableInput';
import type { TextFieldProps } from 'src/components/TextField';
import type { TextFieldProps } from '@linode/ui';

export const StyledTypography = styled(Typography, {
label: 'EditableInput__StyledTypography',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
StyledTypography,
} from './EditableInput.styles';

import type { TextFieldProps } from 'src/components/TextField';
import type { TextFieldProps } from '@linode/ui';

export type EditableTextVariant = 'h1' | 'h2' | 'table-cell';

Expand Down
6 changes: 2 additions & 4 deletions packages/manager/src/components/EditableText/EditableText.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { Button, ClickAwayListener, H1Header } from '@linode/ui';
import { Button, ClickAwayListener, H1Header, TextField } from '@linode/ui';
import Check from '@mui/icons-material/Check';
import Close from '@mui/icons-material/Close';
import Edit from '@mui/icons-material/Edit';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { makeStyles } from 'tss-react/mui';

import { TextField } from '../TextField';

import type { TextFieldProps } from '../TextField';
import type { TextFieldProps } from '@linode/ui';
import type { Theme } from '@mui/material/styles';

const useStyles = makeStyles<void, 'editIcon' | 'icon'>()(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Box, Button } from '@linode/ui';
import { Box, Button, PlusSignIcon, TextField } from '@linode/ui';
import { styled } from '@mui/material/styles';
import * as React from 'react';

import Minus from 'src/assets/icons/LKEminusSign.svg';
import Plus from 'src/assets/icons/LKEplusSign.svg';
import { TextField } from 'src/components/TextField';

const sxTextFieldBase = {
'&::-webkit-inner-spin-button': {
Expand Down Expand Up @@ -155,6 +153,6 @@ const MinusIcon = styled(Minus)({
width: 12,
});

const PlusIcon = styled(Plus)({
const PlusIcon = styled(PlusSignIcon)({
width: 14,
});
5 changes: 2 additions & 3 deletions packages/manager/src/components/EnhancedSelect/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { convertToKebabCase } from '@linode/ui';
import { useTheme } from '@mui/material';
import * as React from 'react';
import ReactSelect from 'react-select';
import CreatableSelect from 'react-select/creatable';

import { convertToKebabCase } from 'src/utilities/convertToKebobCase';

import { DropdownIndicator } from './components/DropdownIndicator';
import Input from './components/Input';
import { LoadingIndicator } from './components/LoadingIndicator';
Expand All @@ -17,14 +16,14 @@ import Control from './components/SelectControl';
import { SelectPlaceholder as Placeholder } from './components/SelectPlaceholder';
import { reactSelectStyles, useStyles } from './Select.styles';

import type { TextFieldProps } from '@linode/ui';
import type { Theme } from '@mui/material';
import type {
ActionMeta,
NamedProps as SelectProps,
ValueType,
} from 'react-select';
import type { CreatableProps as CreatableSelectProps } from 'react-select/creatable';
import type { TextFieldProps } from 'src/components/TextField';

export interface Item<T = number | string, L = string> {
data?: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { TextField } from '@linode/ui';
import * as React from 'react';
import { ControlProps } from 'react-select';

import { TextField } from 'src/components/TextField';
import type { ControlProps } from 'react-select';

type Props = ControlProps<any, any>;

const SelectControl: React.FC<Props> = (props) => {
return (
<TextField
placeholder={props.selectProps.placeholder}
InputProps={{
inputComponent: 'div',
inputProps: {
Expand All @@ -24,6 +23,7 @@ const SelectControl: React.FC<Props> = (props) => {
: props.selectProps.placeholder
}
fullWidth
placeholder={props.selectProps.placeholder}
{...props.selectProps.textFieldProps}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Button, InputLabel, Notice, TooltipIcon } from '@linode/ui';
import { Button, InputLabel, Notice, TextField, TooltipIcon } from '@linode/ui';
import Close from '@mui/icons-material/Close';
import Grid from '@mui/material/Unstable_Grid2';
import * as React from 'react';
import { makeStyles } from 'tss-react/mui';

import { LinkButton } from 'src/components/LinkButton';
import { StyledLinkButtonBox } from 'src/components/SelectFirewallPanel/SelectFirewallPanel';
import { TextField } from 'src/components/TextField';
import { Typography } from 'src/components/Typography';

import type { InputBaseProps } from '@mui/material/InputBase';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Box } from '@linode/ui';
import { Box, TextField } from '@linode/ui';
import { styled, useTheme } from '@mui/material/styles';
import * as React from 'react';

import { MenuItem } from 'src/components/MenuItem';

import { PaginationControls } from '../PaginationControls/PaginationControls';
import { TextField } from '../TextField';

export const MIN_PAGE_SIZE = 25;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { TextField } from '@linode/ui';
import Visibility from '@mui/icons-material/Visibility';
import VisibilityOff from '@mui/icons-material/VisibilityOff';
import * as React from 'react';

import { TextField, TextFieldProps } from '../TextField';
import type { TextFieldProps } from '@linode/ui';

export const HideShowText = (props: TextFieldProps) => {
const [hidden, setHidden] = React.useState(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import zxcvbn from 'zxcvbn';
import { StrengthIndicator } from '../PasswordInput/StrengthIndicator';
import { HideShowText } from './HideShowText';

import type { TextFieldProps } from 'src/components/TextField';
import type { TextFieldProps } from '@linode/ui';

interface Props extends TextFieldProps {
disabledReason?: JSX.Element | string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { useAllPlacementGroupsQuery } from 'src/queries/placementGroups';
import { PlacementGroupSelectOption } from './PlacementGroupSelectOption';

import type { APIError, PlacementGroup, Region } from '@linode/api-v4';
import type { TextFieldProps } from '@linode/ui';
import type { SxProps, Theme } from '@mui/material/styles';
import type { TextFieldProps } from 'src/components/TextField';

export interface PlacementGroupsSelectProps {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { TextField } from '@linode/ui';
import * as React from 'react';

import { Link } from 'src/components/Link';
import { TextField, TextFieldProps } from 'src/components/TextField';
import { Typography } from 'src/components/Typography';

import type { TextFieldProps } from '@linode/ui';

export interface TypeToConfirmProps extends Omit<TextFieldProps, 'onChange'> {
confirmationText?: JSX.Element | string;
hideInstructions?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button } from '@linode/ui';
import { Button, convertToKebabCase } from '@linode/ui';
import {
Step,
StepConnector,
Expand All @@ -11,8 +11,6 @@ import Box from '@mui/material/Box';
import useMediaQuery from '@mui/material/useMediaQuery';
import React, { useState } from 'react';

import { convertToKebabCase } from 'src/utilities/convertToKebobCase';

import {
CustomStepIcon,
StyledCircleIcon,
Expand Down
3 changes: 1 addition & 2 deletions packages/manager/src/features/Account/CloseAccountDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { cancelAccount } from '@linode/api-v4/lib/account';
import { Notice } from '@linode/ui';
import { Notice, TextField } from '@linode/ui';
import { styled } from '@mui/material/styles';
import * as React from 'react';
import { useHistory } from 'react-router-dom';
import { makeStyles } from 'tss-react/mui';

import { TextField } from 'src/components/TextField';
import { TypeToConfirmDialog } from 'src/components/TypeToConfirmDialog/TypeToConfirmDialog';
import { Typography } from 'src/components/Typography';
import { useProfile } from 'src/queries/profile/profile';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
InputAdornment,
Notice,
Stack,
TextField,
TooltipIcon,
} from '@linode/ui';
import Grid from '@mui/material/Unstable_Grid2';
Expand All @@ -18,7 +19,6 @@ import { Drawer } from 'src/components/Drawer';
import { ErrorState } from 'src/components/ErrorState/ErrorState';
import { LinearProgress } from 'src/components/LinearProgress';
import { SupportLink } from 'src/components/SupportLink';
import { TextField } from 'src/components/TextField';
import { Typography } from 'src/components/Typography';
import { getRestrictedResourceText } from 'src/features/Account/utils';
import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { addPromotion } from '@linode/api-v4/lib';
import { Notice } from '@linode/ui';
import { Notice, TextField } from '@linode/ui';
import { useQueryClient } from '@tanstack/react-query';
import { useSnackbar } from 'notistack';
import * as React from 'react';
import { makeStyles } from 'tss-react/mui';

import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';
import { ConfirmationDialog } from 'src/components/ConfirmationDialog/ConfirmationDialog';
import { TextField } from 'src/components/TextField';
import { Typography } from 'src/components/Typography';
import { accountQueries } from 'src/queries/account/queries';
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Notice } from '@linode/ui';
import { Notice, TextField } from '@linode/ui';
import Grid from '@mui/material/Unstable_Grid2';
import { allCountries } from 'country-region-data';
import { useFormik } from 'formik';
Expand All @@ -7,7 +7,6 @@ import { makeStyles } from 'tss-react/mui';

import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';
import EnhancedSelect from 'src/components/EnhancedSelect/Select';
import { TextField } from 'src/components/TextField';
import {
getRestrictedResourceText,
useIsTaxIdEnabled,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addPaymentMethod } from '@linode/api-v4/lib';
import { Notice } from '@linode/ui';
import { Notice, TextField } from '@linode/ui';
import { CreditCardSchema } from '@linode/validation';
import Grid from '@mui/material/Unstable_Grid2';
import { useQueryClient } from '@tanstack/react-query';
Expand All @@ -10,7 +10,6 @@ import NumberFormat from 'react-number-format';
import { makeStyles } from 'tss-react/mui';

import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';
import { TextField } from 'src/components/TextField';
import { accountQueries } from 'src/queries/account/queries';
import { parseExpiryYear } from 'src/utilities/creditCard';
import { handleAPIErrors } from 'src/utilities/formikErrorUtils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { yupResolver } from '@hookform/resolvers/yup';
import { Paper } from '@linode/ui';
import { Paper, TextField } from '@linode/ui';
import { createAlertDefinitionSchema } from '@linode/validation';
import { useSnackbar } from 'notistack';
import * as React from 'react';
Expand All @@ -8,7 +8,6 @@ import { useHistory } from 'react-router-dom';

import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';
import { Breadcrumb } from 'src/components/Breadcrumb/Breadcrumb';
import { TextField } from 'src/components/TextField';
import { Typography } from 'src/components/Typography';
import { useCreateAlertDefinition } from 'src/queries/cloudpulse/alerts';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Box, Button } from '@linode/ui';
import { Box, Button, TextField } from '@linode/ui';
import { Grid, styled } from '@mui/material';

import { Autocomplete } from 'src/components/Autocomplete/Autocomplete';
import { TextField } from 'src/components/TextField';
import { Typography } from 'src/components/Typography';
import { PlansPanel } from 'src/features/components/PlansPanel/PlansPanel';

Expand Down
3 changes: 1 addition & 2 deletions packages/manager/src/features/Domains/CloneDomainDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Notice, Radio, RadioGroup } from '@linode/ui';
import { Notice, Radio, RadioGroup, TextField } from '@linode/ui';
import { useFormik } from 'formik';
import React from 'react';
import { useHistory } from 'react-router-dom';

import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';
import { Drawer } from 'src/components/Drawer';
import { FormControlLabel } from 'src/components/FormControlLabel';
import { TextField } from 'src/components/TextField';
import { useCloneDomainMutation } from 'src/queries/domains';
import { useGrants, useProfile } from 'src/queries/profile/profile';

Expand Down
Loading

0 comments on commit 9c92ef8

Please sign in to comment.