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

refactor: [M3-6318] - MUI v5 - Components > DeletionDialog #9047

Merged
merged 10 commits into from
Apr 24, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- MUIv5 Migration - Components > TagsInput, TagsPanel #8995
- MUIv5 Migration - Grid v2 for Features #8985
- MUIv5 Migration - Components > Dialog #9020
- MUIv5 Migration - Components > DeletionDialog #9047
- MUIv5 Migration - Components > Currency #9030
- MUIv5 Migration - Components > DisplayPrice #9022
- MUIv5 Migration - Components > CreateLinodeDisabled #9015
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import DeletionDialog from 'src/components/DeletionDialog';
import { DeletionDialog } from 'src/components/DeletionDialog/DeletionDialog';
import { action } from '@storybook/addon-actions';
import type { Meta, StoryObj } from '@storybook/react';

Expand Down
28 changes: 14 additions & 14 deletions packages/manager/src/components/DeletionDialog/DeletionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as React from 'react';
import ActionsPanel from 'src/components/ActionsPanel';
import Button from 'src/components/Button';
import { ConfirmationDialog } from 'src/components/ConfirmationDialog/ConfirmationDialog';
import { makeStyles } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import { useTheme } from '@mui/material/styles';
import Typography from 'src/components/core/Typography';
import TypeToConfirm from 'src/components/TypeToConfirm';
import Notice from 'src/components/Notice';
Expand All @@ -12,7 +11,7 @@ import { capitalize } from 'src/utilities/capitalize';
import { DialogProps } from '../Dialog/Dialog';
import { usePreferences } from 'src/queries/preferences';

interface Props extends Omit<DialogProps, 'title'> {
interface DeletionDialogProps extends Omit<DialogProps, 'title'> {
open: boolean;
error?: string;
entity: string;
Expand All @@ -23,15 +22,8 @@ interface Props extends Omit<DialogProps, 'title'> {
typeToConfirm?: boolean;
}

const useStyles = makeStyles((theme: Theme) => ({
text: {
paddingTop: theme.spacing(2),
paddingBottom: theme.spacing(),
},
}));

const DeletionDialog: React.FC<Props> = (props) => {
const classes = useStyles();
const _DeletionDialog = (props: DeletionDialogProps) => {
const theme = useTheme();
const {
entity,
error,
Expand Down Expand Up @@ -96,7 +88,13 @@ const DeletionDialog: React.FC<Props> = (props) => {
placeholder={label}
visible={typeToConfirmRequired}
confirmationText={
<Typography component={'span'} className={classes.text}>
<Typography
component={'span'}
sx={{
paddingTop: theme.spacing(2),
paddingBottom: theme.spacing(),
}}
>
To confirm deletion, type the name of the {entity} (
<strong>{label}</strong>) in the field below:
</Typography>
Expand All @@ -106,4 +104,6 @@ const DeletionDialog: React.FC<Props> = (props) => {
);
};

export default React.memo(DeletionDialog);
const DeletionDialog = React.memo(_DeletionDialog);

export { DeletionDialog };
2 changes: 0 additions & 2 deletions packages/manager/src/components/DeletionDialog/index.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/manager/src/features/Domains/DeleteDomain.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Button from 'src/components/Button';
import DeletionDialog from 'src/components/DeletionDialog';
import { DeletionDialog } from 'src/components/DeletionDialog/DeletionDialog';
import { makeStyles } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import { useDeleteDomainMutation } from 'src/queries/domains';
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/features/Domains/DomainsLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CircleProgress } from 'src/components/CircleProgress';
import { makeStyles } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import Typography from 'src/components/core/Typography';
import DeletionDialog from 'src/components/DeletionDialog';
import { DeletionDialog } from 'src/components/DeletionDialog/DeletionDialog';
import { DocumentTitleSegment } from 'src/components/DocumentTitle';
import ErrorState from 'src/components/ErrorState';
import LandingHeader from 'src/components/LandingHeader';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Theme } from '@mui/material/styles';
import TableBody from 'src/components/core/TableBody';
import TableHead from 'src/components/core/TableHead';
import Typography from 'src/components/core/Typography';
import DeletionDialog from 'src/components/DeletionDialog';
import { DeletionDialog } from 'src/components/DeletionDialog/DeletionDialog';
import { DocumentTitleSegment } from 'src/components/DocumentTitle';
import Grid from '@mui/material/Unstable_Grid2';
import OrderBy from 'src/components/OrderBy';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Theme } from '@mui/material/styles';
import TableBody from 'src/components/core/TableBody';
import TableHead from 'src/components/core/TableHead';
import Typography from 'src/components/core/Typography';
import DeletionDialog from 'src/components/DeletionDialog';
import { DeletionDialog } from 'src/components/DeletionDialog/DeletionDialog';
import { DocumentTitleSegment } from 'src/components/DocumentTitle';
import Grid from '@mui/material/Unstable_Grid2';
import OrderBy from 'src/components/OrderBy';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { makeStyles } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import TableBody from 'src/components/core/TableBody';
import TableHead from 'src/components/core/TableHead';
import DeletionDialog from 'src/components/DeletionDialog';
import { DeletionDialog } from 'src/components/DeletionDialog/DeletionDialog';
import { DocumentTitleSegment } from 'src/components/DocumentTitle';
import Grid from '@mui/material/Unstable_Grid2';
import OrderBy from 'src/components/OrderBy';
Expand Down