Skip to content

Commit a115946

Browse files
committed
#netpyne-103: removing reset button, removing update timestamp, clean up dependencies
1 parent a922d1f commit a115946

5 files changed

Lines changed: 50 additions & 49 deletions

File tree

webapp/components/general/TutorialBubble.js

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import React, { useState, useRef, useEffect } from 'react';
2-
import { Box, Button, Grid, Typography } from '@material-ui/core';
2+
import {
3+
Box, Button, Grid, Typography,
4+
} from '@material-ui/core';
35
import {
46
primaryColor, secondaryColor, bgLight, bgDark, primaryTextColor, secondaryTextColor, fontColor,
57
} from '../../theme';
68

79
const rectMargin = 4;
810

911
const TutorialBubble = ({
10-
requestedTourStep, steps, lastCheckRender, stopTutorial, incrementTutorialStep, validateTutorialStep, currentTourStep
12+
requestedTourStep, steps, lastCheckRender, stopTutorial, incrementTutorialStep, validateTutorialStep, currentTourStep,
1113
}) => {
12-
const tutorialTarget = useRef(null)
14+
const tutorialTarget = useRef(null);
1315

14-
useEffect(() => {
15-
return () => {
16-
tutorialTarget.current = null;
17-
}
18-
}, [])
16+
useEffect(() => () => {
17+
tutorialTarget.current = null;
18+
}, []);
1919

2020
const getDOMTarget = (target, config) => {
2121
// We query the DOM with the selector
@@ -37,7 +37,7 @@ const TutorialBubble = ({
3737
return DOMtargets[config?.collectionIndex || 0];
3838
};
3939

40-
function calculateVisiblePosition(rect1, width2, height2) {
40+
function calculateVisiblePosition (rect1, width2, height2) {
4141
const windowHeight = window.innerHeight;
4242
const windowWidth = window.innerWidth;
4343

@@ -68,11 +68,10 @@ const TutorialBubble = ({
6868
}
6969

7070
const nextTourStep = steps[requestedTourStep];
71-
const { target: nextTarget } = nextTourStep ? nextTourStep : { target: undefined };
71+
const { target: nextTarget } = nextTourStep || { target: undefined };
7272

7373
const { target, title, content } = tourStep;
7474

75-
7675
const DOMtarget = getDOMTarget(target, tourStep);
7776
const nextDOMtarget = getDOMTarget(nextTarget, nextTourStep);
7877
const visible = DOMtarget?.checkVisibility();
@@ -91,7 +90,7 @@ const TutorialBubble = ({
9190
return false;
9291
}
9392
return el.parentNode.isContentEditable;
94-
}
93+
};
9594

9695
const isAnyEditable = (element) => {
9796
if (isEditable(element)) {
@@ -104,27 +103,27 @@ const TutorialBubble = ({
104103
}
105104
}
106105
return false;
107-
}
106+
};
108107

109108
const listen = (event) => {
110109
tutorialTarget.current = null;
111110
incrementTutorialStep();
112-
}
111+
};
113112

114113
const stop = (event) => {
115114
stopTutorial(event);
116115
tutorialTarget.current = null;
117-
}
116+
};
118117

119118
if (currentTourStep === requestedTourStep) {
120119
tutorialTarget.current = null;
121120
}
122121

123122
if (!tutorialTarget.current && currentTourStep !== requestedTourStep) {
124123
tutorialTarget.current = DOMtarget;
125-
let waitFor = tourStep.waitFor;
124+
let { waitFor } = tourStep;
126125
if (!waitFor) {
127-
waitFor = isAnyEditable(DOMtarget) ? 'fieldEdition' : 'click'
126+
waitFor = isAnyEditable(DOMtarget) ? 'fieldEdition' : 'click';
128127
}
129128
switch (waitFor) {
130129
case 'click':
@@ -148,9 +147,9 @@ const TutorialBubble = ({
148147
const nextIsVisible = nextDOMtarget?.checkVisibility();
149148

150149
return (
151-
<Box className='tutorials'>
150+
<Box className="tutorials">
152151
<Box
153-
className='tutorials_highlight'
152+
className="tutorials_highlight"
154153
id="tutorialTargetRectangle"
155154
style={{
156155
top: targetRect.top - rectMargin,
@@ -162,25 +161,28 @@ const TutorialBubble = ({
162161
}}
163162
/>
164163

165-
<Box className='tutorials_wrapper' id="tutorialBubble">
166-
{lastCheckRender}
167-
168-
<Box className='tutorials_content' style={{
169-
top: y,
170-
left: x,
171-
}}>
172-
<Typography component='h3'>
164+
<Box className="tutorials_wrapper" id="tutorialBubble">
165+
<Box
166+
className="tutorials_content"
167+
style={{
168+
top: y,
169+
left: x,
170+
}}
171+
>
172+
<Typography component="h3">
173173
{title}
174174
</Typography>
175175

176176
{content}
177177

178-
<Box pt={2.5} display='flex' alignItems='center' justifyContent='space-between'>
178+
<Box pt={2.5} display="flex" alignItems="center" justifyContent="space-between">
179179
<Typography>
180-
{requestedTourStep}/{steps.length}
180+
{requestedTourStep}
181+
/
182+
{steps.length}
181183
</Typography>
182184

183-
<Box display='flex' alignItems='center'>
185+
<Box display="flex" alignItems="center">
184186
<Button
185187
onClick={stop}
186188
color="primary"
@@ -190,7 +192,7 @@ const TutorialBubble = ({
190192

191193
{hasOtherSteps && (
192194
<Button
193-
variant='contained'
195+
variant="contained"
194196
color="primary"
195197
onClick={listen}
196198
disabled={!nextIsVisible}

webapp/components/general/TutorialObserver.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
22
import { useSelector } from 'react-redux';
33
import TutorialBubble from './TutorialBubble';
44

5-
export default function TutorialObserver(props) {
5+
export default function TutorialObserver (props) {
66
const tourRunning = useSelector((state) => state.tutorial.tourRunning);
77
const [observer, setObserver] = useState(null);
88

@@ -16,11 +16,11 @@ export default function TutorialObserver(props) {
1616
validateTutorialStep,
1717
checkBubbleRender,
1818
lastCheckRender,
19-
children
19+
children,
2020
} = props;
2121

2222
const bubbleUpdate = () => {
23-
checkBubbleRender({ epoch: Date.now() })
23+
checkBubbleRender({ epoch: Date.now() });
2424
};
2525

2626
useEffect(() => {
@@ -31,8 +31,9 @@ export default function TutorialObserver(props) {
3131
return;
3232
}
3333
// Listen for new components being added to the DOM
34+
// eslint-disable-next-line no-undef
3435
const obs = new MutationObserver((mutationsList) => {
35-
if(mutationsList.length > 0) {
36+
if (mutationsList.length > 0) {
3637
bubbleUpdate();
3738
}
3839
});
@@ -44,23 +45,22 @@ export default function TutorialObserver(props) {
4445

4546
const startTutorialCallBack = () => {
4647
startTutorialStep();
47-
}
48+
};
4849

4950
const stopTutorial = () => {
5051
stopTutorialStep();
51-
}
52+
};
5253

5354
const doIncrementTutorialStep = () => {
54-
validateTutorialStep({ tourStep: requestedTourStep })
55-
incrementTutorialStep()
56-
}
55+
validateTutorialStep({ tourStep: requestedTourStep });
56+
incrementTutorialStep();
57+
};
5758

5859
return (
5960
<>
6061
{children}
6162
{tourRunning && (
6263
<>
63-
<button onClick={ () => { startTutorialCallBack() }}>RESET TUTORIAL</button>
6464
<TutorialBubble
6565
requestedTourStep={requestedTourStep}
6666
currentTourStep={tourStep}
@@ -70,7 +70,8 @@ export default function TutorialObserver(props) {
7070
validateTutorialStep={validateTutorialStep}
7171
lastCheckRender={lastCheckRender}
7272
/>
73-
</>)}
73+
</>
74+
)}
7475
</>
7576
);
76-
}
77+
}

webapp/dev_package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"react": "^17.0.1",
3434
"react-color": "^2.19.3",
3535
"react-dom": "^16.4.0",
36-
"react-joyride": "^2.5.3",
3736
"react-json-view": "^1.21.3",
3837
"react-redux": "^7.2.0",
3938
"react-sortable-tree": "^2.8.0",

webapp/package.bak

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "MIT",
77
"scripts": {
88
"lint": "eslint . --color --fix",
9-
"build": "webpack --mode production -p --progress --devtool source-map",
9+
"build": "webpack --mode development -p --progress --devtool source-map",
1010
"build-dev": "webpack --mode development --devtool source-map",
1111
"build-dev-noTest": "webpack --mode development --devtool source-map --env.noTest=true",
1212
"build-dev-noTest:watch": "webpack --mode development --devtool source-map --env.noTest=true --progress --watch",
@@ -19,9 +19,9 @@
1919
"@material-ui/core": "4.12.1",
2020
"@material-ui/icons": "^4.11.2",
2121
"@material-ui/lab": "^4.0.0-alpha.60",
22-
"@metacell/geppetto-meta-client": "1.1.0",
23-
"@metacell/geppetto-meta-core": "1.1.0",
24-
"@metacell/geppetto-meta-ui": "1.1.0",
22+
"@metacell/geppetto-meta-client": "1.2.0",
23+
"@metacell/geppetto-meta-core": "1.2.0",
24+
"@metacell/geppetto-meta-ui": "1.2.0",
2525
"@nosferatu500/react-sortable-tree": "3.0.5",
2626
"@sentry/integrations": "^6.16.1",
2727
"@sentry/react": "^6.16.1",

webapp/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"awesome-typescript-loader": "^5.2.1",
6363
"babel-eslint": "^10.0.1",
6464
"babel-loader": "^8.0.6",
65-
"casperjs": "^1.1.4",
6665
"copy-webpack-plugin": "^4.6.0",
6766
"css-loader": "^3.0.0",
6867
"eslint": "^7.20.0",

0 commit comments

Comments
 (0)