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: Clean up App.tsx and MainContent.tsx #9106

Merged
merged 3 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions packages/manager/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ export class App extends React.Component<CombinedProps, State> {
<DocumentTitleSegment segment="Linode Manager" />
{this.props.featureFlagsLoading ? null : (
<MainContent
history={this.props.history}
location={this.props.location}
appIsLoading={this.props.appIsLoading}
isLoggedInAsCustomer={this.props.isLoggedInAsCustomer}
/>
Expand Down
43 changes: 13 additions & 30 deletions packages/manager/src/MainContent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import classNames from 'classnames';
import { isEmpty } from 'ramda';
import * as React from 'react';
import { Redirect, Route, RouteComponentProps, Switch } from 'react-router-dom';
import { Redirect, Route, Switch } from 'react-router-dom';
import { compose } from 'recompose';
import Logo from 'src/assets/logo/akamai-logo.svg';
import Box from 'src/components/core/Box';
import { makeStyles, withTheme, WithTheme } from '@mui/styles';
import { makeStyles } from 'tss-react/mui';
import { Theme } from '@mui/material/styles';
import Grid from '@mui/material/Unstable_Grid2';
import MainContentBanner from 'src/components/MainContentBanner';
Expand Down Expand Up @@ -36,7 +35,7 @@ import { complianceUpdateContext } from './context/complianceUpdateContext';
import { FlagSet } from './featureFlags';
import { ManagerPreferences } from 'src/types/ManagerPreferences';

const useStyles = makeStyles((theme: Theme) => ({
const useStyles = makeStyles()((theme: Theme) => ({
appFrame: {
position: 'relative',
display: 'flex',
Expand All @@ -45,15 +44,6 @@ const useStyles = makeStyles((theme: Theme) => ({
backgroundColor: theme.bg.app,
zIndex: 1,
},
wrapper: {
padding: theme.spacing(3),
transition: theme.transitions.create('opacity'),
[theme.breakpoints.down('md')]: {
paddingTop: theme.spacing(2),
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
},
},
cmrWrapper: {
maxWidth: `${theme.breakpoints.values.lg}px !important`,
padding: `${theme.spacing(3)} 0`,
Expand Down Expand Up @@ -135,13 +125,11 @@ const useStyles = makeStyles((theme: Theme) => ({
}));

interface Props {
location: RouteComponentProps['location'];
history: RouteComponentProps['history'];
appIsLoading: boolean;
isLoggedInAsCustomer: boolean;
}

type CombinedProps = Props & GlobalErrorProps & WithTheme;
type CombinedProps = Props & GlobalErrorProps;

const Account = React.lazy(() => import('src/features/Account'));
const LinodesRoutes = React.lazy(() => import('src/features/linodes'));
Expand Down Expand Up @@ -175,8 +163,8 @@ const AccountActivationLanding = React.lazy(
const Firewalls = React.lazy(() => import('src/features/Firewalls'));
const Databases = React.lazy(() => import('src/features/Databases'));

const MainContent: React.FC<CombinedProps> = (props) => {
const classes = useStyles();
const MainContent = (props: CombinedProps) => {
const { classes, cx } = useStyles();
const flags = useFlags();
const { data: preferences } = usePreferences();

Expand Down Expand Up @@ -259,7 +247,7 @@ const MainContent: React.FC<CombinedProps> = (props) => {
*/
return (
<div
className={classNames({
className={cx({
[classes.appFrame]: true,
/**
* hidden to prevent some jankiness with the app loading before the splash screen
Expand Down Expand Up @@ -293,15 +281,11 @@ const MainContent: React.FC<CombinedProps> = (props) => {
closeMenu={() => toggleMenu(false)}
/>
<div
className={`
${classes.content}
${
className={cx(classes.content, {
[classes.fullWidthContent]:
desktopMenuIsOpen ||
(desktopMenuIsOpen && desktopMenuIsOpen === true)
? classes.fullWidthContent
: ''
}
`}
(desktopMenuIsOpen && desktopMenuIsOpen === true),
})}
>
<TopMenu
isSideMenuOpen={!desktopMenuIsOpen}
Expand All @@ -316,7 +300,7 @@ const MainContent: React.FC<CombinedProps> = (props) => {
role="main"
>
<Grid container spacing={0} className={classes.grid}>
<Grid className={`${classes.switchWrapper} p0`}>
<Grid className={cx(classes.switchWrapper, 'p0')}>
<GlobalNotifications />
<React.Suspense fallback={<SuspenseLoader />}>
<Switch>
Expand Down Expand Up @@ -380,8 +364,7 @@ const MainContent: React.FC<CombinedProps> = (props) => {

export default compose<CombinedProps, Props>(
React.memo,
withGlobalErrors(),
withTheme
withGlobalErrors()
)(MainContent);

// =============================================================================
Expand Down