Skip to content

Commit 3fc6418

Browse files
authored
Merge pull request #248 from oslabs-beta/master
Merge New Features Into Master Branch
2 parents a7f76a0 + bcafeef commit 3fc6418

39 files changed

+1259
-795
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"Abaas Khorrami",
4141
"Ali Rahman",
4242
"Andy Wong",
43+
"Andy Tsou",
4344
"Bryan Lee",
4445
"Becca Viner",
4546
"Caitlin Chan",
@@ -51,6 +52,7 @@
5152
"Dennis Lopez",
5253
"Edwin Menendez",
5354
"Ergi Shehu",
55+
"Freya Wu",
5456
"Gabriela Jardim Aquino",
5557
"Gregory Panciera",
5658
"Haejin Jo",
@@ -61,6 +63,7 @@
6163
"Kevin Fey",
6264
"Kevin Ngo",
6365
"Kim Mai Nguyen",
66+
"Lina Shin",
6467
"Nathanael Wa Mwenze",
6568
"Prasanna Malla",
6669
"Rajeeb Banstola",
@@ -70,6 +73,7 @@
7073
"Ryan Dang",
7174
"Sierra Swaby",
7275
"Tania Lind",
76+
"Viet Nguyen",
7377
"Yujin Kang"
7478
],
7579
"license": "ISC",

src/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ The general flow of data is described in the following steps:
7070
![GENERAL DATA FLOW](../assets/dataflow.jpg)
7171

7272
1. When the background bundle is loaded by the browser, it executes a script injection into the dom. (see section on *backend*). This script uses a technique called [throttle](https://medium.com/@bitupon.211/debounce-and-throttle-160affa5457b) to send state data from the app to the content script every specified milliseconds (in our case, this interval is 70ms).
73+
<!-- CHECK LINE 496 IN LINKFIBER.TS -->
74+
7375

7476
2. The content script always listens for messages being passed from the extension's target application. Upon receiving data from the target app, the content script will immediately forward this data to the background script which then updates an object called `tabsObj`. Each time `tabsObj` is updated, its latest version will be passed to Reactime, where it is processed for displaying to the user by the *app* folder scripts.
7577

src/app/__tests__/ActionContainer.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ const state = {
6868
}],
6969
}],
7070
},
71+
currLocation: {
72+
index: 0,
73+
name: 1,
74+
branch: 0,
75+
},
7176
sliderIndex: 0,
7277
viewIndex: -1,
7378
},
@@ -86,7 +91,7 @@ let wrapper;
8691
//conditional rendering in ActionContainer that shows/hides time-travel functionality
8792

8893
beforeEach(() => {
89-
wrapper = shallow(<ActionContainer actionView={true}/>);
94+
wrapper = shallow(<ActionContainer actionView={true} />);
9095
useStoreContext.mockClear();
9196
dispatch.mockClear();
9297
});

src/app/actions/actions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const save = (tabsObj) => ({
55
type: types.SAVE,
66
payload: tabsObj,
77
});
8-
export const deleteSeries = () =>({
8+
export const deleteSeries = () => ({
99
type: types.DELETE_SERIES,
1010
})
1111
export const toggleMode = (mode) => ({
@@ -95,3 +95,8 @@ export const onHoverExit = (rtid) => ({
9595
type: types.ON_HOVER_EXIT,
9696
payload: rtid,
9797
});
98+
99+
export const setCurrentLocation = (tabsObj) => ({
100+
type: types.SET_CURRENT_LOCATION,
101+
payload: tabsObj,
102+
})

src/app/components/Action.tsx

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface ActionProps {
2222
componentData: { actualDuration: number } | undefined;
2323
state?: Record<string, unknown>;
2424
viewIndex: number;
25+
isCurrIndex: boolean;
2526
handleOnkeyDown: (e: any, i: number) => any;
2627
logChangedState: (index: number) => any;
2728
}
@@ -53,6 +54,7 @@ const Action = (props: ActionProps): JSX.Element => {
5354
componentName,
5455
componentData,
5556
viewIndex,
57+
isCurrIndex,
5658
handleOnkeyDown,
5759
logChangedState,
5860
} = props;
@@ -98,43 +100,55 @@ const Action = (props: ActionProps): JSX.Element => {
98100
return (
99101
<div
100102
// Invoking keyboard functionality; functionality is in ActionContainer;
101-
onKeyDown={(e) => handleOnkeyDown(e, viewIndex)}
103+
onKeyDown={e => handleOnkeyDown(e, viewIndex)}
102104
className={
103105
selected || last ? 'action-component selected' : 'action-component'
104106
}
105107
onClick={() => {
106108
dispatch(changeView(index));
107109
}}
108-
role='presentation'
110+
role="presentation"
109111
style={index > sliderIndex ? { color: '#5f6369' } : {}}
110112
tabIndex={index}
111113
>
112114
<ReactHover options={optionsCursorTrueWithMargin}>
113-
<Trigger type='trigger'>
114-
<div className='action-component-trigger' style={index > sliderIndex ? { color: '#5f6369' } : {}}>
115-
<div className='action-component-text'>
115+
<Trigger type="trigger">
116+
<div className="action-component-trigger" style={index > sliderIndex ? { color: '#5f6369' } : {}}>
117+
<div className="action-component-text">
116118
{`${displayName}: ${componentName !== 'nameless' ? componentName : ''} `}
117119
{/* {`displayName: ${displayName}`} */}
118120
</div>
119-
<button className='time-button' type='button'>
121+
<button className="time-button" type="button">
120122
{displayTime}
121123
</button>
122-
<button
123-
className='jump-button'
124-
onClick={(e: any): void => {
125-
e.stopPropagation();
126-
dispatch(changeSlider(index));
127-
dispatch(changeView(index));
128-
}}
129-
tabIndex={index}
130-
type='button'
131-
>
132-
Jump
133-
</button>
124+
{
125+
isCurrIndex ? (
126+
<button
127+
className="current-location"
128+
type="button"
129+
>
130+
Current
131+
</button>
132+
)
133+
: (
134+
<button
135+
className="jump-button"
136+
onClick={(e: any): void => {
137+
e.stopPropagation();
138+
dispatch(changeSlider(index));
139+
dispatch(changeView(index));
140+
}}
141+
tabIndex={index}
142+
type="button"
143+
>
144+
Jump
145+
</button>
146+
)
147+
}
134148
</div>
135149
</Trigger>
136-
<Hover type='hover'>
137-
<div style={{ padding: '0.5rem 1rem' }} id='hover-box'>
150+
<Hover type="hover">
151+
<div style={{ padding: '0.5rem 1rem' }} id="hover-box">
138152
<p>{logChangedState(index)}</p>
139153
</div>
140154
</Hover>

src/app/components/BarGraph.tsx

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import { scaleBand, scaleLinear, scaleOrdinal } from '@visx/scale';
99
import { useTooltip, useTooltipInPortal, defaultStyles } from '@visx/tooltip';
1010
import { Text } from '@visx/text';
1111
import { schemeSet3 } from 'd3-scale-chromatic';
12-
import { onHover, onHoverExit } from '../actions/actions';
12+
import { onHover, onHoverExit, save } from '../actions/actions';
1313
import { useStoreContext } from '../store';
14-
import { save } from '../actions/actions';
1514

1615
/* TYPESCRIPT */
1716
interface data {
@@ -45,7 +44,9 @@ interface TooltipData {
4544
}
4645

4746
/* DEFAULTS */
48-
const margin = { top: 30, right: 30, bottom: 0, left: 50 };
47+
const margin = {
48+
top: 30, right: 30, bottom: 0, left: 50,
49+
};
4950
const axisColor = '#62d6fb';
5051
const background = '#242529';
5152
const tooltipStyles = {
@@ -58,7 +59,7 @@ const tooltipStyles = {
5859
fontFamily: 'Roboto',
5960
};
6061

61-
const BarGraph = (props) => {
62+
const BarGraph = props => {
6263
const [{ tabs, currentTab }, dispatch] = useStoreContext();
6364
const { width, height, data } = props;
6465
const {
@@ -78,8 +79,8 @@ const BarGraph = (props) => {
7879

7980
// data accessor (used to generate scales) and formatter (add units for on hover box)
8081
const getSnapshotId = (d: snapshot) => d.snapshotId;
81-
const formatSnapshotId = (id) => `Snapshot ID: ${id}`;
82-
const formatRenderTime = (time) => `${time} ms `;
82+
const formatSnapshotId = id => `Snapshot ID: ${id}`;
83+
const formatRenderTime = time => `${time} ms `;
8384

8485
// create visualization SCALES with cleaned data
8586
const snapshotIdScale = scaleBand<string>({
@@ -105,7 +106,7 @@ const BarGraph = (props) => {
105106

106107
const toStorage = {
107108
currentTab,
108-
title: tabs[currentTab]['title'],
109+
title: tabs[currentTab].title,
109110
data,
110111
};
111112

@@ -119,14 +120,14 @@ const BarGraph = (props) => {
119120
} else {
120121
saveButtons[i].innerHTML = 'Save Series';
121122
saveButtons[i].classList.remove('animate');
122-
};
123-
};
123+
}
124+
}
124125
});
125126
return (
126-
<div className='bargraph-position'>
127+
<div className="bargraph-position">
127128
<button
128-
className='save-series-button'
129-
onClick={(e) => {
129+
className="save-series-button"
130+
onClick={e => {
130131
dispatch(save(toStorage));
131132
}}
132133
>
@@ -149,7 +150,7 @@ const BarGraph = (props) => {
149150
yScale={renderingScale}
150151
width={xMax}
151152
height={yMax}
152-
stroke='black'
153+
stroke="black"
153154
strokeOpacity={0.1}
154155
xOffset={snapshotIdScale.bandwidth() / 2}
155156
/>
@@ -162,48 +163,44 @@ const BarGraph = (props) => {
162163
yScale={renderingScale}
163164
color={colorScale}
164165
>
165-
{(barStacks) =>
166-
barStacks.map((barStack) =>
167-
barStack.bars.map((bar, idx) => {
168-
// Hides new components if components don't exist in previous snapshots.
169-
if (Number.isNaN(bar.bar[1]) || bar.height < 0) {
170-
bar.height = 0;
171-
}
172-
return (
173-
<rect
174-
key={`bar-stack-${barStack.id}-${bar.id}`}
175-
x={bar.x}
176-
y={bar.y}
177-
height={bar.height === 0 ? null : bar.height}
178-
width={bar.width}
179-
fill={bar.color}
166+
{barStacks => barStacks.map(barStack => barStack.bars.map((bar, idx) => {
167+
// Hides new components if components don't exist in previous snapshots.
168+
if (Number.isNaN(bar.bar[1]) || bar.height < 0) {
169+
bar.height = 0;
170+
}
171+
return (
172+
<rect
173+
key={`bar-stack-${barStack.id}-${bar.id}`}
174+
x={bar.x}
175+
y={bar.y}
176+
height={bar.height === 0 ? null : bar.height}
177+
width={bar.width}
178+
fill={bar.color}
180179
/* TIP TOOL EVENT HANDLERS */
181180
// Hides tool tip once cursor moves off the current rect.
182-
onMouseLeave={() => {
183-
dispatch(
184-
onHoverExit(data.componentData[bar.key].rtid),
185-
(tooltipTimeout = window.setTimeout(() => {
186-
hideTooltip();
187-
}, 300))
188-
);
189-
}}
181+
onMouseLeave={() => {
182+
dispatch(
183+
onHoverExit(data.componentData[bar.key].rtid),
184+
(tooltipTimeout = window.setTimeout(() => {
185+
hideTooltip();
186+
}, 300)),
187+
);
188+
}}
190189
// Cursor position in window updates position of the tool tip.
191-
onMouseMove={(event) => {
192-
dispatch(onHover(data.componentData[bar.key].rtid));
193-
if (tooltipTimeout) clearTimeout(tooltipTimeout);
194-
const top = event.clientY - margin.top - bar.height;
195-
const left = bar.x + bar.width / 2;
196-
showTooltip({
197-
tooltipData: bar,
198-
tooltipTop: top,
199-
tooltipLeft: left,
200-
});
201-
}}
202-
/>
203-
);
204-
})
205-
)
206-
}
190+
onMouseMove={event => {
191+
dispatch(onHover(data.componentData[bar.key].rtid));
192+
if (tooltipTimeout) clearTimeout(tooltipTimeout);
193+
const top = event.clientY - margin.top - bar.height;
194+
const left = bar.x + bar.width / 2;
195+
showTooltip({
196+
tooltipData: bar,
197+
tooltipTop: top,
198+
tooltipLeft: left,
199+
});
200+
}}
201+
/>
202+
);
203+
}))}
207204
</BarStack>
208205
</Group>
209206
<AxisLeft
@@ -235,15 +232,15 @@ const BarGraph = (props) => {
235232
/>
236233
<Text
237234
x={-xMax / 2}
238-
y='15'
239-
transform='rotate(-90)'
235+
y="15"
236+
transform="rotate(-90)"
240237
fontSize={12}
241-
fill='#FFFFFF'
238+
fill="#FFFFFF"
242239
>
243240
Rendering Time (ms)
244241
</Text>
245242
<br />
246-
<Text x={xMax / 2 + 15} y={yMax + 70} fontSize={12} fill='#FFFFFF'>
243+
<Text x={xMax / 2 + 15} y={yMax + 70} fontSize={12} fill="#FFFFFF">
247244
Snapshot ID
248245
</Text>
249246
</svg>
@@ -257,10 +254,15 @@ const BarGraph = (props) => {
257254
>
258255
<div style={{ color: colorScale(tooltipData.key) }}>
259256
{' '}
260-
<strong>{tooltipData.key}</strong>{' '}
257+
<strong>{tooltipData.key}</strong>
258+
{' '}
261259
</div>
262260
<div>{data.componentData[tooltipData.key].stateType}</div>
263-
<div> {formatRenderTime(tooltipData.bar.data[tooltipData.key])} </div>
261+
<div>
262+
{' '}
263+
{formatRenderTime(tooltipData.bar.data[tooltipData.key])}
264+
{' '}
265+
</div>
264266
<div>
265267
{' '}
266268
<small>

src/app/components/BarGraphComparisonTEST.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ const BarGraphComparison = props => {
332332
// height/width/etc. are calculated by visx.
333333
// to set X and Y scale, it will used the passed in function and
334334
// will run it on the array thats outputted by data
335-
// console.log("barStack.bars:",barStack.bars)
336-
const bar = barStack.bars[currentIndex];
335+
const bar = barStack.bars[currentIndex]
337336
if (Number.isNaN(bar.bar[1]) || bar.height < 0) {
338337
bar.height = 0;
339338
}

0 commit comments

Comments
 (0)