Skip to content

Commit

Permalink
refactor: [M3-8097] - Retire recharts feature flag (#10483)
Browse files Browse the repository at this point in the history
* Initial commit: save work

* remove other flag instances

* remove extranuous comments

* Added changeset: Retire recharts feature flag

* feedback @hana-linode - LineGraph deprecation comments
  • Loading branch information
abailly-akamai committed May 20, 2024
1 parent 4b4a3da commit 69c7c15
Show file tree
Hide file tree
Showing 10 changed files with 341 additions and 709 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

Retire recharts feature flag ([#10483](https://github.com/linode/manager/pull/10483))
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* ONLY USED IN THE LINE GRAPH COMPONENT (Longview)
* Delete when LineGraph is sunsetted
*/
import { visuallyHidden } from '@mui/utils';
import { DateTime } from 'luxon';
import * as React from 'react';
Expand All @@ -13,8 +17,6 @@ export interface GraphTabledDataProps {
hiddenDatasets: number[];
}

// @todo recharts: delete this file when we decide recharts is stable (new version is AccessibleAreaChart)

/**
* This component is used to provide an accessible representation of the data
* It does not care about styles, it only cares about presenting the data in bare HTML tables,
Expand Down
4 changes: 4 additions & 0 deletions packages/manager/src/components/LineGraph/LineGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* ONLY USED IN LONGVIEW
* Delete when Lonview is sunsetted, along with AccessibleGraphData
*/
import { Theme, useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import {
Expand Down
1 change: 0 additions & 1 deletion packages/manager/src/dev-tools/FeatureFlagTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const options: { flag: keyof Flags; label: string }[] = [
{ flag: 'objMultiCluster', label: 'OBJ Multi-Cluster' },
{ flag: 'parentChildAccountAccess', label: 'Parent/Child Account' },
{ flag: 'placementGroups', label: 'Placement Groups' },
{ flag: 'recharts', label: 'Recharts' },
{ flag: 'selfServeBetas', label: 'Self Serve Betas' },
{ flag: 'supportTicketSeverity', label: 'Support Ticket Severity' },
];
Expand Down
1 change: 0 additions & 1 deletion packages/manager/src/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export interface Flags {
productInformationBanners: ProductInformationBannerFlag[];
promos: boolean;
promotionalOffers: PromotionalOffer[];
recharts: boolean;
referralBannerText: ReferralBannerText;
selfServeBetas: boolean;
soldOutChips: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ import { LinodeNetworkTimeData, Point } from 'src/components/AreaChart/types';
import { Box } from 'src/components/Box';
import { CircleProgress } from 'src/components/CircleProgress';
import { ErrorState } from 'src/components/ErrorState/ErrorState';
import { LineGraph } from 'src/components/LineGraph/LineGraph';
import { Typography } from 'src/components/Typography';
import {
convertNetworkToUnit,
formatNetworkTooltip,
generateNetworkUnits,
} from 'src/features/Longview/shared/utilities';
import { useFlags } from 'src/hooks/useFlags';
import {
STATS_NOT_READY_API_MESSAGE,
STATS_NOT_READY_MESSAGE,
Expand All @@ -39,7 +36,6 @@ export const TransferHistory = React.memo((props: Props) => {
const { linodeCreated, linodeID } = props;

const theme = useTheme();
const flags = useFlags();

// Needed to see the user's timezone.
const { data: profile } = useProfile();
Expand Down Expand Up @@ -84,16 +80,6 @@ export const TransferHistory = React.memo((props: Props) => {
return convertNetworkToUnit(value, unit);
};

/**
* formatNetworkTooltip is a helper method from Longview, where
* data is expected in bytes. The method does the rounding, unit conversions, etc.
* that we want, but it first multiplies by 8 to convert to bits.
* APIv4 returns this data in bits to begin with,
* so we have to preemptively divide by 8 to counter the conversion inside the helper.
*/
const formatTooltip = (valueInBytes: number) =>
formatNetworkTooltip(valueInBytes / 8);

const maxMonthOffset = getOffsetFromDate(
now,
DateTime.fromISO(linodeCreated, { zone: 'utc' })
Expand Down Expand Up @@ -155,64 +141,39 @@ export const TransferHistory = React.memo((props: Props) => {
);
}

// @TODO recharts: remove conditional code and delete old chart when we decide recharts is stable
if (flags?.recharts) {
const timeData = combinedData.reduce(
(acc: LinodeNetworkTimeData[], point: Point) => {
acc.push({
'Public Outbound Traffic': convertNetworkData
? convertNetworkData(point[1])
: point[1],
timestamp: point[0],
});
return acc;
},
[]
);

return (
<Box marginLeft={-5}>
<AreaChart
areas={[
{
color: '#1CB35C',
dataKey: 'Public Outbound Traffic',
},
]}
xAxis={{
tickFormat: 'LLL dd',
tickGap: 15,
}}
ariaLabel={graphAriaLabel}
data={timeData}
height={190}
timezone={profile?.timezone ?? 'UTC'}
unit={` ${unit}/s`}
/>
</Box>
);
}
const timeData = combinedData.reduce(
(acc: LinodeNetworkTimeData[], point: Point) => {
acc.push({
'Public Outbound Traffic': convertNetworkData
? convertNetworkData(point[1])
: point[1],
timestamp: point[0],
});
return acc;
},
[]
);

return (
<LineGraph
data={[
{
backgroundColor: '#1CB35C',
borderColor: 'transparent',
data: combinedData,
label: 'Public Outbound Traffic',
},
]}
accessibleDataTable={{ unit: 'Kb/s' }}
ariaLabel={graphAriaLabel}
chartHeight={190}
formatData={convertNetworkData}
formatTooltip={formatTooltip}
showToday={true}
tabIndex={-1}
timezone={profile?.timezone ?? 'UTC'}
unit={`/s`}
/>
<Box marginLeft={-5}>
<AreaChart
areas={[
{
color: '#1CB35C',
dataKey: 'Public Outbound Traffic',
},
]}
xAxis={{
tickFormat: 'LLL dd',
tickGap: 15,
}}
ariaLabel={graphAriaLabel}
data={timeData}
height={190}
timezone={profile?.timezone ?? 'UTC'}
unit={` ${unit}/s`}
/>
</Box>
);
};

Expand Down
Loading

0 comments on commit 69c7c15

Please sign in to comment.