Skip to content

Commit 5404d5b

Browse files
authored
Merge pull request #2 from oslabs-beta/louis/new-feature
Updated typescript interface and remove deprecated code
2 parents e873fe5 + 4203e96 commit 5404d5b

14 files changed

+58
-64
lines changed

src/app/components/Action.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,33 @@ const Action = (props: ActionProps): JSX.Element => {
5858

5959
/**
6060
* @function cleanTime: Displays render times for state changes
61-
* @returns render display time in seconds in miliseconds
61+
* @returns render display time in seconds in milliseconds
6262
*/
6363
const cleanTime = () => {
6464
if (!componentData || !componentData.actualDuration) {
6565
return 'NO TIME';
6666
}
6767
let seconds: number | string;
68-
let miliseconds: any = componentData.actualDuration;
68+
let milliseconds: any = componentData.actualDuration;
6969
if (Math.floor(componentData.actualDuration) > 60) {
7070
seconds = Math.floor(componentData.actualDuration / 60);
7171
seconds = JSON.stringify(seconds);
7272
if (seconds.length < 2) {
7373
seconds = '0'.concat(seconds);
7474
}
75-
miliseconds = Math.floor(componentData.actualDuration % 60);
75+
milliseconds = Math.floor(componentData.actualDuration % 60);
7676
} else {
7777
seconds = '00';
7878
}
79-
miliseconds = Number.parseFloat(miliseconds).toFixed(2);
80-
const arrayMiliseconds = miliseconds.split('.');
81-
if (arrayMiliseconds[0].length < 2) {
82-
arrayMiliseconds[0] = '0'.concat(arrayMiliseconds[0]);
79+
milliseconds = Number.parseFloat(milliseconds).toFixed(2);
80+
const arrayMilliseconds = milliseconds.split('.');
81+
if (arrayMilliseconds[0].length < 2) {
82+
arrayMilliseconds[0] = '0'.concat(arrayMilliseconds[0]);
8383
}
8484
if (index === 0) {
85-
return `${seconds}:${arrayMiliseconds[0]}.${arrayMiliseconds[1]}`;
85+
return `${seconds}:${arrayMilliseconds[0]}.${arrayMilliseconds[1]}`;
8686
}
87-
return `+${seconds}:${arrayMiliseconds[0]}.${arrayMiliseconds[1]}`;
87+
return `+${seconds}:${arrayMilliseconds[0]}.${arrayMilliseconds[1]}`;
8888
};
8989
const displayTime = cleanTime();
9090

src/app/components/App.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ import React, { useReducer } from 'react';
22
import {
33
MemoryRouter as Router,
44
} from 'react-router-dom';
5-
// import { Steps, Hints } from 'intro.js-react';
65
import MainContainer from '../containers/MainContainer';
76
import { StoreContext } from '../store';
87
import mainReducer from '../reducers/mainReducer.js';
98

10-
// import 'intro.js/introjs.css';
11-
129
// currentTab is the current active tab within Google Chrome.
1310
// This is used to decide what tab Reactime should be monitoring. This can be "locked"
1411
// currentTabInApp is the current active tab within Reactime (Map, Performance, History, etc).

src/app/components/BarGraph.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-nocheck
22
import React, { useEffect, useState } from 'react';
3-
import { BarStack, Bar } from '@visx/shape';
3+
import { BarStack } from '@visx/shape';
44
import { SeriesPoint } from '@visx/shape/lib/types';
55
import { Group } from '@visx/group';
66
import { Grid } from '@visx/grid';
@@ -43,6 +43,18 @@ interface TooltipData {
4343
color: string;
4444
}
4545

46+
interface BarGraphProps {
47+
width: number,
48+
height: number,
49+
data: Record<string, unknown>,
50+
comparison: unknown,
51+
setRoute: () => void,
52+
allRoutes: unknown,
53+
filteredSnapshots: unknown,
54+
snapshot: unknown,
55+
setSnapshot: () => void
56+
}
57+
4658
/* DEFAULTS */
4759
const margin = {
4860
top: 30, right: 30, bottom: 0, left: 50,
@@ -59,7 +71,7 @@ const tooltipStyles = {
5971
fontFamily: 'Roboto',
6072
};
6173

62-
const BarGraph = props => {
74+
const BarGraph = (props: BarGraphProps): unknown => {
6375
const [{ tabs, currentTab }, dispatch] = useStoreContext();
6476
const {
6577
width,
@@ -70,7 +82,7 @@ const BarGraph = props => {
7082
allRoutes,
7183
filteredSnapshots,
7284
snapshot,
73-
setSnapshot
85+
setSnapshot,
7486
} = props;
7587
const [seriesNameInput, setSeriesNameInput] = useState(`Series ${comparison.length + 1}`);
7688
const {

src/app/components/BarGraphComparison.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ import { onHover, onHoverExit, deleteSeries, setCurrentTabInApp } from '../actio
1717
import { useStoreContext } from '../store';
1818

1919
/* TYPESCRIPT */
20-
interface data {
21-
snapshotId?: string;
22-
}
23-
interface series {
24-
seriesId?: any;
25-
}
2620

2721
interface margin {
2822
top: number;
@@ -51,6 +45,16 @@ interface TooltipData {
5145
color: string;
5246
}
5347

48+
interface BarGraphComparisonProps {
49+
width: number,
50+
height: number,
51+
data: Record<string, unknown>,
52+
comparison: string | [],
53+
setSeries: () => void,
54+
series: unknown,
55+
setAction: () => void,
56+
}
57+
5458
/* DEFAULTS */
5559
const margin = {
5660
top: 30, right: 30, bottom: 0, left: 50,
@@ -67,10 +71,10 @@ const tooltipStyles = {
6771
fontFamily: 'Roboto',
6872
};
6973

70-
const BarGraphComparison = props => {
74+
const BarGraphComparison = (props: BarGraphComparisonProps): unknown => {
7175
const [{ tabs, currentTab }, dispatch] = useStoreContext();
7276
const {
73-
width, height, data, comparison, setSeries, series, setAction
77+
width, height, data, comparison, setSeries, series, setAction,
7478
} = props;
7579
const [snapshots] = React.useState(0);
7680
const [open, setOpen] = React.useState(false);
@@ -207,7 +211,7 @@ const BarGraphComparison = props => {
207211
return data.barStack;
208212
}
209213
const animateButton = e => {
210-
e.preventDefault;
214+
e.preventDefault();
211215
e.target.classList.add('animate');
212216
e.target.innerHTML = 'Deleted!';
213217
setTimeout(() => {

src/app/components/Diff.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function Diff(props: DiffProps) {
2828
}
2929

3030
// cleaning preview from stateless data
31-
const statelessCleanning = (obj:{name?:string; componentData?:object; state?:string|any;stateSnaphot?:object; children?:any[]}) => {
31+
const statelessCleanning = (obj:{name?:string; componentData?:object; state?:string|any; stateSnaphot?:object; children?:any[]}) => {
3232
const newObj = { ...obj };
3333
if (newObj.name === 'nameless') {
3434
delete newObj.name;

src/app/components/StateRoute.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import PerformanceVisx from './PerformanceVisx';
2222
import WebMetrics from './WebMetrics';
2323

2424
const History = require('./History').default;
25-
const ErrorHandler = require('./ErrorHandler').default;
2625

2726
const NO_STATE_MSG = 'No state change detected. Trigger an event to change state';
2827
// eslint-disable-next-line react/prop-types
@@ -64,9 +63,9 @@ const StateRoute = (props: StateRouteProps) => {
6463

6564
// the hierarchy gets set upon the first click on the page
6665
// when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized
67-
// if true, we invoke teh D3 render chart with hierarchy
66+
// if true, we invoke the D3 render chart with hierarchy
6867
// by invoking History component, and passing in all the props required to render D3 elements and perform timeJump from clicking of node
69-
// otherwise we an alert to the user that no state was found.
68+
// otherwise we send an alert to the user that no state was found.
7069
const renderHistory = () => {
7170
if (hierarchy) {
7271
return (

src/app/containers/ActionContainer.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const resetSlider = () => {
2222
function ActionContainer(props): JSX.Element {
2323
const [{ tabs, currentTab, port }, dispatch] = useStoreContext();
2424
const {
25-
currLocation, hierarchy, sliderIndex, viewIndex, snapshots,
25+
currLocation, hierarchy, sliderIndex, viewIndex,
2626
} = tabs[currentTab];
2727
const {
2828
toggleActionContainer, actionView, setActionView,
@@ -52,8 +52,6 @@ function ActionContainer(props): JSX.Element {
5252
state: obj.stateSnapshot.children[0].state,
5353
componentName: obj.stateSnapshot.children[0].name,
5454
routePath: obj.stateSnapshot.route.url,
55-
// nathan testing new entries for component name, original above
56-
// componentName: findDiff(obj.index),
5755
componentData:
5856
JSON.stringify(obj.stateSnapshot.children[0].componentData) === '{}'
5957
? ''

src/app/containers/ButtonsContainer.tsx

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
// @ts-nocheck
22

33
import * as React from 'react';
4-
import {
5-
useState, useRef, useEffect,
6-
} from 'react';
74
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
85
import {
96
faUpload,
10-
faQuestion,
117
faDownload,
128
faSquare,
139
faColumns,
@@ -54,16 +50,11 @@ function importHandler(dispatch: (a: any) => void) {
5450
fileUpload.click();
5551
}
5652

57-
function howToUseHandler() {
58-
window.open('https://github.com/open-source-labs/reactime', '_blank');
59-
return null;
60-
}
61-
6253
function ButtonsContainer(): JSX.Element {
6354
const [{ tabs, currentTab, split, currentTabInApp }, dispatch] = useStoreContext();
6455
const {
6556
snapshots,
66-
mode: { paused, persist },
57+
mode: { paused },
6758
} = tabs[currentTab];
6859

6960
return (
@@ -94,20 +85,6 @@ function ButtonsContainer(): JSX.Element {
9485
{split ? 'Unsplit' : 'Split'}
9586
</button>
9687

97-
{/* removing the UI for now Defunt perist feauture. See docs for more info */}
98-
{/* <button
99-
className="persist-button"
100-
type="button"
101-
onClick={() => dispatch(toggleMode('persist'))}
102-
>
103-
{persist ? (
104-
<FontAwesomeIcon icon={faRedoAlt} />
105-
) : (
106-
<FontAwesomeIcon icon={faMapPin} />
107-
)}
108-
{persist ? 'Unpersist' : 'Persist'}
109-
</button> */}
110-
11188
<button
11289
className="export-button"
11390
type="button"

src/app/containers/ErrorContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Loader from '../components/Loader';
55
import ErrorMsg from '../components/ErrorMsg';
66
import { useStoreContext } from '../store';
77

8-
function ErrorContainer(props): JSX.Element {
8+
function ErrorContainer(): any {
99
const [store, dispatch] = useStoreContext();
1010
const { tabs, currentTitle, currentTab } = store;
1111
// hooks for error checks

src/app/containers/MainContainer.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from '../actions/actions';
2020
import { useStoreContext } from '../store';
2121

22-
function MainContainer(): any {
22+
function MainContainer(): JSX.Element {
2323
const [store, dispatch] = useStoreContext();
2424
const {
2525
tabs, currentTab, port, split,
@@ -28,6 +28,7 @@ function MainContainer(): any {
2828
// this function handles Time Jump sidebar view
2929
const toggleActionContainer = () => {
3030
setActionView(!actionView);
31+
// aside is like an added text that appears "on the side" aside some text.
3132
const toggleElem = document.querySelector('aside');
3233
toggleElem.classList.toggle('no-aside');
3334
// hides the record toggle button from Actions Container in Time Jump sidebar view
@@ -47,15 +48,16 @@ function MainContainer(): any {
4748
const currentPort = chrome.runtime.connect();
4849
// listen for a message containing snapshots from the background script
4950
currentPort.onMessage.addListener(
51+
// parameter message is an object with following type script properties
5052
(message: {
5153
action: string;
5254
payload: Record<string, unknown>;
5355
sourceTab: number;
5456
}) => {
5557
const { action, payload, sourceTab } = message;
56-
let maxTab;
58+
let maxTab: number;
5759
if (!sourceTab) {
58-
const tabsArray: any = Object.keys(payload);
60+
const tabsArray: Array<string> = Object.keys(payload);
5961
maxTab = Math.max(...tabsArray);
6062
}
6163
switch (action) {
@@ -92,7 +94,7 @@ function MainContainer(): any {
9294
);
9395

9496
currentPort.onDisconnect.addListener(() => {
95-
console.log('this port is disconeccting line 79');
97+
console.log('this port is disconnecting line 79');
9698
// disconnecting
9799
});
98100

0 commit comments

Comments
 (0)