Skip to content

Commit abc698a

Browse files
Merge branch 'master' into keyCommands
2 parents 3d718bb + fcc8e14 commit abc698a

File tree

5 files changed

+73
-64
lines changed

5 files changed

+73
-64
lines changed

src/app/components/Action.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { changeView, changeSlider } from '../actions/actions';
44

5+
/* // gabi and nate :: index and delta props were removed from Action.jsx */
56
const Action = props => {
67
const {
7-
selected, index, delta, sliderIndex, dispatch,
8+
selected, index, sliderIndex, dispatch, displayName, componentName, state
89
} = props;
910

1011
// function arrowKeys(event, indexx) {
@@ -35,9 +36,7 @@ const Action = props => {
3536
tabIndex={index}
3637
>
3738
<div className="action-component-text">
38-
{`${index
39-
}: ${delta}`}
40-
39+
{`${displayName}: ${componentName} `}
4140
</div>
4241
<button
4342
className="jump-button"
@@ -54,13 +53,15 @@ const Action = props => {
5453
</div>
5554
);
5655
};
57-
56+
// gabi and nate :: added displayName, componentName and State props to propTypes
5857
Action.propTypes = {
5958
sliderIndex: PropTypes.number.isRequired,
6059
selected: PropTypes.bool.isRequired,
6160
index: PropTypes.number.isRequired,
6261
dispatch: PropTypes.func.isRequired,
63-
delta: PropTypes.string.isRequired,
62+
displayName: PropTypes.string.isRequired,
63+
componentName: PropTypes.string.isRequired,
64+
state: PropTypes.object.isRequired
6465
};
6566

6667
export default Action;

src/app/components/Chart.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ class Chart extends Component {
2323

2424
componentDidMount() {
2525
const { hierarchy } = this.props;
26+
console.log('this is hierarchy on didMount chart', hierarchy)
2627
root = JSON.parse(JSON.stringify(hierarchy));
2728
this.maked3Tree();
2829
}
2930

3031
componentDidUpdate() {
3132
const { hierarchy } = this.props;
33+
console.log('this is hierarchy on didUpdate chart', hierarchy)
3234
root = JSON.parse(JSON.stringify(hierarchy));
3335
this.maked3Tree();
3436
}
@@ -50,7 +52,7 @@ class Chart extends Component {
5052
};
5153
const width = 600 - margin.right - margin.left;
5254
const height = 700 - margin.top - margin.bottom;
53-
55+
console.log('this is this.chartRef.current on chart', this.chartRef.current)
5456
const chartContainer = d3.select(this.chartRef.current)
5557
.append('svg') // chartContainer is now pointing to svg
5658
.attr('width', width)
@@ -71,7 +73,8 @@ class Chart extends Component {
7173
const tree = d3.tree()
7274
// this assigns width of tree to be 2pi
7375
.size([2 * Math.PI, radius / 1.3])
74-
.separation(function (a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
76+
// .separation(function (a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
77+
.separation(function (a, b) { return (a.parent == b.parent ? 1 : 2)});
7578

7679
const d3root = tree(hierarchy);
7780

@@ -142,7 +145,10 @@ class Chart extends Component {
142145
// this arranges the angle of the text
143146
.attr('transform', function (d) { return 'rotate(' + (d.x < Math.PI ? d.x - Math.PI / 2 : d.x + Math.PI / 2) * 1 / Math.PI + ')'; })
144147
.text(function (d) {
145-
return d.data.index;
148+
console.log('this is d from text char line 148', d)
149+
// save d.data.index to variable
150+
// gabi and nate :: display the name of of specific patch
151+
return `${d.data.name}.${d.data.branch}`;
146152
});
147153

148154
// allows svg to be dragged around

src/app/containers/ActionContainer.jsx

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,67 +14,46 @@ const resetSlider = () => {
1414

1515
function ActionContainer() {
1616
const [{ tabs, currentTab }, dispatch] = useStoreContext();
17-
const { snapshots, sliderIndex, viewIndex } = tabs[currentTab];
17+
const { hierarchy, sliderIndex, viewIndex } = tabs[currentTab];
18+
console.log('actionContainer tabs[currentTab];', tabs[currentTab])
1819

1920
let actionsArr = [];
20-
// build actions array
21-
if (snapshots.length > 0) {
22-
// breadth first function - take in an delta obj
23-
function breadthFirst(delta) {
24-
if (delta === undefined) return '';
25-
// aux array = current and one called next
26-
let current = Object.values(delta.children); // Object.keys(delta.children);
27-
let next = [];
28-
let result = '';
29-
// return a string
30-
while (current.length > 0) {
31-
const shifted = current.shift();
32-
if (shifted.state) {
33-
// eslint-disable-next-line no-loop-func
34-
Object.keys(shifted.state).forEach(key => {
35-
result = result.concat(key, ', ');
36-
});
37-
}
38-
if (shifted.children) {
39-
// eslint-disable-next-line no-loop-func
40-
Object.keys(shifted.children).forEach(el => {
41-
next.push(shifted.children[el]);
42-
});
43-
}
44-
if (current.length === 0) {
45-
current = next;
46-
next = [];
47-
}
48-
}
49-
return result;
50-
}
21+
let hierarchyArr = [];
5122

52-
function truncate(newDiff, num = 15) {
53-
if (newDiff.length <= num) return newDiff.replace(',', '');
54-
const thisdiff = newDiff.slice(0, num);
55-
return thisdiff.concat('...');
56-
}
57-
actionsArr = snapshots.map((snapshot, index) => {
58-
const selected = index === viewIndex;
59-
let newDiff = '';
60-
// if index is greater than 0
61-
if (index > 0) {
62-
// calculate the diff
63-
const delta = diff(snapshots[index - 1], snapshot);
64-
newDiff = truncate(breadthFirst(delta));
23+
// gabi and nate :: delete function to traverse state from snapshots, now we are tranversing state from hiararchy and alsog getting infromation on display name and component name
24+
const displayArray = (obj) => {
25+
const newObj = {
26+
index: obj.index,
27+
displayName : `${obj.name}.${obj.branch}`,
28+
state: obj.stateSnapshot.children[0].state,
29+
componentName: obj.stateSnapshot.children[0].name,
30+
}
31+
hierarchyArr.push(newObj)
32+
if(obj.children){
33+
obj.children.forEach((element) => {
34+
displayArray(element)
35+
})
6536
}
37+
}
38+
displayArray(hierarchy)
39+
console.log('this is hierarchyArr', hierarchyArr)
40+
41+
actionsArr = hierarchyArr.map((snapshot, index) => {
42+
const selected = index === viewIndex;
6643
return (
6744
<Action
6845
key={`action${index}`}
6946
index={index}
47+
state={snapshot.state}
48+
displayName={snapshot.displayName}
49+
componentName={snapshot.componentName}
7050
selected={selected}
7151
dispatch={dispatch}
7252
sliderIndex={sliderIndex}
73-
delta={newDiff}
7453
/>
7554
);
7655
});
77-
}
56+
7857
return (
7958
<div className="action-container">
8059
<div className="action-component exclude">

src/app/styles/components/d3graph.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ div.tooltip {
5858
pointer-events: none;
5959
}
6060

61-
/* .d3-tip {
61+
.d3-tip {
6262
line-height: 1;
6363
padding: 6px;
6464
background: #9cf4df;
@@ -68,9 +68,9 @@ div.tooltip {
6868
max-width: 400px;
6969
overflow-wrap: break-word;
7070
font-family: "Overpass Mono", monospace;
71-
} */
71+
}
7272

73-
/* Creates a small triangle extender for the tooltip
73+
/* Creates a small triangle extender for the tooltip */
7474
.d3-tip:after {
7575
box-sizing: border-box;
7676
display: inline;
@@ -80,11 +80,11 @@ div.tooltip {
8080
content: "\25BC";
8181
position: absolute;
8282
text-align: center;
83-
} */
83+
}
8484

8585
/* Style northward tooltips specifically */
86-
/* .d3-tip.n:after {
86+
.d3-tip.n:after {
8787
margin: -2px 0 0 0;
8888
top: 100%;
8989
left: 0;
90-
} */
90+
}

src/extension/background.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ function createTabObj(title) {
1717
title,
1818
// snapshots is an array of ALL state snapshots for the reactime tab working on a specific user application
1919
snapshots: [],
20-
index: 0,
20+
// gabi and nate :: index here is the tab index that show total amount of state changes
21+
index: 0,
2122
//* this is our pointer so we know what the current state the user is checking (this accounts for time travel aka when user clicks jump on the UI)
2223
currLocation: null,
24+
// gabi and nate :: point the node that will generate the next child set by newest node or jump
25+
currParent: 0,
26+
// gabi and nate :: points to the current branch
27+
currBranch: 0,
2328
//* inserting a new property to build out our hierarchy dataset for d3
2429
hierarchy: null,
2530
mode: {
@@ -35,7 +40,12 @@ class Node {
3540
// eslint-disable-next-line no-param-reassign
3641
// eslint-disable-next-line no-multi-assign
3742
// eslint-disable-next-line no-plusplus
43+
// gabi and nate :: continue the order of number of total state changes
3844
this.index = tabObj.index++;
45+
// gabi and nate :: continue the order of number of states changed from that parent
46+
this.name = tabObj.currParent+=1;
47+
// gabi and nate :: mark from what branch this node is originated
48+
this.branch = tabObj.currBranch;
3949
this.stateSnapshot = obj;
4050
this.children = [];
4151
console.log('created node in background.js constructor');
@@ -48,14 +58,24 @@ function sendToHierarchy(tabObj, newNode) {
4858
tabObj.hierarchy = newNode;
4959
} else {
5060
tabObj.currLocation.children.push(newNode);
61+
// gabi and nate :: if the node's children's array is empty
62+
if(tabObj.currLocation.children.length > 1){
63+
// gabi and nate :: increment the value of the nodes branch by 1
64+
newNode.branch+=1
65+
// gabi and nate :: reassign value of current branch the newNode branch value
66+
tabObj.currBranch = newNode.branch;
67+
}
5168
tabObj.currLocation = newNode;
5269
}
5370
}
5471

5572
function changeCurrLocation(tabObj, rootNode, index) {
73+
// gabi and nate :: index comes from the app's main reducer to locate the right current location on tabObj
5674
// check if current node has the index wanted
57-
if (rootNode.index === index) {
75+
if (rootNode.index === index) {
5876
tabObj.currLocation = rootNode;
77+
// gabi and nate :: index of current location from where the next node will be a child
78+
tabObj.currParent = index;
5979
return;
6080
}
6181
// base case if no children
@@ -165,6 +185,9 @@ chrome.runtime.onMessage.addListener((request, sender) => {
165185

166186
switch (action) {
167187
case 'jumpToSnap': {
188+
// console.log('this tabsObj[tabId] sent to changeCurrLocation', tabsObj[tabId])
189+
// console.log('this tabsObj[tabId].hierarchy sent to changeCurrLocation', tabsObj[tabId].hierarchy)
190+
// console.log('this index sent to changeCurrLocation', index)
168191
changeCurrLocation(tabsObj[tabId], tabsObj[tabId].hierarchy, index);
169192
break;
170193
}

0 commit comments

Comments
 (0)