Skip to content

Commit

Permalink
refactor: [M3-6359] - MUI v5 Migration - `Components > LongviewLineGr…
Browse files Browse the repository at this point in the history
…aph` (#9291)

## Description 📝
Update styles and code patterns for the LongviewLineGraph component

## How to test 🧪
So, we don't have an account that has Longview setup and when I tried to run the curl command to set it up, I kept running into errors. I think the changes are minor enough that we can just check the code
  • Loading branch information
hana-akamai authored Jun 26, 2023
1 parent b6cacce commit ae62d9e
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

MUI v5 Migration - `Components > LongviewLineGraph` ([#9291](https://github.com/linode/manager/pull/9291))
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { compose } from 'recompose';
import Divider from 'src/components/core/Divider';
import { makeStyles } from '@mui/styles';
import { makeStyles } from 'tss-react/mui';
import { Theme } from '@mui/material/styles';
import Typography from 'src/components/core/Typography';
import { ErrorState } from 'src/components/ErrorState/ErrorState';
Expand All @@ -11,7 +10,7 @@ import {
LineGraphProps,
} from 'src/components/LineGraph/LineGraph';

const useStyles = makeStyles((theme: Theme) => ({
const useStyles = makeStyles()((theme: Theme) => ({
title: {
color: theme.color.headline,
fontWeight: 'bold',
Expand All @@ -28,18 +27,16 @@ const useStyles = makeStyles((theme: Theme) => ({
},
}));

export interface Props extends LineGraphProps {
export interface LongViewLineGraphProps extends LineGraphProps {
title: string;
subtitle?: string;
error?: string;
loading?: boolean;
ariaLabel?: string;
}

type CombinedProps = Props;

const LongviewLineGraph: React.FC<CombinedProps> = (props) => {
const classes = useStyles();
export const LongviewLineGraph = React.memo((props: LongViewLineGraphProps) => {
const { classes } = useStyles();

const { error, loading, title, subtitle, ariaLabel, ...rest } = props;

Expand Down Expand Up @@ -74,7 +71,7 @@ const LongviewLineGraph: React.FC<CombinedProps> = (props) => {
</div>
</React.Fragment>
);
};
});

export const isDataEmpty = (data: DataSet[]) => {
return data.every(
Expand All @@ -84,5 +81,3 @@ export const isDataEmpty = (data: DataSet[]) => {
thisSeries.data.every((thisPoint) => thisPoint[1] === null)
);
};

export default compose<CombinedProps, Props>(React.memo)(LongviewLineGraph);
6 changes: 0 additions & 6 deletions packages/manager/src/components/LongviewLineGraph/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { compose } from 'recompose';
import Paper from 'src/components/core/Paper';
import { WithTheme, withTheme } from '@mui/styles';
import Grid from 'src/components/Grid';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import {
convertNetworkToUnit,
formatNetworkTooltip,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { compose } from 'recompose';
import { makeStyles, withTheme, WithTheme } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import Typography from 'src/components/core/Typography';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import { isToday as _isToday } from 'src/utilities/isToday';
import { Stat, StatWithDummyPoint } from '../../../request.types';
import { convertData } from '../../../shared/formatters';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import Paper from 'src/components/core/Paper';
import { withTheme, WithTheme } from '@mui/styles';
import Grid from 'src/components/Grid';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import {
formatNetworkTooltip,
getMaxUnitAndFormatNetwork,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { compose } from 'recompose';
import Paper from 'src/components/core/Paper';
import { WithTheme, withTheme } from '@mui/styles';
import Grid from 'src/components/Grid';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import { LongviewProcesses, NginxResponse } from '../../../request.types';
import { convertData } from '../../../shared/formatters';
import ProcessGraphs, { useStyles } from '../ProcessGraphs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { CircleProgress } from 'src/components/CircleProgress';
import { withTheme, WithTheme } from '@mui/styles';
import { ErrorState } from 'src/components/ErrorState/ErrorState';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import { Placeholder } from 'src/components/Placeholder/Placeholder';
import {
convertNetworkToUnit,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { withTheme, WithTheme } from '@mui/styles';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import { sumCPU } from 'src/features/Longview/shared/utilities';
import {
convertData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { pathOr } from 'ramda';
import * as React from 'react';
import { withTheme, WithTheme } from '@mui/styles';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import { appendStats } from 'src/features/Longview/shared/utilities';
import { Disk, StatWithDummyPoint } from '../../../request.types';
import { convertData } from '../../../shared/formatters';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { withTheme, WithTheme } from '@mui/styles';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import { convertData } from '../../../shared/formatters';
import { GraphProps } from './types';
import { useGraphs } from './useGraphs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { pathOr } from 'ramda';
import * as React from 'react';
import { withTheme, WithTheme } from '@mui/styles';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import {
convertBytesToTarget,
readableBytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { pathOr } from 'ramda';
import * as React from 'react';
import { compose } from 'recompose';
import { withTheme, WithTheme } from '@mui/styles';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import {
formatNetworkTooltip,
getMaxUnitAndFormatNetwork,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { compose } from 'recompose';
import { makeStyles, WithTheme, withTheme } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import Grid from 'src/components/Grid';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import {
convertBytesToTarget,
readableBytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Paper from 'src/components/core/Paper';
import { makeStyles, withTheme, WithTheme } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import Typography from 'src/components/core/Typography';
import LongviewLineGraph from 'src/components/LongviewLineGraph';
import { LongviewLineGraph } from 'src/components/LongviewLineGraph/LongviewLineGraph';
import {
LongviewProcesses,
WithStartAndEnd,
Expand Down

0 comments on commit ae62d9e

Please sign in to comment.