Skip to content

Commit ba0fdca

Browse files
authored
Merge pull request #8 from oslabs-beta/PerfVisxTutorial
Performance tab tutorial complete, series name input box styling fixes
2 parents 5424815 + 08b7d9f commit ba0fdca

17 files changed

+528
-160
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"import/extensions": "off",
1313
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
1414
"react-hooks/exhaustive-deps": "warn", // Checks effect dependencies
15-
"react/jsx-filename-extension": [0]
15+
"react/jsx-filename-extension": [0],
16+
"linebreak-style": "off"
1617
},
1718
"env": {
1819
"es6": true,

src/app/actions/actions.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,14 @@ export const onHoverExit = (rtid) => ({
118118
export const setCurrentLocation = (tabsObj) => ({
119119
type: types.SET_CURRENT_LOCATION,
120120
payload: tabsObj,
121-
})
121+
});
122+
123+
export const setCurrentTabInApp = (currentTabInApp) => ({
124+
type: types.SET_CURRENT_TAB_IN_APP,
125+
payload: currentTabInApp,
126+
});
127+
128+
export const tutorialSaveSeriesToggle = (toggleVal) => ({
129+
type: types.TUTORIAL_SAVE_SERIES_TOGGLE,
130+
payload: toggleVal,
131+
});

src/app/components/App.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,44 @@
11
import React, { useReducer, useState } from 'react';
2+
import {
3+
MemoryRouter as Router,
4+
Route,
5+
NavLink,
6+
Switch,
7+
useLocation,
8+
} from 'react-router-dom';
29
// import { Steps, Hints } from 'intro.js-react';
310
import MainContainer from '../containers/MainContainer';
411
import { StoreContext } from '../store';
512
import mainReducer from '../reducers/mainReducer.js';
613

14+
715
// import 'intro.js/introjs.css';
816

17+
// currentTab is the current active tab within Google Chrome. This is used to decide what tab Reactime should be monitoring. This can be "locked"
18+
// currentTabInApp is the current active tab within Reactime (Map, Performance, History, etc). This is used to determine the proper tutorial to render when How To button is pressed.
19+
920
const initialState: {
1021
port: null | number,
1122
currentTab: null | number,
1223
currentTitle: null | string,
1324
split: null | boolean,
14-
tabs: unknown; } = {
25+
tabs: unknown,
26+
currentTabInApp: null | string, } = {
1527
port: null,
1628
currentTab: null,
1729
currentTitle: 'No Target',
1830
split: false,
1931
tabs: {},
32+
currentTabInApp: null,
2033
};
2134

2235
function App(): JSX.Element {
2336
return (
24-
<StoreContext.Provider value={useReducer(mainReducer, initialState)}>
25-
<MainContainer />
26-
</StoreContext.Provider>
37+
<Router>
38+
<StoreContext.Provider value={useReducer(mainReducer, initialState)}>
39+
<MainContainer />
40+
</StoreContext.Provider>
41+
</Router>
2742
);
2843
}
2944

src/app/components/BarGraph.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const tooltipStyles = {
6262
const BarGraph = props => {
6363
const [{ tabs, currentTab }, dispatch] = useStoreContext();
6464
const { width, height, data, comparison } = props;
65-
const [seriesNameInput, setSeriesNameInput] = useState(`Series ${comparison.length}`);
65+
const [ seriesNameInput, setSeriesNameInput ] = useState(`Series ${comparison.length + 1}`);
6666
const {
6767
tooltipOpen,
6868
tooltipLeft,

src/app/components/BarGraphComparison.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-nocheck
2-
import React from 'react';
2+
import React, { useEffect } from 'react';
33
import { BarStack } from '@visx/shape';
44
import { SeriesPoint } from '@visx/shape/lib/types';
55
import { Group } from '@visx/group';
@@ -13,7 +13,7 @@ import { makeStyles } from '@material-ui/core/styles';
1313
import Select from '@material-ui/core/Select';
1414
import MenuItem from '@material-ui/core/MenuItem';
1515
import FormControl from '@material-ui/core/FormControl';
16-
import { onHover, onHoverExit, deleteSeries } from '../actions/actions';
16+
import { onHover, onHoverExit, deleteSeries, setCurrentTabInApp } from '../actions/actions';
1717
import { useStoreContext } from '../store';
1818

1919
/* TYPESCRIPT */
@@ -75,6 +75,9 @@ const BarGraphComparison = props => {
7575
const [snapshots, setSnapshots] = React.useState(0);
7676
const [open, setOpen] = React.useState(false);
7777
const [picOpen, setPicOpen] = React.useState(false);
78+
useEffect(() => {
79+
dispatch(setCurrentTabInApp('performance-comparison'));
80+
}, []);
7881

7982
const currentIndex = tabs[currentTab].sliderIndex;
8083

@@ -239,11 +242,10 @@ const BarGraphComparison = props => {
239242
Clear All Series
240243
</button>
241244
<h4 style={{ padding: '0 1rem' }}>Compare Series: </h4>
242-
<FormControl variant="outlined" className={classes.formControl}>
245+
<FormControl id="selectSeries" variant="outlined" className={classes.formControl}>
243246
<Select
244247
style={{ color: 'white' }}
245248
labelId="simple-select-outlined-label"
246-
id="simple-select-outlined"
247249
className={classes.select}
248250
open={open}
249251
onClose={handleClose}

src/app/components/BarGraphComparisonActions.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-nocheck
2-
import React from 'react';
2+
import React, { useEffect } from 'react';
33
import { BarStack } from '@visx/shape';
44
import { SeriesPoint } from '@visx/shape/lib/types';
55
import { Group } from '@visx/group';
@@ -13,7 +13,7 @@ import { makeStyles } from '@material-ui/core/styles';
1313
import Select from '@material-ui/core/Select';
1414
import MenuItem from '@material-ui/core/MenuItem';
1515
import FormControl from '@material-ui/core/FormControl';
16-
import { onHover, onHoverExit, deleteSeries } from '../actions/actions';
16+
import { onHover, onHoverExit, deleteSeries, setCurrentTabInApp } from '../actions/actions';
1717
import { useStoreContext } from '../store';
1818

1919
/* TYPESCRIPT */
@@ -75,6 +75,9 @@ const BarGraphComparisonActions = props => {
7575
const [snapshots, setSnapshots] = React.useState(0);
7676
const [open, setOpen] = React.useState(false);
7777
const [picOpen, setPicOpen] = React.useState(false);
78+
useEffect(() => {
79+
dispatch(setCurrentTabInApp('performance-comparison'));
80+
}, []);
7881

7982
const {
8083
tooltipOpen,

src/app/components/ComponentMap.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import {
1919
} from '@visx/tooltip';
2020
import LinkControls from './LinkControls';
2121
import getLinkComponent from './getLinkComponent';
22-
import { toggleExpanded } from '../actions/actions';
22+
import { toggleExpanded, setCurrentTabInApp } from '../actions/actions';
2323
import { useStoreContext } from '../store';
24+
import { useEffect } from 'react';
2425

2526
const exclude = ['childExpirationTime', 'staticContext', '_debugSource', 'actualDuration', 'actualStartTime', 'treeBaseDuration', '_debugID', '_debugIsCurrentlyTiming', 'selfBaseDuration', 'expirationTime', 'effectTag', 'alternate', '_owner', '_store', 'get key', 'ref', '_self', '_source', 'firstBaseUpdate', 'updateQueue', 'lastBaseUpdate', 'shared', 'responders', 'pending', 'lanes', 'childLanes', 'effects', 'memoizedState', 'pendingProps', 'lastEffect', 'firstEffect', 'tag', 'baseState', 'baseQueue', 'dependencies', 'Consumer', 'context', '_currentRenderer', '_currentRenderer2', 'mode', 'flags', 'nextEffect', 'sibling', 'create', 'deps', 'next', 'destroy', 'parentSub', 'child', 'key', 'return', 'children', '$$typeof', '_threadCount', '_calculateChangedBits', '_currentValue', '_currentValue2', 'Provider', '_context', 'stateNode', 'elementType', 'type'];
2627

@@ -74,6 +75,10 @@ export default function ComponentMap({
7475
const [selectedNode, setSelectedNode] = useState('root');
7576
const [{ tabs, currentTab }, dispatch] = useStoreContext();
7677

78+
useEffect(() => {
79+
dispatch(setCurrentTabInApp('map'))
80+
}, []);
81+
7782
// setting the margins for the Map to render in the tab window.
7883
const innerWidth = totalWidth - margin.left - margin.right;
7984
const innerHeight = totalHeight - margin.top - margin.bottom - 60;

src/app/components/History.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import React, { useEffect } from 'react';
55
import { diff, formatters } from 'jsondiffpatch';
66
import * as d3 from 'd3';
77

8-
import { changeView, changeSlider } from '../actions/actions';
8+
import { changeView, changeSlider, setCurrentTabInApp } from '../actions/actions';
9+
import { useStoreContext } from '../store';
910

1011
const defaultMargin = {
1112
top: 30, left: 30, right: 55, bottom: 70,
@@ -23,6 +24,8 @@ function History(props: Record<string, unknown>): JSX.Element {
2324
currLocation,
2425
snapshots,
2526
} = props;
27+
const [ store, dispatch] = useStoreContext();
28+
2629

2730
const svgRef = React.useRef(null);
2831
const root = JSON.parse(JSON.stringify(hierarchy));
@@ -35,6 +38,10 @@ function History(props: Record<string, unknown>): JSX.Element {
3538
makeD3Tree();
3639
}, [root, currLocation]);
3740

41+
useEffect(() => {
42+
dispatch(setCurrentTabInApp('history'));
43+
}, []);
44+
3845

3946
function labelCurrentNode(d3root) {
4047
if (d3root.data.index === currLocation.index) {

src/app/components/PerformanceVisx.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
/* eslint-disable guard-for-in */
22
/* eslint-disable no-restricted-syntax */
33
// @ts-nocheck
4-
import React, { useState } from 'react';
4+
import React, { useState, useEffect } from 'react';
55
import {
66
MemoryRouter as Router,
77
Route,
88
NavLink,
99
Switch,
1010
useLocation,
11+
Redirect,
1112
} from 'react-router-dom';
1213
import RenderingFrequency from './RenderingFrequency';
1314
import BarGraph from './BarGraph';
1415
import BarGraphComparison from './BarGraphComparison';
1516
import BarGraphComparisonActions from './BarGraphComparisonActions';
1617
import { useStoreContext } from '../store';
18+
import { setCurrentTabInApp } from '../actions/actions';
1719
/* NOTES
1820
Issue - Not fully compatible with recoil apps. Reference the recoil-todo-test.
1921
Barstacks display inconsistently...however, almost always displays upon initial test app load or
@@ -172,7 +174,7 @@ const getPerfMetrics = (snapshots, snapshotsIds): {} => {
172174
const PerformanceVisx = (props: BarStackProps) => {
173175
// hook used to dispatch onhover action in rect
174176
const { width, height, snapshots, hierarchy, } = props;
175-
const [{ tabs, currentTab }, dispatch] = useStoreContext();
177+
const [{ tabs, currentTab, currentTabInApp }, dispatch] = useStoreContext();
176178
const [detailsView, setDetailsView] = useState('barStack');
177179
const [comparisonView, setComparisonView] = useState('barStack');
178180
const [comparisonData, setComparisonData] = useState();
@@ -181,6 +183,10 @@ const PerformanceVisx = (props: BarStackProps) => {
181183
const [ series, setSeries ] = useState(true);
182184
const [ action, setAction ] = useState(false);
183185

186+
useEffect(() => {
187+
dispatch(setCurrentTabInApp('performance'));
188+
}, []);
189+
184190
const getActions = () => {
185191
let seriesArr = localStorage.getItem('project')
186192
seriesArr = seriesArr === null ? [] : JSON.parse(seriesArr);
@@ -237,6 +243,14 @@ const PerformanceVisx = (props: BarStackProps) => {
237243
return <div className="noState">{NO_STATE_MSG}</div>;
238244
};
239245

246+
const renderForTutorial = () => {
247+
console.log(currentTabInApp)
248+
if (currentTabInApp === 'performance') return <Redirect to="/" />;
249+
if (currentTabInApp === 'performance-comparison') return <Redirect to="/comparison" />;
250+
251+
return null;
252+
}
253+
240254
return (
241255
<Router>
242256
<div className="performance-nav-bar-container">
@@ -251,6 +265,7 @@ const PerformanceVisx = (props: BarStackProps) => {
251265
</NavLink>
252266
<NavLink
253267
className="router-link-performance"
268+
id="router-link-performance-comparison"
254269
// className="router-link"
255270
activeClassName="is-active"
256271
to="/comparison"
@@ -267,6 +282,8 @@ const PerformanceVisx = (props: BarStackProps) => {
267282
</NavLink>
268283
</div>
269284

285+
{renderForTutorial()}
286+
270287
<Switch>
271288
<Route path="/comparison" render={renderComparisonBargraph} />
272289
<Route path="/componentdetails" render={renderComponentDetailsView} />

src/app/components/RenderingFrequency.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
/* eslint-disable jsx-a11y/click-events-have-key-events */
22
/* eslint-disable jsx-a11y/no-static-element-interactions */
33
/* eslint-disable react/prop-types */
4-
import React, { useState } from 'react';
4+
import React, { useState, useEffect } from 'react';
55
import { render } from 'react-dom';
6-
import { onHover, onHoverExit } from '../actions/actions';
6+
import { onHover, onHoverExit, setCurrentTabInApp } from '../actions/actions';
77
import { useStoreContext } from '../store';
88

99
const RenderingFrequency = props => {
1010
const perfData = props.data;
11+
const [ store, dispatch] = useStoreContext();
12+
useEffect(() => {
13+
dispatch(setCurrentTabInApp('performance-comparison'));
14+
}, []);
1115
return (
1216
<div>
1317
{Object.keys(perfData).map(componentName => {

0 commit comments

Comments
 (0)