Skip to content

Commit 8ea77a1

Browse files
committed
Tutorial conditionally renders based on active tab within RT. Now working on creating the performance tutorial
1 parent 62c36dc commit 8ea77a1

File tree

9 files changed

+56
-9
lines changed

9 files changed

+56
-9
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,8 @@ export const setCurrentLocation = (tabsObj) => ({
119119
type: types.SET_CURRENT_LOCATION,
120120
payload: tabsObj,
121121
})
122+
123+
export const setCurrentTabInApp = (currentTabInApp) => ({
124+
type: types.SET_CURRENT_TAB_IN_APP,
125+
payload: currentTabInApp,
126+
})

src/app/components/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ import mainReducer from '../reducers/mainReducer.js';
66

77
// import 'intro.js/introjs.css';
88

9+
// currentTab is the current active tab within Google Chrome. This is used to decide what tab Reactime should be monitoring. This can be "locked"
10+
// 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.
11+
912
const initialState: {
1013
port: null | number,
1114
currentTab: null | number,
1215
currentTitle: null | string,
1316
split: null | boolean,
14-
tabs: unknown; } = {
17+
tabs: unknown,
18+
currentTabInApp: null | string, } = {
1519
port: null,
1620
currentTab: null,
1721
currentTitle: 'No Target',
1822
split: false,
1923
tabs: {},
24+
currentTabInApp: null,
2025
};
2126

2227
function App(): JSX.Element {

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/PerformanceVisx.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import BarGraph from './BarGraph';
1414
import BarGraphComparison from './BarGraphComparison';
1515
import BarGraphComparisonActions from './BarGraphComparisonActions';
1616
import { useStoreContext } from '../store';
17+
import { useEffect } from 'react';
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
@@ -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);

src/app/components/Tutorial.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { useLocation } from 'react-router-dom';
55
import { Steps, Hints } from 'intro.js-react';
66
import 'intro.js/introjs.css';
77
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8-
import {
9-
faQuestion,
10-
} from '@fortawesome/free-solid-svg-icons';
8+
import { faQuestion } from '@fortawesome/free-solid-svg-icons';
9+
import { useStoreContext } from '../store';
1110

1211
export default function Tutorial(): JSX.Element {
1312
const [stepsEnabled, setStepsEnabled] = useState(false);
1413
const [initialStep, setInitialStep] = useState(0);
14+
const [store, dispatch] = useStoreContext();
15+
const { currentTabInApp } = store;
16+
//why is this state rather than just a variable?
1517
const [steps, setSteps] = useState([
1618
{
1719
title: 'Reactime Tutorial',
@@ -103,12 +105,29 @@ export default function Tutorial(): JSX.Element {
103105
const startIntro = () => {
104106
setStepsEnabled(true);
105107
};
108+
let stepsTest = [{
109+
title: 'Tutorial Complete',
110+
intro: '<ul><li>Please visit our official Github Repo for more information </li><br> <li><a href="https://github.com/open-source-labs/reactime" target="_blank">Reactime Github</a></li></ul>',
111+
position: 'top',
112+
}];
113+
114+
switch (currentTabInApp) {
115+
case 'performance':
116+
stepsTest = [{
117+
title: 'performance',
118+
intro: '<ul><li>Please visit our official Github Repo for more information </li><br> <li><a href="https://github.com/open-source-labs/reactime" target="_blank">Reactime Github</a></li></ul>',
119+
position: 'top',
120+
}];
121+
break;
122+
default:
123+
break;
124+
}
106125

107126
return (
108127
<>
109128
<Steps
110129
enabled={stepsEnabled}
111-
steps={steps}
130+
steps={stepsTest}
112131
initialStep={initialStep}
113132
onExit={onExit}
114133
options={{

src/app/constants/actionTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ export const ON_HOVER_EXIT = 'ON_HOVER_EXIT';
2222
export const SAVE = 'SAVE';
2323
export const DELETE_SERIES = 'DELETE_SERIES';
2424
export const SET_CURRENT_LOCATION = 'SET_CURRENT_LOCATION';
25+
export const SET_CURRENT_TAB_IN_APP = 'SET_CURRENT_TAB_IN_APP';

src/app/containers/MainContainer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { useStoreContext } from '../store';
2222
function MainContainer(): any {
2323
const [store, dispatch] = useStoreContext();
2424
const {
25-
tabs, currentTab, port: currentPort, split,
25+
tabs, currentTab, port: currentPort, split, currentTabInApp
2626
} = store;
2727
const [actionView, setActionView] = useState(true);
2828
// this function handles Time Jump sidebar view
@@ -195,6 +195,7 @@ function MainContainer(): any {
195195

196196
return (
197197
<div className="main-container">
198+
{currentTabInApp}
198199
<div id="bodyContainer" className="body-container">
199200
<ActionContainer
200201
actionView={actionView}

src/app/reducers/mainReducer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as types from '../constants/actionTypes.ts';
44

55
export default (state, action) => produce(state, draft => {
66
const {
7-
port, currentTab, tabs,
7+
port, currentTab, tabs,
88
} = draft;
99
const {
1010
hierarchy, snapshots, mode, intervalId, viewIndex, sliderIndex,
@@ -362,6 +362,10 @@ export default (state, action) => produce(state, draft => {
362362
tabs[currentTab].currLocation = payload[currentTab].currLocation;
363363
break;
364364
}
365+
case types.SET_CURRENT_TAB_IN_APP: {
366+
draft.currentTabInApp = action.payload;
367+
break;
368+
}
365369
default:
366370
throw new Error(`nonexistent action: ${action.type}`);
367371
}

0 commit comments

Comments
 (0)