You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/app/components/RouteDescription.tsx
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,16 @@
1
1
importReactfrom'react';
2
2
3
+
/*
4
+
Render's the red route description on app's left sided column between the clear button and the list of state snapshots. The route description is derived from the first state snapshot.
Copy file name to clipboardExpand all lines: src/app/components/SwitchApp.tsx
+14-1Lines changed: 14 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,24 +3,37 @@ import Select from 'react-select';
3
3
import{useStoreContext}from'../store';
4
4
import{setTab}from'../actions/actions';
5
5
6
+
/*
7
+
This is the dropdown menu on the left column above the 'clear' button and the state snapshots list. It allows us to switch between which website/application we are currently working on.
8
+
9
+
Currently, it doesn't seem to be fully implemented since switching applications doesn't change to snapshots that are relevant into the newly selected application
10
+
*/
11
+
6
12
constSwitchAppDropdown=(): JSX.Element=>{
13
+
// we destructure the returned context object from the invocation of the useStoreContext function. Properties not found on the initialState object (dispatch) are from the useReducer function invocation in the App component
This file renders the 'ActionContainer'. The action container is the leftmost column in the application. It includes the button that shrinks and expands the action container, a dropdown to select the active site, a clear button, the current selected Route, and a list of selectable snapshots with timestamps.
15
+
*/
13
16
14
17
// resetSlider locates the rc-slider elements on the document and resets it's style attributes
15
18
constresetSlider=()=>{
@@ -40,18 +43,36 @@ function ActionContainer(props): JSX.Element {
40
43
// we create an array 'hierarchyArr' that will hold objects and numbers
41
44
consthierarchyArr: (number|{})[]=[];
42
45
43
-
// function to traverse state from hierarchy and also getting information on display name and component name
46
+
/*
47
+
48
+
function to traverse state from hierarchy and also getting information on display name and component name
49
+
50
+
the obj parameter is an object with the following structure:
51
+
{
52
+
stateSnapshot: {
53
+
route: any;
54
+
children: any[];
55
+
};
56
+
name: number;
57
+
branch: number;
58
+
index: number;
59
+
children?: [];
60
+
}
61
+
62
+
*/
63
+
44
64
constdisplayArray=(obj: Obj): void=>{
45
65
if(
46
-
// if the stateSnapshot has a non-empty children array
66
+
// if the 'stateSnapshot' has a non-empty 'children' array
47
67
obj.stateSnapshot.children.length>0&&
48
68
// and there is an element
49
69
obj.stateSnapshot.children[0]&&
50
-
// with a state
70
+
// with a 'state'
51
71
obj.stateSnapshot.children[0].state&&
52
-
// and a name
72
+
// and a 'name'
53
73
obj.stateSnapshot.children[0].name
54
74
){
75
+
// we create a new Record object (whose property keys are Keys and whose property values are Type. This utility can be used to map the properties of a type to another type) and populate it's properties with relevant values from our argument 'obj'.
55
76
constnewObj: Record<string,unknown>={
56
77
index: obj.index,
57
78
displayName: `${obj.name}.${obj.branch}`,
@@ -63,20 +84,23 @@ function ActionContainer(props): JSX.Element {
63
84
? ''
64
85
: obj.stateSnapshot.children[0].componentData,
65
86
};
87
+
// we push our record object into 'hiearchyArr' defined on line 41
66
88
hierarchyArr.push(newObj);
67
89
}
90
+
// if argument has a 'children' array, we iterate through it and run 'displayArray' on each element
68
91
if(obj.children){
69
92
obj.children.forEach((element): void=>{
70
93
displayArray(element);
71
94
});
72
95
}
73
96
};
97
+
74
98
// the hierarchy gets set on the first click in the page
75
99
// when page in refreshed we may not have a hierarchy so we need to check if hierarchy was initialized
76
100
// if true invoke displayArray to display the hierarchy
77
101
if(hierarchy)displayArray(hierarchy);
78
102
79
-
// handles keyboard presses, function passes an event and index of each action-component
103
+
// This function allows us to use our arrow keys to jump between snapshots. It passes an event and the index of each action-component. Using the arrow keys allows us to highligh snapshots and the enter key jumps to the selected snapshot
@@ -93,15 +117,16 @@ function ActionContainer(props): JSX.Element {
93
117
}
94
118
// enter key pressed
95
119
elseif(e.key==='Enter'){
96
-
e.stopPropagation();
120
+
e.stopPropagation();// prevents further propagation of the current event in the capturing and bubbling phases
97
121
e.preventDefault();// needed or will trigger onClick right after
98
122
dispatch(changeSlider(currIndex));
99
123
}
100
124
}
101
-
// Sort by index.
102
125
126
+
// Sort hierarchyArr by index property of each object. This will be useful when later when we build our components so that our components will be displayed in index/chronological order
@@ -137,6 +171,7 @@ function ActionContainer(props): JSX.Element {
137
171
);
138
172
useEffect(()=>{
139
173
setActionView(true);
174
+
// !!!! Why is the dependency array the function being called within the useEffect? !!!!
140
175
},[setActionView]);
141
176
142
177
// Function sends message to background.js which sends message to the content script
@@ -155,7 +190,9 @@ function ActionContainer(props): JSX.Element {
155
190
};
156
191
157
192
constroutes: {}={};
193
+
// iterate through our actionsArr
158
194
for(leti=0;i<actionsArr.length;i+=1){
195
+
// if 'routes' doesn't have a property key that is the same as the current component at index[i] routePath we create an array with the first element being the component at index [i]. If it does exist, we push the component at index [i] to the apporpriate routes[routePath]
Copy file name to clipboardExpand all lines: src/app/containers/MainContainer.tsx
+10-8Lines changed: 10 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -17,12 +17,16 @@ import {
17
17
}from'../actions/actions';
18
18
import{useStoreContext}from'../store';
19
19
20
+
/*
21
+
This is the main container where everything in our application is rendered
22
+
*/
23
+
20
24
functionMainContainer(): JSX.Element{
21
25
// we destructure the returned context object from the invocation of the useStoreContext function. Properties not found on the initialState object (store/dispatch) are from the useReducer function invocation in the App component
22
26
const[store,dispatch]=useStoreContext();
23
-
// we continue to destructure store and get the tabs/currentTab/port
27
+
// we continue to destructure 'store' and get the tabs/currentTab/port
24
28
const{ tabs, currentTab, port }=store;
25
-
// We create a local state actionView and set it to true
29
+
// We create a local state 'actionView' and set it to true
26
30
const[actionView,setActionView]=useState(true);
27
31
28
32
// this function handles Time Jump sidebar view
@@ -35,10 +39,8 @@ function MainContainer(): JSX.Element {
35
39
// toggles the addition or the removal of the 'no-aside' class
36
40
toggleElem.classList.toggle('no-aside');
37
41
38
-
// hides the record toggle button from Actions Container in Time Jump sidebar view
// switches whether to display the button by changing the display property between none and flex
43
+
// switches whether to display the record toggle button by changing the display property between none and flex
42
44
if(recordBtn.style.display==='none'){
43
45
recordBtn.style.display='flex';
44
46
}else{
@@ -51,7 +53,7 @@ function MainContainer(): JSX.Element {
51
53
if(port)return;
52
54
53
55
// chrome.runtime allows our application to retrieve our service worker (our eventual bundles/background.bundle.js after running npm run build), details about the manifest, and allows us to listen and respond to events in our application lifecycle.
54
-
// we connect our listeners to our service worker
56
+
// we connect to our service worker
55
57
constcurrentPort=chrome.runtime.connect();
56
58
57
59
// listen for a message containing snapshots from the background script
@@ -72,7 +74,7 @@ function MainContainer(): JSX.Element {
// regenerator runtime supports async functionality : This package implements a fully-functional source transformation that takes the syntax for generators/yield from ECMAScript 2015 or ES2015 and Asynchronous Iteration proposal and spits out efficient JS-of-today (ES5) that behaves the same way.
7
7
import'regenerator-runtime/runtime';
8
+
// linkFiberInitialization (actually uses the function linkFiber but is labeled here as linkFiberInitialization, returns a function). When this returned function is invoked, it checks if devTools is installed, checks if the website is a reactApp, adds event listeners for timetravel, and allows us to obtain the initial FiberRoot Node from react dev tool
// timeJumpInitialization (actually uses the function timeJumpInitiation but is labeled here as linkFiberInitialization, returns a function) returns a function that sets jumping to false and handles timetravel feature
0 commit comments