Skip to content

Commit d63dab8

Browse files
committed
Tutorial completed for Performance Tab. Placeholder tutorials on history, web metrics, and tree tabs
1 parent ac2dc01 commit d63dab8

15 files changed

+483
-262
lines changed

src/app/actions/actions.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,14 @@ export const onHoverExit = (rtid) => ({
118118
export const setCurrentLocation = (tabsObj) => ({
119119
type: types.SET_CURRENT_LOCATION,
120120
payload: tabsObj,
121-
})
121+
});
122122

123123
export const setCurrentTabInApp = (currentTabInApp) => ({
124124
type: types.SET_CURRENT_TAB_IN_APP,
125125
payload: currentTabInApp,
126-
})
126+
});
127+
128+
export const tutorialSaveSeriesToggle = (toggleVal) => ({
129+
type: types.TUTORIAL_SAVE_SERIES_TOGGLE,
130+
payload: toggleVal,
131+
});

src/app/components/BarGraph.tsx

Lines changed: 2 additions & 2 deletions
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,
@@ -137,7 +137,7 @@ const BarGraph = props => {
137137
dispatch(save(toStorage))
138138
}
139139

140-
const textbox = tabs[currentTab].seriesSavedStatus === 'inputBoxOpen' ? <input type="text" id="seriesname" value={seriesNameInput} onChange={e => setSeriesNameInput(e.target.value)} /> : null;
140+
const textbox = tabs[currentTab].seriesSavedStatus === 'inputBoxOpen' ? <input type="text" className="seriesNameInput" value={seriesNameInput} onChange={e => setSeriesNameInput(e.target.value)} /> : null;
141141
return (
142142
<div className="bargraph-position">
143143
{/* <input type="text" id ="seriesname" placeholder="Series Name" /> */}

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/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: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
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';
17-
import { useEffect } from 'react';
1818
import { setCurrentTabInApp } from '../actions/actions';
1919
/* NOTES
2020
Issue - Not fully compatible with recoil apps. Reference the recoil-todo-test.
@@ -174,7 +174,7 @@ const getPerfMetrics = (snapshots, snapshotsIds): {} => {
174174
const PerformanceVisx = (props: BarStackProps) => {
175175
// hook used to dispatch onhover action in rect
176176
const { width, height, snapshots, hierarchy, } = props;
177-
const [{ tabs, currentTab }, dispatch] = useStoreContext();
177+
const [{ tabs, currentTab, currentTabInApp }, dispatch] = useStoreContext();
178178
const [detailsView, setDetailsView] = useState('barStack');
179179
const [comparisonView, setComparisonView] = useState('barStack');
180180
const [comparisonData, setComparisonData] = useState();
@@ -243,6 +243,14 @@ const PerformanceVisx = (props: BarStackProps) => {
243243
return <div className="noState">{NO_STATE_MSG}</div>;
244244
};
245245

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+
246254
return (
247255
<Router>
248256
<div className="performance-nav-bar-container">
@@ -257,6 +265,7 @@ const PerformanceVisx = (props: BarStackProps) => {
257265
</NavLink>
258266
<NavLink
259267
className="router-link-performance"
268+
id="router-link-performance-comparison"
260269
// className="router-link"
261270
activeClassName="is-active"
262271
to="/comparison"
@@ -273,6 +282,8 @@ const PerformanceVisx = (props: BarStackProps) => {
273282
</NavLink>
274283
</div>
275284

285+
{renderForTutorial()}
286+
276287
<Switch>
277288
<Route path="/comparison" render={renderComparisonBargraph} />
278289
<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 => {

src/app/components/Tree.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11

2-
import React from 'react';
2+
import React, { useEffect } from 'react';
33
import JSONTree from 'react-json-tree';
44

5+
import { setCurrentTabInApp } from '../actions/actions';
6+
import { useStoreContext } from '../store';
7+
58
const colors = {
69
scheme: 'paraiso',
710
author: 'jan t. sott',
@@ -47,6 +50,11 @@ interface TreeProps {
4750

4851
const Tree = (props: TreeProps) => {
4952
const { snapshot } = props;
53+
const [ store, dispatch] = useStoreContext();
54+
55+
useEffect(() => {
56+
dispatch(setCurrentTabInApp('history'));
57+
}, []);
5058

5159
return (
5260
<>

0 commit comments

Comments
 (0)