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-6343] - MUI v5 Migration - Grid v2 for Features #8985

Merged
merged 21 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from 18 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
6 changes: 3 additions & 3 deletions packages/manager/src/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Logo from 'src/assets/logo/akamai-logo.svg';
import Box from 'src/components/core/Box';
import { makeStyles, withTheme, WithTheme } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import Grid from 'src/components/Grid';
import Grid from '@mui/material/Unstable_Grid2';
import MainContentBanner from 'src/components/MainContentBanner';
import { MaintenanceScreen } from 'src/components/MaintenanceScreen';
import NotFound from 'src/components/NotFound';
Expand Down Expand Up @@ -57,7 +57,7 @@ const useStyles = makeStyles((theme: Theme) => ({
cmrWrapper: {
maxWidth: `${theme.breakpoints.values.lg}px !important`,
padding: `${theme.spacing(3)} 0`,
paddingTop: 20,
paddingTop: 12,
transition: theme.transitions.create('opacity'),
[theme.breakpoints.down('md')]: {
paddingTop: theme.spacing(2),
Expand Down Expand Up @@ -316,7 +316,7 @@ const MainContent: React.FC<CombinedProps> = (props) => {
role="main"
>
<Grid container spacing={0} className={classes.grid}>
<Grid item className={`${classes.switchWrapper} p0`}>
<Grid className={`${classes.switchWrapper} p0`}>
<GlobalNotifications />
<React.Suspense fallback={<SuspenseLoader />}>
<Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const useStyles = makeStyles((theme: Theme) => ({
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
padding: `10px 16px !important`,
padding: `7px 16px !important`, // This will be taken care of during refactor
},
footerBorder: {
borderTop: `1px solid ${theme.borderColors.borderTable}`,
Expand Down
4 changes: 2 additions & 2 deletions packages/manager/src/components/MainContentBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import Close from '@mui/icons-material/Close';
import { makeStyles } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import Grid from 'src/components/core/Grid';
import Grid from '@mui/material/Unstable_Grid2';
import Typography from 'src/components/core/Typography';
import { Link } from 'src/components/Link';
import { useMutatePreferences, usePreferences } from 'src/queries/preferences';
Expand Down Expand Up @@ -75,7 +75,7 @@ const MainContentBanner: React.FC<Props> = (props) => {
};

return (
<Grid className={classes.bannerOuter} item xs={12}>
<Grid className={classes.bannerOuter} xs={12}>
<Typography variant="h2" className={classes.header}>
{bannerText}&nbsp;
{linkText && url && (
Expand Down
7 changes: 3 additions & 4 deletions packages/manager/src/components/Notice/Notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { makeStyles } from 'tss-react/mui';
import { withTheme, WithTheme } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import Typography, { TypographyProps } from 'src/components/core/Typography';
import Grid, { GridProps } from 'src/components/Grid';
import Grid, { Grid2Props } from '@mui/material/Unstable_Grid2';
import { SxProps } from '@mui/system';

export const useStyles = makeStyles<
Expand Down Expand Up @@ -112,7 +112,7 @@ export const useStyles = makeStyles<
},
}));

export interface Props extends GridProps {
export interface Props extends Grid2Props {
text?: string;
error?: boolean;
errorGroup?: string;
Expand Down Expand Up @@ -202,7 +202,6 @@ const Notice: React.FC<CombinedProps> = (props) => {

return (
<Grid
item
className={cx({
[classes.root]: true,
[classes.important]: important,
Expand All @@ -229,7 +228,7 @@ const Notice: React.FC<CombinedProps> = (props) => {
sx={sx}
>
{flag && (
<Grid item>
<Grid>
<Flag className={classes.flag} />
</Grid>
)}
Expand Down
4 changes: 2 additions & 2 deletions packages/manager/src/components/PrimaryNav/PrimaryNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Longview from 'src/assets/icons/longview.svg';
import AkamaiLogo from 'src/assets/logo/akamai-logo.svg';
import { BetaChip } from 'src/components/BetaChip/BetaChip';
import Divider from 'src/components/core/Divider';
import Grid from 'src/components/core/Grid';
import Grid from '@mui/material/Unstable_Grid2';
import useAccountManagement from 'src/hooks/useAccountManagement';
import useFlags from 'src/hooks/useFlags';
import usePrefetch from 'src/hooks/usePreFetch';
Expand Down Expand Up @@ -258,7 +258,7 @@ export const PrimaryNav: React.FC<Props> = (props) => {
role="navigation"
id="main-navigation"
>
<Grid item>
<Grid>
<div
className={classNames(classes.logoItemAkamai, {
[classes.logoItemAkamaiCollapsed]: isCollapsed,
Expand Down
34 changes: 19 additions & 15 deletions packages/manager/src/components/TagCell/TagCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Grid from '@mui/material/Unstable_Grid2';
import Tag from 'src/components/Tag';
import CircleProgress from '../CircleProgress';
import AddTag from './AddTag';
import Box from '@mui/material/Box';
import { SxProps } from '@mui/system';

const useStyles = makeStyles((theme: Theme) => ({
root: {
Expand Down Expand Up @@ -59,13 +59,17 @@ const useStyles = makeStyles((theme: Theme) => ({
borderRadius: 0,
color: theme.color.tagIcon,
height: 30,
marginLeft: theme.spacing(),
marginLeft: theme.spacing(0.5),
marginRight: theme.spacing(0.5),
padding: 0,
width: '40px',
'&:hover': {
backgroundColor: theme.palette.primary.main,
color: '#ffff',
},
[theme.breakpoints.down('lg')]: {
marginLeft: 0,
},
},
addTagButton: {
display: 'flex',
Expand Down Expand Up @@ -107,6 +111,7 @@ interface Props {
tags: string[];
updateTags: (tags: string[]) => Promise<any>;
listAllTags: (tags: string[]) => void;
sx?: SxProps;
}

// https://stackoverflow.com/questions/143815/determine-if-an-html-elements-content-overflows
Expand All @@ -129,7 +134,7 @@ export type CombinedProps = Props;
export const TagCell: React.FC<Props> = (props) => {
const classes = useStyles();

const { updateTags, tags } = props;
const { updateTags, tags, sx } = props;

const [hasOverflow, setOverflow] = React.useState<boolean>(false);
const [addingTag, setAddingTag] = React.useState<boolean>(false);
Expand Down Expand Up @@ -168,6 +173,7 @@ export const TagCell: React.FC<Props> = (props) => {
direction="row"
alignItems="center"
wrap="nowrap"
sx={sx}
>
{loading ? (
<div className={classes.progress}>
Expand Down Expand Up @@ -202,18 +208,16 @@ export const TagCell: React.FC<Props> = (props) => {
</div>

{hasOverflow ? (
<Box className="py0">
<IconButton
onKeyPress={() => props.listAllTags(tags)}
onClick={() => props.listAllTags(tags)}
className={classes.button}
disableRipple
aria-label="Display all tags"
size="large"
>
<MoreHoriz />
</IconButton>
</Box>
<IconButton
onKeyPress={() => props.listAllTags(tags)}
onClick={() => props.listAllTags(tags)}
className={classes.button}
disableRipple
aria-label="Display all tags"
size="large"
>
<MoreHoriz />
</IconButton>
) : null}
<button
className={classes.addTagButton}
Expand Down
5 changes: 1 addition & 4 deletions packages/manager/src/components/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ const useStyles = makeStyles((theme: Theme) => ({
marginTop: 0,
},
helpWrapperTextField: {
width: 415,
[theme.breakpoints.down('sm')]: {
width: '100%',
},
width: '415px',
},
errorText: {
display: 'flex',
Expand Down
8 changes: 4 additions & 4 deletions packages/manager/src/dev-tools/EnvironmentToggleTool.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import Grid from 'src/components/core/Grid';
import Grid from '@mui/material/Unstable_Grid2';
import { storage } from 'src/utilities/storage';

interface EnvironmentOption {
Expand Down Expand Up @@ -55,10 +55,10 @@ const EnvironmentToggleTool: React.FC<{}> = () => {

return (
<Grid container>
<Grid item xs={12}>
<h4 style={{ marginBottom: 8 }}>Environment</h4>
<Grid xs={12}>
<h4 style={{ marginTop: 0, marginBottom: 8 }}>Environment</h4>
</Grid>
<Grid item xs={12}>
<Grid xs={12}>
<select
onBlur={(e) => {
const selectedIndex = options.findIndex(
Expand Down
8 changes: 4 additions & 4 deletions packages/manager/src/dev-tools/FeatureFlagTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Flags, FlagSet } from 'src/featureFlags';
import { Dispatch } from 'src/hooks/types';
import useFlags from 'src/hooks/useFlags';
import { setMockFeatureFlags } from 'src/store/mockFeatureFlags';
import Grid from 'src/components/core/Grid';
import Grid from '@mui/material/Unstable_Grid2';

const options: { label: string; flag: keyof Flags }[] = [
{ label: 'Metadata', flag: 'metadata' },
Expand All @@ -25,10 +25,10 @@ const FeatureFlagTool: React.FC<{}> = () => {

return (
<Grid container>
<Grid item xs={12}>
<h4 style={{ marginBottom: 8 }}>Feature Flags</h4>
<Grid xs={12}>
<h4 style={{ marginTop: 0, marginBottom: 8 }}>Feature Flags</h4>
</Grid>
<Grid item xs={12}>
<Grid xs={12}>
<div style={{ display: 'flex', flexDirection: 'column' }}>
{options.map((thisOption) => {
return (
Expand Down
12 changes: 6 additions & 6 deletions packages/manager/src/dev-tools/MockDataTool.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import withFeatureFlagProvider from 'src/containers/withFeatureFlagProvider.container';
import Grid from 'src/components/core/Grid';
import Grid from '@mui/material/Unstable_Grid2';
import { MockData, mockDataController } from './mockDataController';
import ServiceWorkerTool from './ServiceWorkerTool';

Expand Down Expand Up @@ -34,11 +34,11 @@ const MockDataTool: React.FC<{}> = () => {
// specific fields, like label, region, etc. (via <input /> or even JSON entry?)

return (
<Grid>
<Grid item xs={12}>
<h4 style={{ marginBottom: 8 }}>Mock Data</h4>
<Grid container>
<Grid xs={12}>
<h4 style={{ marginTop: 0, marginBottom: 8 }}>Mock Data</h4>
</Grid>
<Grid item xs={12}>
<Grid xs={12}>
{options.map((thisOption) => {
return (
<div key={thisOption.key} style={{ marginTop: 4 }}>
Expand All @@ -55,7 +55,7 @@ const MockDataTool: React.FC<{}> = () => {
);
})}
</Grid>
<Grid item xs={12}>
<Grid xs={12}>
<ServiceWorkerTool />
</Grid>
</Grid>
Expand Down
8 changes: 4 additions & 4 deletions packages/manager/src/dev-tools/dev-tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import EnvironmentToggleTool from './EnvironmentToggleTool';
import { Provider } from 'react-redux';
import MockDataTool from './MockDataTool';
import { ENABLE_DEV_TOOLS, isProductionBuild } from 'src/constants';
import Grid from 'src/components/core/Grid';
import Grid from '@mui/material/Unstable_Grid2';
import { ApplicationStore } from 'src/store';

function install(store: ApplicationStore) {
Expand All @@ -18,16 +18,16 @@ function install(store: ApplicationStore) {
<div id="dev-tools">
<div>🛠</div>
<Grid container spacing={2} className="tools">
<Grid item xs={4} sm={2}>
<Grid xs={4} sm={2}>
<FeatureFlagTool />
</Grid>
{import.meta.env.DEV && (
<Grid item xs={4} sm={5} md={3}>
<Grid xs={4} sm={5} md={3}>
<EnvironmentToggleTool />
</Grid>
)}
{!isProductionBuild || ENABLE_DEV_TOOLS ? (
<Grid item xs={4} sm={5} md={3}>
<Grid xs={4} sm={5} md={3}>
<MockDataTool />
</Grid>
) : null}
Expand Down
12 changes: 6 additions & 6 deletions packages/manager/src/features/Account/AutoBackups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Theme } from '@mui/material/styles';
import * as React from 'react';
import Accordion from 'src/components/Accordion';
import FormControlLabel from 'src/components/core/FormControlLabel';
import Grid from 'src/components/Grid';
import Grid from '@mui/material/Unstable_Grid2';
import Notice from 'src/components/Notice';
import OpenInNew from '@mui/icons-material/OpenInNew';
import { Toggle } from 'src/components/Toggle';
Expand Down Expand Up @@ -46,8 +46,8 @@ const AutoBackups = (props: Props) => {

return (
<Accordion heading="Backup Auto Enrollment" defaultExpanded={true}>
<Grid container direction="column">
<Grid item>
<Grid container direction="column" spacing={2}>
<Grid>
{!!isManagedCustomer ? (
<Notice success spacingBottom={20}>
You&rsquo;re a Managed customer, which means your Linodes are
Expand All @@ -72,8 +72,8 @@ const AutoBackups = (props: Props) => {
.
</Typography>
</Grid>
<Grid item container direction="row" alignItems="center">
<Grid item>
<Grid container direction="row" alignItems="center">
<Grid>
<FormControlLabel
control={
<Toggle
Expand All @@ -92,7 +92,7 @@ const AutoBackups = (props: Props) => {
</Grid>
</Grid>
{!isManagedCustomer && !backups_enabled && hasLinodesWithoutBackups && (
<Grid item>
<Grid>
<Typography variant="body1" className={classes.footnote}>
For existing Linodes without backups,&nbsp;
<button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import Accordion from 'src/components/Accordion';
import Button from 'src/components/Button';
import Grid from 'src/components/Grid';
import Grid from '@mui/material/Unstable_Grid2';
import CloseAccountDialog from './CloseAccountDialog';

const CloseAccountSetting = () => {
Expand All @@ -11,7 +11,7 @@ const CloseAccountSetting = () => {
<>
<Accordion heading="Close Account" defaultExpanded={true}>
<Grid container direction="column">
<Grid item>
<Grid>
<Button buttonType="outlined" onClick={() => setDialogOpen(true)}>
Close Account
</Button>
Expand Down
8 changes: 4 additions & 4 deletions packages/manager/src/features/Account/EnableManaged.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Button from 'src/components/Button';
import ConfirmationDialog from 'src/components/ConfirmationDialog';
import Typography from 'src/components/core/Typography';
import ExternalLink from 'src/components/ExternalLink';
import Grid from 'src/components/Grid';
import Grid from '@mui/material/Unstable_Grid2';
import { SupportLink } from 'src/components/SupportLink';
import withLinodes, {
DispatchProps,
Expand Down Expand Up @@ -44,8 +44,8 @@ export const ManagedContent = (props: ContentProps) => {
}

return (
<Grid container direction="column">
<Grid item>
<Grid container direction="column" spacing={2}>
<Grid>
<Typography variant="body1">
Linode Managed includes Backups, Longview Pro, cPanel, and
round-the-clock monitoring to help keep your systems up and running.
Expand All @@ -57,7 +57,7 @@ export const ManagedContent = (props: ContentProps) => {
/>
</Typography>
</Grid>
<Grid item>
<Grid>
<Button buttonType="outlined" onClick={openConfirmationModal}>
Add Linode Managed
</Button>
Expand Down
Loading