Skip to content

Commit cb5bb84

Browse files
committed
Implemented toggle button in the Action Conatiner to pause recording of state changes
1 parent 66ac1fa commit cb5bb84

File tree

7 files changed

+41
-54
lines changed

7 files changed

+41
-54
lines changed

src/app/components/ComponentMap.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ export default function ComponentMap({
188188
// }
189189
// };
190190
// inner(state);
191-
192191
// return result;
193192
// --------------------------------------------------------------------------------------------
194193
return ['stateful'];

src/app/components/PerformanceVisx.tsx

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
11
/* eslint-disable guard-for-in */
22
/* eslint-disable no-restricted-syntax */
33
// @ts-nocheck
4-
<<<<<<< HEAD
5-
import React, { useState, useEffect } from 'react';
6-
import FormControlLabel from '@material-ui/core/FormControlLabel';
7-
import { ParentSize } from '@visx/responsive';
8-
=======
94
import React, { useState } from 'react';
10-
>>>>>>> Reactime13.0
115
import {
126
MemoryRouter as Router,
137
Route,
148
NavLink,
159
Switch,
1610
useLocation,
1711
} from 'react-router-dom';
18-
<<<<<<< HEAD
19-
import { Component } from 'react';
20-
import { render } from 'react-dom';
21-
import { Component } from 'react';
22-
=======
23-
>>>>>>> Reactime13.0
2412
import RenderingFrequency from './RenderingFrequency';
2513
import BarGraph from './BarGraph';
2614
import BarGraphComparison from './BarGraphComparison';
2715
import BarGraphComparisonActions from './BarGraphComparisonActions';
2816
import { useStoreContext } from '../store';
29-
<<<<<<< HEAD
30-
// import snapshots from './snapshots';
31-
=======
32-
33-
>>>>>>> Reactime13.0
3417
/* NOTES
3518
Issue - Not fully compatible with recoil apps. Reference the recoil-todo-test.
3619
Barstacks display inconsistently...however, almost always displays upon initial test app load or
@@ -97,11 +80,6 @@ const collectNodes = (snaps, componentName) => {
9780
}
9881
}
9982
}
100-
<<<<<<< HEAD
101-
// console.log('componentsResult looks like: ', componentsResult);
102-
return componentsResult;
103-
};
104-
=======
10583

10684
const finalResults = componentsResult.map((e, index) => {
10785
const name = Object.keys(e)[0];
@@ -111,7 +89,6 @@ const collectNodes = (snaps, componentName) => {
11189
return finalResults;
11290
};
11391

114-
>>>>>>> Reactime13.0
11592
/* DATA HANDLING HELPER FUNCTIONS */
11693
const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
11794
if (!snapshot.children[0]) return;
@@ -159,14 +136,7 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
159136

160137
// Retrieve snapshot series data from Chrome's local storage.
161138
const allStorage = () => {
162-
<<<<<<< HEAD
163-
// const values = [];
164-
// const keys = Object.keys(localStorage);
165-
let values = localStorage.getItem('project');
166-
// values === null ? values = [] : values = JSON.parse(values) ;
167-
=======
168139
let values = localStorage.getItem('project')
169-
>>>>>>> Reactime13.0
170140
values = values === null ? [] : JSON.parse(values);
171141
return values;
172142
};
@@ -201,14 +171,7 @@ const getPerfMetrics = (snapshots, snapshotsIds): {} => {
201171
/* EXPORT COMPONENT */
202172
const PerformanceVisx = (props: BarStackProps) => {
203173
// hook used to dispatch onhover action in rect
204-
<<<<<<< HEAD
205-
206-
const {
207-
width, height, snapshots, hierarchy,
208-
} = props;
209-
=======
210174
const { width, height, snapshots, hierarchy, } = props;
211-
>>>>>>> Reactime13.0
212175
const [{ tabs, currentTab }, dispatch] = useStoreContext();
213176
const [detailsView, setDetailsView] = useState('barStack');
214177
const [comparisonView, setComparisonView] = useState('barStack');

src/app/containers/ActionContainer.tsx

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// @ts-nocheck
2-
import React, { useEffect } from 'react';
2+
import React, { useEffect, useState } from 'react';
33

4+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5+
import {
6+
faToggleOff,
7+
faToggleOn,
8+
} from '@fortawesome/free-solid-svg-icons';
49
import Action from '../components/Action';
510
import SwitchAppDropdown from '../components/SwitchApp';
611
import { emptySnapshots, changeView, changeSlider } from '../actions/actions';
@@ -14,13 +19,15 @@ const resetSlider = () => {
1419
};
1520

1621
function ActionContainer(props): JSX.Element {
17-
const [{ tabs, currentTab }, dispatch] = useStoreContext();
22+
const [{ tabs, currentTab, port }, dispatch] = useStoreContext();
1823
const {
1924
currLocation, hierarchy, sliderIndex, viewIndex, snapshots,
2025
} = tabs[currentTab];
2126
const {
22-
toggleActionContainer, actionView, setActionView
27+
toggleActionContainer, actionView, setActionView,
2328
} = props;
29+
const [recordingActions, setRecordingActions] = useState(true);
30+
2431
let actionsArr = [];
2532
const hierarchyArr: any[] = [];
2633

@@ -128,21 +135,37 @@ function ActionContainer(props): JSX.Element {
128135
const toggleRecord = () => {
129136
port.postMessage({
130137
action: 'toggleRecord',
138+
tabId: currentTab,
131139
});
140+
setRecordingActions(!recordingActions);
132141
// change color of record button or switch svg/img file
133142
};
134143

135144
// the conditional logic below will cause ActionContainer.test.tsx to fail as it cannot find the Empty button
136145
// UNLESS actionView={true} is passed into <ActionContainer /> in the beforeEach() call in ActionContainer.test.tsx
137146
return (
138147
<div id="action-id" className="action-container">
139-
<div id="arrow">
140-
<aside className="aside">
141-
<a onClick={toggleActionContainer} className="toggle">
142-
<i />
143-
</a>
144-
</aside>
145-
{/* <button className="recordBtn" onClick={toggleRecord}>Record</button> */}
148+
<div className="actionToolContainer">
149+
<div id="arrow">
150+
<aside className="aside">
151+
<a onClick={toggleActionContainer} className="toggle">
152+
<i />
153+
</a>
154+
</aside>
155+
156+
</div>
157+
<a
158+
type="button"
159+
className="recordBtn"
160+
onClick={toggleRecord}
161+
>
162+
<i />
163+
{recordingActions ? (
164+
<FontAwesomeIcon className="fa-regular" icon={faToggleOn} />
165+
) : (
166+
<FontAwesomeIcon className="fa-regular" icon={faToggleOff} />
167+
)}
168+
</a>
146169
</div>
147170
{actionView ? (
148171
<div className="action-button-wrapper">

src/app/containers/MainContainer.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ function MainContainer(): any {
3131
const toggleElem = document.querySelector('aside');
3232
toggleElem.classList.toggle('no-aside');
3333
};
34-
34+
// let port;
3535
useEffect(() => {
3636
// only open port once
3737
if (currentPort) return;
3838

3939
// open long-lived connection with background script
4040
const port = chrome.runtime.connect();
41-
4241
// listen for a message containing snapshots from the background script
4342
port.onMessage.addListener(
4443
(message: {
@@ -209,4 +208,4 @@ function MainContainer(): any {
209208
);
210209
}
211210

212-
export default MainContainer;
211+
export default MainContainer;

src/app/styles/layout/_actionContainer.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
.recordBtn{
1313
position: relative;
1414
left: 80%;
15+
height: 100vw;
1516
// visibility: hidden;
16-
}
17+
}

src/extension/background.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ chrome.runtime.onConnect.addListener(port => {
209209
case 'jumpToSnap':
210210
chrome.tabs.sendMessage(tabId, msg);
211211
return true; // attempt to fix message port closing error, consider return Promise
212+
case 'toggleRecord':
213+
chrome.tabs.sendMessage(tabId, msg);
214+
return true; // attempt to fix message port closing error, consider return Promise
212215
default:
213216
return true;
214217
}

src/extension/contentScript.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
let firstMessage = true;
1212
// Listens for window messages (from the injected script on the DOM)
1313
let isRecording = true;
14+
1415
window.addEventListener('message', msg => {
1516
// Event listener runs constantly based on actions
1617
// recorded on the test application from backend files (linkFiber.ts).
@@ -48,8 +49,6 @@ chrome.runtime.onMessage.addListener(request => {
4849
}
4950

5051
if (action === 'jumpToSnap') {
51-
//
52-
//
5352
chrome.runtime.sendMessage(request);
5453
}
5554
// After the jumpToSnap action has been sent back to background js,

0 commit comments

Comments
 (0)