Skip to content

Commit 3071e51

Browse files
Merge pull request #9 from StackOverFlowWhereArtThou/fixSaveButton
Save Series Improved Features
2 parents 4757290 + 3bcdacc commit 3071e51

File tree

5 files changed

+54
-25
lines changed

5 files changed

+54
-25
lines changed

src/app/components/BarGraph.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-nocheck
2-
import React from 'react';
2+
import React, { useEffect } from 'react';
33
import { BarStack } from '@visx/shape';
44
import { SeriesPoint } from '@visx/shape/lib/types';
55
import { Group } from '@visx/group';
@@ -109,19 +109,19 @@ const BarGraph = (props) => {
109109
data,
110110
};
111111

112-
const animateButton = function (e) {
113-
e.preventDefault;
114-
e.target.classList.add('animate');
115-
e.target.innerHTML = 'Saved!';
116-
setTimeout(function () {
117-
e.target.innerHTML = 'Save Series';
118-
e.target.classList.remove('animate');
119-
}, 1000);
120-
};
121-
const classname = document.getElementsByClassName('save-series-button');
122-
for (let i = 0; i < classname.length; i++) {
123-
classname[i].addEventListener('click', animateButton, false);
124-
}
112+
// use this to animate the save series button. It
113+
useEffect(() => {
114+
const saveButtons = document.getElementsByClassName('save-series-button');
115+
for (let i = 0; i < saveButtons.length; i++) {
116+
if (tabs[currentTab].seriesSavedStatus) {
117+
saveButtons[i].classList.add('animate');
118+
saveButtons[i].innerHTML = 'Saved!';
119+
} else {
120+
saveButtons[i].innerHTML = 'Save Series';
121+
saveButtons[i].classList.remove('animate');
122+
};
123+
};
124+
});
125125
return (
126126
<div className='bargraph-position'>
127127
<button

src/app/containers/MainContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function MainContainer(): any {
6060
case 'sendSnapshots': {
6161
dispatch(setTab(sourceTab));
6262
// set state with the information received from the background script
63+
console.log('sendSnapshots payload\n', payload); // HFConsoleLog
6364
dispatch(addNewSnapshots(payload));
6465
break;
6566
}

src/app/reducers/mainReducer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export default (state, action) =>
3838
case types.SAVE: {
3939
const data = JSON.stringify(action.payload);
4040
localStorage.setItem(`${action.payload.currentTab}`, data);
41+
tabs[currentTab] = {...tabs[currentTab], seriesSavedStatus: true};
42+
console.log('seriesSavedStatus set to true from saving series');
4143
break;
4244
}
4345
// Delete case will delete ALL stored series in chrome local storage. To see chrome storage related data
@@ -56,6 +58,7 @@ export default (state, action) =>
5658
...tabs[tab],
5759
};
5860
});
61+
tabs[currentTab] = {...tabs[currentTab], seriesSavedStatus: false}
5962
}
6063
case types.ON_HOVER_EXIT: {
6164
port.postMessage({
@@ -187,6 +190,8 @@ export default (state, action) =>
187190
tabs[currentTab].currParent = 1;
188191
// resets currBranch
189192
tabs[currentTab].currBranch = 0;
193+
// resets series saved status
194+
tabs[currentTab].seriesSavedStatus = false;
190195
break;
191196
}
192197
case types.SET_PORT: {
@@ -265,7 +270,9 @@ export default (state, action) =>
265270
...tabs[tab],
266271
...payload[tab],
267272
sliderIndex: newSnaps.length - 1,
273+
seriesSavedStatus: false,
268274
};
275+
console.log('seriesSavedStatus set to false from new snapshot');
269276
}
270277
});
271278

src/extension/background.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const metrics = {};
1414
// which will hold test app's snapshots, link fiber tree info, chrome tab info, etc.
1515
// console.log("hello from background.js");
1616
function createTabObj(title) {
17+
// TO-DO for save button
18+
// Save State
19+
// Knowlege of the comparison snapshot
20+
// Check for it in the reducer
1721
// update tabsObj
1822
return {
1923
title,

src/extension/build/manifest.json

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
{
2-
"name": "ReactimeX",
3-
"version": "8.0.0",
2+
"name": "ReactimevHarryFox",
3+
"version": "8.0.1",
44
"devtools_page": "devtools.html",
55
"description": "A Chrome extension that helps debug React applications by memorizing the state of components with every render.",
66
"manifest_version": 2,
7-
"content_security_policy":"script-src 'self' https://www.gstatic.com:* 'unsafe-eval'; object-src 'self'",
7+
"content_security_policy": "script-src 'self' https://www.gstatic.com:* 'unsafe-eval'; object-src 'self'",
88
"background": {
9-
"scripts": ["bundles/background.bundle.js"],
9+
"scripts": [
10+
"bundles/background.bundle.js"
11+
],
1012
"persistent": false
1113
},
12-
"icons": { "48": "assets/icon48.png", "128": "assets/icon128.png" },
14+
"icons": {
15+
"48": "assets/icon48.png",
16+
"128": "assets/icon128.png"
17+
},
1318
"content_scripts": [
1419
{
15-
"matches": ["http://localhost/*", "https://localhost/*"],
16-
"js": ["bundles/content.bundle.js"]
20+
"matches": [
21+
"http://localhost/*",
22+
"https://localhost/*"
23+
],
24+
"js": [
25+
"bundles/content.bundle.js"
26+
]
1727
}
1828
],
19-
"web_accessible_resources" : ["bundles/backend.bundle.js"],
20-
"permissions": ["contextMenus", "tabs", "activeTab", "http://localhost/*", "https://localhost/*"]
21-
22-
}
29+
"web_accessible_resources": [
30+
"bundles/backend.bundle.js"
31+
],
32+
"permissions": [
33+
"contextMenus",
34+
"tabs",
35+
"activeTab",
36+
"http://localhost/*",
37+
"https://localhost/*"
38+
]
39+
}

0 commit comments

Comments
 (0)