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
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.
@@ -24,7 +25,6 @@ const resetSlider = () => {
24
25
}
25
26
};
26
27
27
-
28
28
functionActionContainer(props): JSX.Element{
29
29
const[{ tabs, currentTab, port },dispatch]=useStoreContext();// 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
30
30
const{ currLocation, hierarchy, sliderIndex, viewIndex }=tabs[currentTab];// we destructure the currentTab object
@@ -57,7 +57,8 @@ function ActionContainer(props): JSX.Element {
57
57
obj.stateSnapshot.children[0].state&&// with a 'state'
58
58
obj.stateSnapshot.children[0].name// and a 'name'
59
59
){
60
-
constnewObj: Record<string,unknown>={// 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'.
60
+
constnewObj: Record<string,unknown>={
61
+
// 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'.
61
62
index: obj.index,
62
63
displayName: `${obj.name}.${obj.branch}`,
63
64
state: obj.stateSnapshot.children[0].state,
@@ -71,7 +72,8 @@ function ActionContainer(props): JSX.Element {
71
72
hierarchyArr.push(newObj);// we push our record object into 'hiearchyArr' defined on line 35
72
73
}
73
74
74
-
if(obj.children){// if argument has a 'children' array, we iterate through it and run 'displayArray' on each element
75
+
if(obj.children){
76
+
// if argument has a 'children' array, we iterate through it and run 'displayArray' on each element
75
77
obj.children.forEach((element): void=>{
76
78
displayArray(element);
77
79
});
@@ -84,28 +86,27 @@ function ActionContainer(props): JSX.Element {
84
86
// 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
elseif(e.key==='ArrowDown'){// down arrow key pressed
95
+
}elseif(e.key==='ArrowDown'){
96
+
// down arrow key pressed
95
97
currIndex+=1;
96
98
if(currIndex>hierarchyArr.length-1)return;
97
99
dispatch(changeView(currIndex));
98
-
}
99
-
100
-
elseif(e.key==='Enter'){// enter key pressed
100
+
}elseif(e.key==='Enter'){
101
+
// enter key pressed
101
102
e.stopPropagation();// prevents further propagation of the current event in the capturing and bubbling phases
102
103
e.preventDefault();// needed or will trigger onClick right after
103
104
dispatch(changeSlider(currIndex));
104
105
}
105
106
}
106
107
107
108
// 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
routes[actionsArr[i].props.routePath]=[actionsArr[i]];// 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].
175
-
}else{
176
+
routes[actionsArr[i].props.routePath]=[actionsArr[i]];// 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].
177
+
}else{
176
178
routes[actionsArr[i].props.routePath].push(actionsArr[i]);// If it does exist, we push the component at index [i] to the apporpriate routes[routePath]
177
179
}
178
180
}
@@ -202,7 +204,8 @@ function ActionContainer(props): JSX.Element {
202
204
<divclassName='action-button-wrapper'>
203
205
<SwitchAppDropdown/>
204
206
<divclassName='action-component exclude'>
205
-
<button
207
+
<Button
208
+
variant='contained'
206
209
className='empty-button'
207
210
onClick={()=>{
208
211
dispatch(emptySnapshots());
@@ -212,7 +215,7 @@ function ActionContainer(props): JSX.Element {
0 commit comments