Skip to content

Commit 546b6b9

Browse files
committed
Merge branch 'dev' into morahBranch
2 parents f1148c5 + 21a6992 commit 546b6b9

26 files changed

+411
-447
lines changed

src/app/components/Action.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ import { ActionProps, OptionsCursorTrueWithMargin } from '../FrontendTypes';
2929
const Action = (props: ActionProps): JSX.Element => {
3030
// We destructure the 'props' that were passed into this component
3131
const {
32-
selected, // boolean on whether the current index is the same as the viewIndex from 'ActionContainer'
33-
last, // boolean on (whether the view index is less than 0) AND if (the index is the same as the last snapshot's index value in hierarchyArr) from 'ActionContainer'
32+
selected, // boolean on whether the current index is the same as the viewIndex in 'ActionContainer'
33+
last, // boolean on (whether the view index is less than 0) AND if (the index is the same as the last snapshot's index value in hierarchyArr) in 'ActionContainer'
3434
index, // from snapshot.index in "ActionContainer's" 'hierarchyArr'
35-
sliderIndex, // from tabs[currentTab] object from 'ActionContainer'
35+
sliderIndex, // from tabs[currentTab] object in 'ActionContainer'
3636
dispatch,
3737
displayName, // from snapshot.displayName in "ActionContainer's" 'hierarchyArr'
3838
componentData, // from snapshot.componentData in "ActionContainer's" 'hierarchyArr'
39-
viewIndex, // from tabs[currentTab] object from 'ActionContainer'
39+
viewIndex, // from tabs[currentTab] object in 'ActionContainer'
4040
isCurrIndex,
4141
handleOnkeyDown, // function that allows arrows keys to jump between snapshots defined in 'ActionContainer.tsx'
4242
} = props;

src/app/components/App.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ const initialState: InitialStateProps = { // we initialize what our initialState
2424
function App(): JSX.Element {
2525
return (
2626
<ThemeProvider theme={theme}>
27-
<Router> {/* we wrap our application with the <Router> tag so that all components that are nested will have the react-router context */}
28-
<StoreContext.Provider value={useReducer(mainReducer, initialState)}> {/* we wrap our MainContainer with the provider so that we will be able to use the store context. We create our store by using useReducer and passing it into the value property */}
29-
<MainContainer />
30-
</StoreContext.Provider>
31-
</Router>
27+
<Router>
28+
{/* we wrap our application with the <Router> tag so that all components that are nested will have the react-router context */}
29+
<StoreContext.Provider value={useReducer(mainReducer, initialState)}>
30+
{/* we wrap our MainContainer with the provider so that we will be able to use the store context. We create our store by using useReducer and passing it into the value property */}
31+
<MainContainer />
32+
</StoreContext.Provider>
33+
</Router>
3234
</ThemeProvider>
3335
);
3436
}

src/app/components/Loader.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ This file is what decides what icon (loading, checkmark, exclamation point) is d
1515

1616
const handleResult = (result: boolean): JSX.Element =>
1717
result ? (
18-
<CheckCircleOutlineIcon className='check'/>
19-
// if result boolean is true, we display a checkmark icon
18+
<CheckCircleOutlineIcon className='check'/> // if result boolean is true, we display a checkmark icon
2019
) : (
21-
<ErrorOutlineIcon className='fail'/>
22-
// if the result boolean is false, we display a fail icon
20+
<ErrorOutlineIcon className='fail'/> // if the result boolean is false, we display a fail icon
2321
);
2422

2523
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default function ComponentMap({
3939
const [layout, setLayout] = useState('cartesian'); // We create a local state "layout" and set it to a string 'cartesian'
4040
const [orientation, setOrientation] = useState('vertical'); // We create a local state "orientation" and set it to a string 'vertical'.
4141
const [linkType, setLinkType] = useState('diagonal'); // We create a local state "linkType" and set it to a string 'diagonal'.
42-
const [stepPercent, setStepPercent] = useState(10); // We create a local state "stepPercent" and set it to a number '10'.
42+
const [stepPercent, setStepPercent] = useState(0.5); // We create a local state "stepPercent" and set it to a number '0.5'. This will be used to scale the Map component's link: Step to 50%
4343
const [selectedNode, setSelectedNode] = useState('root'); // We create a local state "selectedNode" and set it to a string 'root'.
4444
const [, dispatch] = useStoreContext(); // we destructure the returned context object from the invocation of the useStoreContext function to get access to our dispatch function
4545

@@ -93,9 +93,12 @@ export default function ComponentMap({
9393
hideTooltip // function to close a tooltip
9494
} = useTooltip(); // returns an object with several properties that you can use to manage the tooltip state of your component
9595

96-
const { containerRef, TooltipInPortal } = useTooltipInPortal({
97-
detectBounds: true,
98-
scroll: true,
96+
const {
97+
containerRef, // Access to the container's bounding box. This will be empty on first render.
98+
TooltipInPortal // TooltipWithBounds in a Portal, outside of your component DOM tree
99+
} = useTooltipInPortal({ // Visx hook
100+
detectBounds: true, // use TooltipWithBounds
101+
scroll: true, // when tooltip containers are scrolled, this will correctly update the Tooltip position
99102
});
100103

101104
const tooltipStyles: ToolTipStyles = {

src/app/components/StateRoute/ComponentMap/LinkControls.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const collectNodes = (node: Node): void => {
3838
export default function LinkControls({
3939
layout, // from the layout local state (initially 'cartesian') in 'ComponentMap'
4040
linkType, // from linkType local state (initially 'vertical') in 'ComponentMap'
41-
stepPercent, // from stepPercent local state (initially '10') in 'ComponentMap'
41+
stepPercent, // from stepPercent local state (initially '0.5') in 'ComponentMap'
4242
setLayout, // from the layout local state in 'ComponentMap'
4343
setOrientation, // from the orientation local state in 'ComponentMap'
4444
setLinkType, // from the linkType local state in 'ComponentMap'
@@ -63,7 +63,8 @@ export default function LinkControls({
6363
</select>
6464
&nbsp;&nbsp;
6565

66-
<label>Orientation:</label> {/* Controls for the Orientation selection, this dropdown will be disabled when the polar layout is selected as it is not needed */}
66+
<label>Orientation:</label> {/* Toggle record button to pause state changes on target application */}
67+
{/* Controls for the Orientation selection, this dropdown will be disabled when the polar layout is selected as it is not needed */}
6768
&nbsp;
6869
<select
6970
onClick={(e) => e.stopPropagation()}

src/app/components/StateRoute/History.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const defaultMargin: DefaultMargin = {
2424
// below we destructure the props
2525
function History(props: Record<string, unknown>): JSX.Element {
2626
const {
27-
width: totalWidth,
28-
height: totalHeight,
27+
width: totalWidth, // from ParentSize provided in StateRoute
28+
height: totalHeight, // from ParentSize provided in StateRoute
2929
margin = defaultMargin,
3030
hierarchy, // from 'tabs[currentTab]' object in 'MainContainer'
3131
dispatch, // from useStoreContext in 'StateRoute'

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

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -34,49 +34,53 @@ const tooltipStyles = {
3434
const BarGraph = (props: BarGraphProps): JSX.Element => {
3535
const [{ tabs, currentTab }, dispatch] = useStoreContext();
3636
const {
37-
width,
38-
height,
39-
data,
40-
comparison,
41-
setRoute,
42-
allRoutes,
43-
filteredSnapshots,
44-
snapshot,
45-
setSnapshot,
37+
width, // from stateRoute container
38+
height, // from stateRoute container
39+
data, // Acquired from getPerfMetrics(snapshots, getSnapshotIds(hierarchy)) in 'PerformanceVisx'
40+
comparison, // result from invoking 'allStorage' in 'PerformanceVisx'
41+
setRoute, // updates the 'route' state in 'PerformanceVisx'
42+
allRoutes, // array containing urls from 'PerformanceVisx'
43+
filteredSnapshots, // array containing url's that exist and with route === url.pathname
44+
snapshot, // state that is initialized to 'All Snapshots' in 'PerformanceVisx'
45+
setSnapshot, // updates the 'snapshot' state in 'PerformanceVisx'
4646
} = props;
4747
const [seriesNameInput, setSeriesNameInput] = useState(`Series ${comparison.length + 1}`);
48-
const { tooltipOpen, tooltipLeft, tooltipTop, tooltipData, hideTooltip, showTooltip } =
49-
useTooltip<TooltipData>();
48+
const {
49+
tooltipOpen, // boolean whether the tooltip state is open or closed
50+
tooltipLeft, // number used for tooltip positioning
51+
tooltipTop, // number used for tooltip positioning
52+
tooltipData, // value/data that tooltip may need to render
53+
hideTooltip, // function to close a tooltip
54+
showTooltip // function to set tooltip state
55+
} = useTooltip<TooltipData>(); // returns an object with several properties that you can use to manage the tooltip state of your component
5056
let tooltipTimeout: number;
51-
const { containerRef, TooltipInPortal } = useTooltipInPortal({
52-
detectBounds: true,
53-
scroll: true,
57+
const {
58+
containerRef, // Access to the container's bounding box. This will be empty on first render.
59+
TooltipInPortal // TooltipWithBounds in a Portal, outside of your component DOM tree
60+
} = useTooltipInPortal({ // Visx hook
61+
detectBounds: true, // use TooltipWithBounds
62+
scroll: true, // when tooltip containers are scrolled, this will correctly update the Tooltip position
5463
});
5564

5665
const keys = Object.keys(data.componentData);
66+
const getSnapshotId = (d: snapshot) => d.snapshotId; // data accessor (used to generate scales) and formatter (add units for on hover box). d comes from data.barstack post filtered data
5767

58-
// data accessor (used to generate scales) and formatter (add units for on hover box)
59-
// d coming from data.barstack post filtered data
60-
const getSnapshotId = (d: snapshot) => d.snapshotId;
61-
62-
// returns snapshot id when invoked in tooltip section
63-
const formatSnapshotId = (id) => `Snapshot ID: ${id}`;
64-
// returns render time when invoked in tooltip section
65-
const formatRenderTime = (time) => `${time} ms `;
68+
const getSnapshotId = (d: snapshot) => d.snapshotId; // data accessor (used to generate scales) and formatter (add units for on hover box). d comes from data.barstack post filtered data
69+
const formatSnapshotId = (id) => `Snapshot ID: ${id}`; // returns snapshot id when invoked in tooltip section
70+
const formatRenderTime = (time) => `${time} ms `; // returns render time when invoked in tooltip section
6671

67-
// create visualization SCALES with cleaned data
68-
const snapshotIdScale = scaleBand<string>({
72+
73+
const snapshotIdScale = scaleBand<string>({ // create visualization SCALES with cleaned data
6974
domain: data.barStack.map(getSnapshotId),
7075
padding: 0.2,
7176
});
7277

73-
// Adjusts y axis to match/ bar height
74-
const renderingScale = scaleLinear<number>({
78+
const renderingScale = scaleLinear<number>({ // Adjusts y axis to match/ bar height
7579
domain: [0, data.maxTotalRender],
7680
nice: true,
7781
});
78-
// Gives each bar on the graph a color using schemeSet1 imported from D3
79-
const colorScale = scaleOrdinal<string>({
82+
83+
const colorScale = scaleOrdinal<string>({ // Gives each bar on the graph a color using schemeSet1 imported from D3
8084
domain: keys,
8185
range: schemeSet1,
8286
});
@@ -92,9 +96,9 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
9296
title: tabs[currentTab].title,
9397
data,
9498
};
95-
// use this to animate the save series button. It
96-
useEffect(() => {
97-
const saveButtons = document.getElementsByClassName('save-series-button');
99+
100+
useEffect(() => { // Animates the save series button.
101+
const saveButtons = document.getElementsByClassName('save-series-button'); // finds the buttom in the DOM
98102
for (let i = 0; i < saveButtons.length; i++) {
99103
if (tabs[currentTab].seriesSavedStatus === 'saved') {
100104
saveButtons[i].classList.add('animate');
@@ -106,22 +110,21 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
106110
}
107111
});
108112

109-
// CURRENTLY DOES NOT SAVE
110-
const saveSeriesClickHandler = () => {
113+
const saveSeriesClickHandler = () => { // function to save the currently selected series
111114
if (tabs[currentTab].seriesSavedStatus === 'inputBoxOpen') {
112115
const actionNames = document.getElementsByClassName('actionname');
113116
for (let i = 0; i < actionNames.length; i += 1) {
114117
toStorage.data.barStack[i].name = actionNames[i].value;
115118
}
116-
dispatch(save(toStorage, seriesNameInput));
117-
setSeriesNameInput(`Series ${comparison.length}`);
119+
dispatch(save(toStorage, seriesNameInput)); // saves the series under seriesName
120+
setSeriesNameInput(`Series ${comparison.length}`); // sends a reducer that saves the series/toStorage object the user wants to chrome local storage
118121
return;
119122
}
120-
dispatch(save(toStorage));
123+
dispatch(save(toStorage)); // sends a reducer that saves the series/toStorage object the user wants to chrome local storage
121124
};
122125

123-
// Need to change so textbox isn't empty before saving
124-
const textbox =
126+
127+
const textbox = // Need to change so textbox isn't empty before saving
125128
tabs[currentTab].seriesSavedStatus === 'inputBoxOpen' ? (
126129
<input
127130
type='text'
@@ -194,8 +197,7 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
194197
{(barStacks) =>
195198
barStacks.map((barStack) =>
196199
barStack.bars.map((bar) => {
197-
// Hides new components if components don't exist in previous snapshots.
198-
if (Number.isNaN(bar.bar[1]) || bar.height < 0) {
200+
if (Number.isNaN(bar.bar[1]) || bar.height < 0) { // Hides new components if components don't exist in previous snapshots.
199201
bar.height = 0;
200202
}
201203
return (
@@ -206,18 +208,17 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
206208
height={bar.height === 0 ? null : bar.height}
207209
width={bar.width}
208210
fill={bar.color}
211+
209212
/* TIP TOOL EVENT HANDLERS */
210-
// Hides tool tip once cursor moves off the current rect.
211-
onMouseLeave={() => {
213+
onMouseLeave={() => { // Hides tool tip once cursor moves off the current rect.
212214
dispatch(
213215
onHoverExit(data.componentData[bar.key].rtid),
214216
(tooltipTimeout = window.setTimeout(() => {
215217
hideTooltip();
216218
}, 300)),
217219
);
218220
}}
219-
// Cursor position in window updates position of the tool tip.
220-
onMouseMove={(event) => {
221+
onMouseMove={(event) => { // Cursor position in window updates position of the tool tip.
221222
dispatch(onHover(data.componentData[bar.key].rtid));
222223
if (tooltipTimeout) clearTimeout(tooltipTimeout);
223224
const top;
@@ -282,11 +283,9 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
282283
</Text>
283284
)}
284285
</svg>
286+
285287
{/* FOR HOVER OVER DISPLAY */}
286-
{/* Ths conditional statement displays a different tooltip
287-
configuration depending on if we are trying do display a specific
288-
snapshot through options menu or all snapshots together in bargraph */}
289-
{tooltipOpen && tooltipData && (
288+
{tooltipOpen && tooltipData && ( // Ths conditional statement displays a different tooltip configuration depending on if we are trying do display a specific snapshot through options menu or all snapshots together in bargraph
290289
<TooltipInPortal
291290
key={Math.random()} // update tooltip bounds each render
292291
top={tooltipTop}
@@ -297,8 +296,8 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
297296
{' '}
298297
<strong>{tooltipData.key}</strong>{' '}
299298
</div>
300-
<div>{data.componentData[tooltipData.key].stateType}</div>
301-
<div> {formatRenderTime(tooltipData.bar.data[tooltipData.key])} </div>
299+
<div>{'State: ' + data.componentData[tooltipData.key].stateType}</div>
300+
<div> {'Render time: ' + formatRenderTime(tooltipData.bar.data[tooltipData.key])} </div>
302301
<div>
303302
{' '}
304303
<small>{formatSnapshotId(getSnapshotId(tooltipData.bar.data))}</small>

0 commit comments

Comments
 (0)