Skip to content

Commit 4c62fc6

Browse files
committed
added colores to chart, debug initial tab, debug counter
1 parent 87f621c commit 4c62fc6

File tree

8 files changed

+29
-27
lines changed

8 files changed

+29
-27
lines changed

src/app/components/Chart.jsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ class Chart extends Component {
2727

2828
componentDidMount() {
2929
const { hierarchy } = this.props;
30-
// console.log('this is hierarchy on didMount chart', hierarchy)
3130
root = JSON.parse(JSON.stringify(hierarchy));
3231
this.maked3Tree();
3332
}
3433

3534
componentDidUpdate() {
3635
const { hierarchy } = this.props;
37-
// console.log('this is hierarchy on didUpdate chart', hierarchy)
3836
root = JSON.parse(JSON.stringify(hierarchy));
3937
this.maked3Tree();
4038
}
@@ -56,7 +54,6 @@ class Chart extends Component {
5654
};
5755
const width = 600 - margin.right - margin.left;
5856
const height = 700 - margin.top - margin.bottom;
59-
// console.log('this is this.chartRef.current on chart', this.chartRef.current)
6057
const chartContainer = d3.select(this.chartRef.current)
6158
.append('svg') // chartContainer is now pointing to svg
6259
.attr('width', width)
@@ -94,7 +91,6 @@ class Chart extends Component {
9491
.attr('class', 'link')
9592
.attr('d', d3.linkRadial()
9693
.angle(d => {
97-
console.log('d on line 92 chart', d)
9894
return d.x
9995
})
10096
.radius(d => d.y));
@@ -105,8 +101,15 @@ class Chart extends Component {
105101
.enter()
106102
.append('g')
107103
.style('fill', function (d) {
108-
console.log('this is d', d)
109-
return colors[d.data.branch]
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+
}
110113
})
111114
.attr('class', 'node--internal')
112115
// })
@@ -159,8 +162,6 @@ class Chart extends Component {
159162
// this arranges the angle of the text
160163
.attr('transform', function (d) { return 'rotate(' + (d.x < Math.PI ? d.x - Math.PI / 2 : d.x + Math.PI / 2) * 1 / Math.PI + ')'; })
161164
.text(function (d) {
162-
// console.log('this is d from text char line 148', d)
163-
// save d.data.index to variable
164165
// gabi and nate :: display the name of of specific patch
165166
return `${d.data.name}.${d.data.branch}`;
166167
});

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/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)