Skip to content

Commit b1435f5

Browse files
neyser zananeyser zana
authored andcommitted
resolve conflicts
2 parents f2538a8 + b4a5dad commit b1435f5

File tree

7 files changed

+85
-204
lines changed

7 files changed

+85
-204
lines changed

build/webpack-bundle.js

Lines changed: 0 additions & 38 deletions
Large diffs are not rendered by default.

build/webpack-bundle.js.map

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/StatePropsBox.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from 'react';
33
const StatePropsBox = (props) => {
44
const stateObj = props.nodeData.State;
55
const propObj = props.nodeData.Props
6+
console.log(stateObj, propObj, 'state and props objects')
67
return (
78
<div className='state-prop-display'>
89
{(props.nodeData.Props !== null || props.nodeData.State !== null) ?

src/components/Tool.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
11
import React from "react";
22

3-
4-
const Tool = (props) => {
5-
return (
6-
<div className='tool-tip' onMouseOver={() => props.handleMouseOver(props.nodeData)} >
7-
<h4 className='tree-names'>{props.nodeData.name}</h4>
8-
</div>
9-
);
3+
class Tool extends React.Component {
4+
constructor(props) {
5+
super(props);
6+
this.state = {
7+
toggle: false,
8+
hoverNodeData: []
9+
}
10+
this.handleMouseOver = this.handleMouseOver.bind(this);
11+
this.handleMouseOut = this.handleMouseOut.bind(this);
12+
}
13+
14+
handleMouseOver(data) {
15+
let timeout;
16+
timeout = setTimeout(() => {
17+
this.setState({
18+
toggle: true,
19+
// hoverNodeData: data
20+
})}, 500)
21+
}
22+
handleMouseOut() {
23+
this.setState({
24+
toggle: false
25+
})
26+
}
27+
28+
render() {
29+
const stateObj = this.props.nodeData.State;
30+
const propObj = this.props.nodeData.Props;
31+
const nodeData = this.props.nodeData
32+
return (
33+
<div className='tool-tip' onMouseOut={() => this.handleMouseOut()} onMouseOver={() => this.props.handleMouseOver(this.props.nodeData)} >
34+
<h4 className='tree-names'>{this.props.nodeData.name}</h4>
35+
</div>
36+
);
37+
}
1038
}
1139

1240
export default Tool;

src/components/TreeDiagram.jsx

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import Tree from 'react-d3-tree';
33
import Tool from './Tool';
44
import filterComponents from '../filterComponents';
5+
import filter from '../filterDOM';
56

67
class TreeDiagram extends React.Component {
78
constructor(props) {
@@ -11,53 +12,25 @@ class TreeDiagram extends React.Component {
1112
orientation: 'vertical',
1213
foreignObjectWrapper: {y: -5, x: 10},
1314
nodeSize: {x: 75, y: 75},
14-
domData: []
15+
componentsToFilter: []
1516
};
1617
this.handleFlip = this.handleFlip.bind(this);
18+
this.handleFilter = this.handleFilter.bind(this);
1719
}
1820

1921

2022
componentDidMount() {
2123
//from reactD3 library *centering
22-
// console.log(this.props.filteredData, 'did filteredData arrive to Tree diagram --console.log from componentDidMount line 22 TreeDiagram')
2324
const dimensions = this.treeContainer.getBoundingClientRect();
25+
console.log(dimensions, 'these are the dimensions')
2426
this.setState({
2527
translate: {
2628
x: dimensions.width / 2,
2729
y: dimensions.height / 8
2830
},
29-
domData: this.props.appState,
3031
});
3132
}
3233

33-
//* when theres a change in any of the toggles, filteredDdata stores the filtered components
34-
//* check for any toggles to be true, and filteredData to be not empty, if so setState.
35-
//* issue is we keep running into a repetitive recursive loop and app breaks/
36-
componentDidUpdate() {
37-
if(this.props.filteredData.length !== 0 && this.props.toggleRedux === true || this.props.toggleRouter === true || this.props.toggleApollo === true) {
38-
this.setState({
39-
domData: this.props.filteredData
40-
});
41-
}
42-
}
43-
44-
//* before props are being passed, we want to compare the old props with the newly updated props.
45-
//* if they're not the same (comparing lengths after filter) then we set our state accordingly.
46-
//* wanted to see diff from this and update.
47-
48-
componentWillReceiveProps(nextProps) {
49-
if(this.props.filteredData.length !== nextProps.filteredData.length) {
50-
this.setState({
51-
domData: this.props.filteredData
52-
})
53-
} else {
54-
this.setState({
55-
domData: this.props.appState
56-
})
57-
}
58-
}
59-
60-
6134
handleFlip() {
6235
if(this.state.orientation === 'vertical') {
6336
this.setState({
@@ -73,6 +46,25 @@ class TreeDiagram extends React.Component {
7346
}
7447
}
7548

49+
handleFilter(arr) {
50+
if (!this.state.componentsToFilter.includes(arr[0])) {
51+
let componentsArr = this.state.componentsToFilter.concat(arr);
52+
this.setState({
53+
componentsToFilter: componentsArr
54+
})
55+
} else {
56+
let list = this.state.componentsToFilter;
57+
for (let i = 0; i < list.length; i++) {
58+
if (arr.includes(list[i])) {
59+
list.splice(i, 1);
60+
}
61+
}
62+
this.setState({
63+
componentsToFilter: list
64+
})
65+
}
66+
}
67+
7668

7769
render() {
7870
const styles = {
@@ -104,33 +96,31 @@ class TreeDiagram extends React.Component {
10496
}
10597
};
10698

99+
let data = this.props.appState;
107100

108-
//* eterna's initial code
109-
// let data = this.props.appState;
110-
111-
// if (this.state.componentsToFilter.length) {
112-
// let result = [];
113-
// filter(data, this.state.componentsToFilter, result);
114-
// data = result;
115-
// }
101+
if (this.state.componentsToFilter.length) {
102+
let result = [];
103+
filter(data, this.state.componentsToFilter, result);
104+
data = result;
105+
}
116106

117107
return (
118108
<div id="treeWrapper" ref={tc => (this.treeContainer = tc)}>
119109
<button onClick={() => {this.handleFlip()}}> {this.state.orientation[0].toUpperCase() + this.state.orientation.slice(1)} </button>
120-
<button onClick={() => { this.props.handleReduxFilter(filterComponents.reduxComponents) }}>Filter Redux</button>
121-
<button onClick={() => { this.props.handleRouterFilter(filterComponents.reactRouterComponents) }}>Filter React-Router</button>
122-
<button onClick={() => { this.props.handleApolloFilter(filterComponents.apolloComponents) }}>Filter Apollo-GraphQL</button>
110+
<button onClick={() => { this.handleFilter(filterComponents.reduxComponents) }}>Filter Redux</button>
111+
<button onClick={() => { this.handleFilter(filterComponents.reactRouterComponents) }}>Filter React-Router</button>
112+
<button onClick={() => { this.handleFilter(filterComponents.apolloComponents) }}>Filter Apollo-GraphQL</button>
123113

124-
{this.state.domData.length !== 0 ? (
114+
{/* when appState has a length we populate tree */}
115+
{this.props.appState.length !== 0 ? (
125116
<Tree
126-
data={this.state.domData}
117+
data={data}
127118
nodeSize={{ x: 75, y: 75 }}
128119
orientation={this.state.orientation}
129120
styles={styles}
130121
translate={this.state.translate}
131122
separation={{ siblings: 1, nonSiblings: 1 }}
132123
allowForeignObjects
133-
//* Placing this tool component in the render property of "nodeLabelComponent", we are allowed access to each tree node's data.
134124
nodeLabelComponent={{
135125
render: <Tool handleMouseOver = {this.props.handleMouseOver} />,
136126
foreignObjectWrapper: this.state.foreignObjectWrapper

src/devtools.js

Lines changed: 9 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import StateContainer from './containers/StateContainer.jsx';
88
import TreeDiagram from './components/TreeDiagram.jsx';
99
import recurseDiff from './stateDiff';
1010
import StatePropsBox from './components/StatePropsBox';
11-
import filter from './filterDOM';
12-
import filterComponents from './filterComponents.js';
1311

1412
class App extends Component {
1513
constructor() {
@@ -18,24 +16,23 @@ class App extends Component {
1816
window: 'Graphql',
1917
logs: [],
2018
appReactDOM: [],
21-
// appFilteredDOM: [],
19+
appFilteredDOM: [],
2220
appState: [],
2321
nodeData: [],
2422
schema: 'GraphQL schema not available.',
2523
stateDiff: [],
24+
<<<<<<< HEAD
2625
componentsToFilter: [],
2726
toggleRouter: false,
2827
toggleRedux: false,
2928
toggleApollo: false,
3029
filteredData: [],
30+
=======
31+
>>>>>>> b4a5dad52039ea3cf331740192a49899892e06f2
3132
logView: null
3233
};
3334

3435
this.handleMouseOver = this.handleMouseOver.bind(this);
35-
this.handleApolloFilter = this.handleApolloFilter.bind(this);
36-
this.handleReduxFilter = this.handleReduxFilter.bind(this);
37-
this.handleRouterFilter = this.handleRouterFilter.bind(this);
38-
this.filterOutComponents = this.filterOutComponents.bind(this);
3936

4037
chrome.devtools.panels.create("Lucid", null, "devtools.html");
4138
}
@@ -123,11 +120,6 @@ class App extends Component {
123120

124121
//* invoke schema fetch only after a log object from a previous response is available
125122
componentDidUpdate() {
126-
console.log(this.state.componentsToFilter,
127-
'componentsToFilter updated after filter button click --- componentDidUpdate line 128 devtools.js')
128-
if(this.state.toggleRedux === true || this.state.toggleApollo === true || this.state.toggleRouter === true) {
129-
this.filterOutComponents();
130-
}
131123
if (this.state.schema === "GraphQL schema not available.") {
132124
this.fetchSchemaFromGraphQLServer();
133125
}
@@ -152,106 +144,7 @@ class App extends Component {
152144
this.setState({
153145
nodeData: data
154146
})
155-
}
156-
157-
filterOutComponents() {
158-
let data = this.state.appState;
159-
if(this.state.componentsToFilter.length) {
160-
let result = [];
161-
filter(data, this.state.componentsToFilter, result);
162-
data = result;
163-
//*whether i use filteredData or actual appState we run into a recursive breakage. For now instead of seprating the data, we will try to manipulate appState directly, since same breakage occurs in both situations.
164-
//* I suspect the appState and the changed data are in constant conflict with one another, and we might need to make changes in traverse when a toggle button is clicked. so all freshly new DOM data will have everything filtered upon arrival.
165-
//* else newly arrived DOM data information on user's app will setState, then on update in our dev tool we'll rerun and change state.
166-
//* best to have a toggle change a set of conditions in traverser, where if toggle is set to false, traverse and leave out these set of words apoloProvider etc.
167-
//* filtering data after its already arrived with two traverse functions seem constly, and is the cause of our glitch.
168-
//* throwing the filtering to dev and resetting appState is causing breakage, if cant find solution, go to the source of the issue, the traverser and set toggling conditions there.
169-
this.setState({
170-
filteredData: data
171-
});
172-
// this.setState({
173-
// appState: data
174-
// });
175-
console.log(data, 'filterOutComponents function ran successfully, filteredData is set to this object --coming from devtools line 169')
176-
}
177-
}
178-
179-
handleApolloFilter(arr) {
180-
//* if first index of arr is not in componentsToFilter arr, set incoming array to componentsToFilter
181-
if(!this.state.componentsToFilter.includes(arr[0]) && arr[0] === 'ApolloProvider') {
182-
console.log('did i hit apollo?')
183-
let componentsArr = this.state.componentsToFilter.concat(arr);
184-
this.setState({
185-
componentsToFilter: componentsArr,
186-
toggleApollo: true
187-
})
188-
}
189-
else {
190-
//* if componentsToFilter is not empty iterate through
191-
let list = this.state.componentsToFilter;
192-
let output = [];
193-
for (let i = 0; i < list.length; i++) {
194-
if (!arr.includes(list[i])) {
195-
output.push(list[i]);
196-
}
197-
}
198-
this.setState({
199-
componentsToFilter: output,
200-
toggleApollo: false
201-
})
202-
}
203-
}
204-
205-
handleReduxFilter(arr) {
206-
//* if first index of arr is not in componentsToFilter arr, set incoming array to componentsToFilter
207-
if(!this.state.componentsToFilter.includes(arr[0]) && arr[0] === 'Provider') {
208-
console.log('did i hit redux?')
209-
let componentsArr = this.state.componentsToFilter.concat(arr);
210-
this.setState({
211-
componentsToFilter: componentsArr,
212-
toggleRedux: true
213-
})
214-
}
215-
else {
216-
//* if componentsToFilter is not empty iterate through
217-
let list = this.state.componentsToFilter;
218-
let output = [];
219-
for (let i = 0; i < list.length; i++) {
220-
if (!arr.includes(list[i])) {
221-
output.push(list[i]);
222-
}
223-
}
224-
this.setState({
225-
componentsToFilter: output,
226-
toggleRedux: false
227-
})
228-
}
229-
}
230-
231-
handleRouterFilter(arr) {
232-
//* if first index of arr is not in componentsToFilter arr, set incoming array to componentsToFilter
233-
if(!this.state.componentsToFilter.includes(arr[0]) && arr[0] === 'BrowserRouter') {
234-
console.log('did i hit router?')
235-
let componentsArr = this.state.componentsToFilter.concat(arr);
236-
this.setState({
237-
componentsToFilter: componentsArr,
238-
toggleRouter: true
239-
})
240-
}
241-
else {
242-
//* if componentsToFilter is not empty iterate through
243-
let list = this.state.componentsToFilter;
244-
let output = [];
245-
for (let i = 0; i < list.length; i++) {
246-
if (!arr.includes(list[i])) {
247-
output.push(list[i]);
248-
}
249-
}
250-
this.setState({
251-
componentsToFilter: output,
252-
toggleRouter: false
253-
})
254-
}
147+
console.log(data, 'data came thru from mouse hover')
255148
}
256149

257150
// * handles the clearing of both the request log and diff log
@@ -304,6 +197,7 @@ class App extends Component {
304197
) : (
305198
<div class='reactTab'>
306199
<StateContainer clearLog={this.handleClearLog.bind(this)} stateDiffs={this.state.stateDiff} />
200+
<<<<<<< HEAD
307201
<TreeDiagram
308202
appState = {this.state.appState}
309203
handleMouseOver = {this.handleMouseOver}
@@ -315,6 +209,9 @@ class App extends Component {
315209
toggleRouter = {this.state.toggleRouter}
316210
toggleApolo = {this.state.toggleApollo}
317211
/>
212+
=======
213+
<TreeDiagram appState={this.state.appState} handleMouseOver={this.handleMouseOver} />
214+
>>>>>>> b4a5dad52039ea3cf331740192a49899892e06f2
318215
<StatePropsBox nodeData={this.state.nodeData} />
319216
</div>
320217
)}

src/filterDOM.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const filter = (node, componentsArr, childrenArr) => {
2-
console.log(node.name, 'name from filterDOM.js is it there?')
32
if (node.name === undefined) {
43
filter(node[0], componentsArr, childrenArr)
54
} else {

0 commit comments

Comments
 (0)