Skip to content

Commit a2b5286

Browse files
authored
Merge pull request #21 from oslabs-beta/staging
Staging
2 parents a924b52 + 885b644 commit a2b5286

File tree

10 files changed

+49
-37
lines changed

10 files changed

+49
-37
lines changed

src/app/components/Action.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Action = props => {
1818
dispatch(changeView(index));
1919
}}
2020
role="presentation"
21-
style={index > sliderIndex ? { color: '#5f6369' } : {}}
21+
style={index >= sliderIndex ? { color: '#5f6369' } : {}}
2222
tabIndex={index}
2323
>
2424
<div className="action-component-text">

src/app/components/Chart.jsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import React, { Component } from 'react';
1515
import * as d3 from 'd3';
1616

17+
const colors = ['#2C4870','#519331','#AA5039','#8B2F5F','#C5B738','#858DFF', '#FF8D02','#FFCD51','#ACDAE6','#FC997E','#CF93AD','#AA3939','#AA6C39','#226666',]
18+
1719
let root = {};
1820
class Chart extends Component {
1921
constructor(props) {
@@ -25,14 +27,12 @@ class Chart extends Component {
2527

2628
componentDidMount() {
2729
const { hierarchy } = this.props;
28-
// console.log('this is hierarchy on didMount chart', hierarchy)
2930
root = JSON.parse(JSON.stringify(hierarchy));
3031
this.maked3Tree();
3132
}
3233

3334
componentDidUpdate() {
3435
const { hierarchy } = this.props;
35-
// console.log('this is hierarchy on didUpdate chart', hierarchy)
3636
root = JSON.parse(JSON.stringify(hierarchy));
3737
this.maked3Tree();
3838
}
@@ -54,7 +54,6 @@ class Chart extends Component {
5454
};
5555
const width = 600 - margin.right - margin.left;
5656
const height = 700 - margin.top - margin.bottom;
57-
// console.log('this is this.chartRef.current on chart', this.chartRef.current)
5857
const chartContainer = d3.select(this.chartRef.current)
5958
.append('svg') // chartContainer is now pointing to svg
6059
.attr('width', width)
@@ -92,7 +91,6 @@ class Chart extends Component {
9291
.attr('class', 'link')
9392
.attr('d', d3.linkRadial()
9493
.angle(d => {
95-
console.log('d on line 92 chart', d)
9694
return d.x
9795
})
9896
.radius(d => d.y));
@@ -102,10 +100,23 @@ class Chart extends Component {
102100
.data(d3root.descendants())
103101
.enter()
104102
.append('g')
105-
// assigning class to the node based on whether node has children or not
106-
.attr('class', function (d) {
107-
return 'node' + (d.children ? ' node--internal' : ' node--leaf');
103+
.style('fill', function (d) {
104+
if(d.data.branch < colors.length){
105+
return colors[d.data.branch]
106+
} else {
107+
let indexColors = d.data.branch - colors.length;
108+
while(indexColors > colors.length){
109+
indexColors = indexColors - colors.length;
110+
}
111+
return colors[indexColors]
112+
}
108113
})
114+
.attr('class', 'node--internal')
115+
// })
116+
// assigning class to the node based on whether node has children or not
117+
// .attr('class', function (d) {
118+
// return 'node' + (d.children ? ' node--internal' : ' node--leaf');
119+
// })
109120
.attr('transform', function (d) {
110121
return 'translate(' + reinfeldTidierAlgo(d.x, d.y) + ')';
111122
});
@@ -151,8 +162,6 @@ class Chart extends Component {
151162
// this arranges the angle of the text
152163
.attr('transform', function (d) { return 'rotate(' + (d.x < Math.PI ? d.x - Math.PI / 2 : d.x + Math.PI / 2) * 1 / Math.PI + ')'; })
153164
.text(function (d) {
154-
// console.log('this is d from text char line 148', d)
155-
// save d.data.index to variable
156165
// gabi and nate :: display the name of of specific patch
157166
return `${d.data.name}.${d.data.branch}`;
158167
});

src/app/containers/ActionContainer.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ function ActionContainer() {
3838
}
3939
// gabi :: the hierarchy get set on the first click in the page, when page in refreshed we don't have a hierarchy so we need to check if hierarchy was inicialize involk displayArray to display the hierarchy
4040
if (hierarchy) displayArray(hierarchy)
41-
// console.log('this is hierarchyArr', hierarchyArr)
4241

4342
// Edwin: handles keyboard presses, function passes an event and index of each action-component
4443
function handleOnKeyDown(e, i) {

src/app/containers/MainContainer.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ import { useStoreContext } from '../store';
1313
function MainContainer() {
1414
const [store, dispatch] = useStoreContext();
1515
const { tabs, currentTab, port: currentPort } = store;
16-
// console.log('entered MainContainer');
1716

1817
// add event listeners to background script
1918
useEffect(() => {
2019
// only open port once
2120
if (currentPort) return;
2221
// open connection with background script
23-
// console.log('opening connection with background script');
2422
const port = chrome.runtime.connect();
25-
// console.log('connection opened?');
2623

2724
// listen for a message containing snapshots from the background script
2825
port.onMessage.addListener(message => {
29-
// console.log('this is message from port', message)
3026
const { action, payload, sourceTab } = message;
27+
let maxTab
28+
if(!sourceTab){
29+
let tabsArray = Object.keys(payload)
30+
maxTab = Math.max(...tabsArray)
31+
}
3132
switch (action) {
3233
case 'deleteTab': {
3334
dispatch(deleteTab(payload));
@@ -44,8 +45,8 @@ function MainContainer() {
4445
break;
4546
}
4647
case 'initialConnectSnapshots': {
48+
dispatch(setTab(maxTab));
4749
dispatch(initialConnect(payload));
48-
dispatch(setTab(sourceTab));
4950
break;
5051
}
5152
default:

src/app/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ import ReactDOM from 'react-dom';
44
import App from './components/App';
55
import './styles/main.scss';
66

7-
console.log('entered index.js, rendering App')
87
ReactDOM.render(<App />, document.getElementById('root'));

src/app/reducers/mainReducer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ export default (state, action) => produce(state, draft => {
214214
break;
215215
}
216216
case types.SET_TAB: {
217-
// console.log('this is SET_TAB action.payload', action.payload)
218217
if (typeof action.payload === 'number') {
219218
draft.currentTab = action.payload;
220219
break;

src/app/styles/components/d3graph.css

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,43 @@ body {
66

77
.node {
88
cursor: pointer;
9+
fill-opacity: 0.8;
910
}
1011

1112
/* this represents leaf nodes aka nodes with no children */
12-
.node circle {
13+
/* .node circle {
1314
fill: #5249f7;
14-
}
15+
} */
1516

1617
/* .node circle:hover {
1718
fill: #320a5c;
1819
} */
1920

2021
.node text {
22+
fill: #fae6e4;
2123
font-size: 10px;
2224
font-family: "Overpass Mono", monospace;
2325
}
2426

2527

2628
/* this represents text for leaf nodes aka the ones with no children */
27-
.node--leaf {
29+
/* .node--leaf {
2830
fill: #71e9e1;
2931
fill-opacity: 0.8;
30-
}
32+
} */
3133

3234
/* this represents those nodes that have children */
33-
.node--internal circle {
35+
/* .node--internal circle {
3436
fill: #d317c9;
35-
}
37+
} */
3638
/* modifies text of parent nodes (has children) */
3739
.node--internal text {
38-
fill: #fae6e4;
40+
fill: white;
3941
font-size: 10px;
4042
}
4143
.link {
4244
fill: none;
43-
stroke: #3853ea;
45+
stroke:#fae6e4;;
4446
stroke-opacity: 0.4;
4547
stroke-width: 3px;
4648
}

src/extension/background.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const reloaded = {};
99
const firstSnapshotReceived = {};
1010
// there will be the same number of objects in here as there are reactime tabs open for each user application being worked on
1111
const tabsObj = {};
12-
console.log('entered background.js');
1312

1413
function createTabObj(title) {
1514
// update tabsObj
@@ -53,7 +52,6 @@ class Node {
5352
this.branch = tabObj.currBranch;
5453
this.stateSnapshot = obj;
5554
this.children = [];
56-
console.log('created node in background.js constructor');
5755
}
5856
}
5957

@@ -145,8 +143,9 @@ chrome.runtime.onConnect.addListener(port => {
145143
// gabi :: reset snapshots to page last state recorded
146144
tabsObj[tabId].snapshots = [tabsObj[tabId].snapshots[tabsObj[tabId].snapshots.length - 1] ];
147145
// gabi :: record hierarchy of page initial state
148-
tabsObj[tabId].initialHierarchy = {...tabsObj[tabId].hierarchy};
149-
tabsObj[tabId].initialHierarchy.children = [];
146+
// tabsObj[tabId].initialHierarchy = {...tabsObj[tabId].hierarchy};
147+
// tabsObj[tabId].initialHierarchy.children = [];
148+
tabsObj[tabId].initialHierarchy = {...tabsObj[tabId].hierarchy, children: []};
150149
// gabi :: reset hierarchy
151150
tabsObj[tabId].hierarchy.children = [];
152151
// gabi :: reset hierarchy to page last state recorded
@@ -180,7 +179,9 @@ chrome.runtime.onConnect.addListener(port => {
180179
// background.js recieves message from contentScript.js
181180
chrome.runtime.onMessage.addListener((request, sender) => {
182181
// IGNORE THE AUTOMATIC MESSAGE SENT BY CHROME WHEN CONTENT SCRIPT IS FIRST LOADED
183-
if (request.type === 'SIGN_CONNECT') return true;
182+
if (request.type === 'SIGN_CONNECT'){
183+
return true;
184+
}
184185
const tabTitle = sender.tab.title;
185186
const tabId = sender.tab.id;
186187
const { action, index, name } = request;
@@ -222,14 +223,19 @@ chrome.runtime.onMessage.addListener((request, sender) => {
222223
// gabi :: reset snapshots to page initial state
223224
tabsObj[tabId].snapshots.splice(1);
224225
// gabi :: reset hierarchy to page initial state
225-
tabsObj[tabId].hierarchy.children = [];
226+
if(tabsObj[tabId].hierarchy){
227+
tabsObj[tabId].hierarchy.children = [];
228+
// gabi :: reset currParent plus current state
229+
tabsObj[tabId].currParent = 1;
230+
} else {
231+
// gabi :: reset currParent
232+
tabsObj[tabId].currParent = 0;
233+
}
226234
}
227235
// gabi :: reset currLocation to page initial state
228236
tabsObj[tabId].currLocation = tabsObj[tabId].hierarchy;
229237
// gabi :: reset index
230238
tabsObj[tabId].index = 0;
231-
// gabi :: reset currParent plus current state
232-
tabsObj[tabId].currParent = 1;
233239
// gabi :: reset currBranch
234240
tabsObj[tabId].currBranch = 0;
235241

@@ -317,7 +323,6 @@ chrome.tabs.onRemoved.addListener(tabId => {
317323
// when tab is view change, put the tabid as the current tab
318324
chrome.tabs.onActivated.addListener(info => {
319325
// tell devtools which tab to be the current
320-
console.log('this is info.tabId from chrome.tabs.onActivated.addListener', info)
321326
if (portsArr.length > 0) {
322327
portsArr.forEach(bg =>
323328
bg.postMessage({

src/extension/build/devtools.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
console.log('devtools.js, creating panel');
21
chrome.devtools.panels.create('Reactime', null, 'panel.html', () => {});

src/extension/contentScript.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@ chrome.runtime.onMessage.addListener(request => { // seems to never fire
3939
return true; // attempt to fix port closing console error
4040
});
4141

42-
console.log('sending contentScriptStarted message to window');
4342
window.postMessage({ action: 'contentScriptStarted' });

0 commit comments

Comments
 (0)