Skip to content

Commit b5d9206

Browse files
committed
removed Series and ActionObj ts from PerformanceVisx to be imported
1 parent 1be9322 commit b5d9206

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

src/app/components/FrontendTypes.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
import { SeriesPoint } from '@visx/shape/lib/types';
22

3+
// PerformanceVisx types
4+
5+
export interface Series {
6+
data: {
7+
barStack: ActionObj[],
8+
}
9+
name: string
10+
}
11+
12+
interface ActionObj {
13+
name: unknown,
14+
seriesName: unknown,
15+
}
16+
317
export interface PerfData {
418
barStack: BarStackProp[],
519
componentData?: Record<string, unknown>,
@@ -9,6 +23,7 @@ export interface PerfData {
923
interface BarStackProp {
1024
snapshotId: string,
1125
route: URL,
26+
currentTab?: string,
1227
}
1328

1429
// On-hover data for BarGraph/BarGraphComparison.tsx
@@ -42,11 +57,12 @@ interface BarGraphBase {
4257
width: number,
4358
height: number,
4459
data: PerfData,
45-
comparison: string | [],
60+
comparison: string | Series | [],
4661
}
62+
4763
export interface BarGraphComparisonProps extends BarGraphBase {
4864
setSeries: () => void,
49-
series: unknown,
65+
series: number,
5066
setAction: () => void,
5167
}
5268

src/app/components/StateRoute/PerformanceVisx/BarGraphComparison.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-param-reassign */
12
import React, { useEffect } from 'react';
23
import { BarStack } from '@visx/shape';
34
import { Group } from '@visx/group';
@@ -77,10 +78,10 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
7778
// We'll then use it in the renderingScale function and compare
7879
// with the render time of the current tab.
7980
// The max render time will determine the Y-axis's highest number.
80-
const calculateMaxTotalRender = series => {
81-
const currentSeriesBarStacks = !comparison[series]
81+
const calculateMaxTotalRender = serie => {
82+
const currentSeriesBarStacks = !comparison[serie]
8283
? []
83-
: comparison[series].data.barStack;
84+
: comparison[serie].data.barStack;
8485
if (currentSeriesBarStacks.length === 0) return 0;
8586
let currentMax = -Infinity;
8687
for (let i = 0; i < currentSeriesBarStacks.length; i += 1) {

src/app/components/StateRoute/PerformanceVisx/PerformanceVisx.tsx

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import BarGraphComparison from './BarGraphComparison';
1717
import BarGraphComparisonActions from './BarGraphComparisonActions';
1818
import { useStoreContext } from '../../../store';
1919
import { setCurrentTabInApp } from '../../../actions/actions';
20-
import { PerfData } from '../../FrontendTypes';
20+
import { PerfData, Series } from '../../FrontendTypes';
2121

2222
interface PerformanceVisxProps {
2323
width: number;
@@ -148,14 +148,6 @@ const getSnapshotIds = (obj, snapshotIds = []): string[] => {
148148
return snapshotIds;
149149
};
150150

151-
// type BarStackProp = Record <string, unknown | URL | number>
152-
153-
// interface PerfData {
154-
// barStack: BarStackProp[],
155-
// componentData?: Record<string, unknown>,
156-
// maxTotalRender: number,
157-
// }
158-
159151
// Returns array of snapshot objs each with components and corresponding render times.
160152
const getPerfMetrics = (snapshots, snapshotsIds): PerfData => {
161153
const perfData: PerfData = {
@@ -189,18 +181,6 @@ const PerformanceVisx = (props: PerformanceVisxProps): JSX.Element => {
189181
dispatch(setCurrentTabInApp('performance'));
190182
}, [dispatch]);
191183

192-
type Series = {
193-
data: {
194-
barStack: ActionObj[],
195-
}
196-
name: string
197-
}
198-
199-
type ActionObj = {
200-
name: unknown,
201-
seriesName: unknown,
202-
}
203-
204184
// Creates the actions array used to populate the compare actions dropdown
205185
const getActions = () => {
206186
const project = localStorage.getItem('project');

0 commit comments

Comments
 (0)