Skip to content

Commit 196e4e3

Browse files
committed
Added editor hold-off time input in Settings dialog
1 parent 004261d commit 196e4e3

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/SettingsDialog.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import FormGroup from '@material-ui/core/FormGroup';
1111
import FormControlLabel from '@material-ui/core/FormControlLabel';
1212
import Switch from '@material-ui/core/Switch';
1313
import Input from '@material-ui/core/Input';
14+
import InputAdornment from '@material-ui/core/InputAdornment';
1415
import InputLabel from '@material-ui/core/InputLabel';
1516
import MenuItem from '@material-ui/core/MenuItem';
1617
import FormHelperText from '@material-ui/core/FormHelperText';
@@ -37,6 +38,9 @@ const styles = theme => ({
3738
display: 'flex',
3839
justifyContent: 'space-between',
3940
},
41+
holdOffInput: {
42+
width: '7em',
43+
}
4044
});
4145

4246
class SettingsDialog extends React.Component {
@@ -53,6 +57,10 @@ class SettingsDialog extends React.Component {
5357
this.props.onFitGraphSwitchChange(event.target.checked);
5458
};
5559

60+
handleHoldOffChange = (event) => {
61+
this.props.onHoldOffChange(event.target.value);
62+
};
63+
5664
render() {
5765
const { classes } = this.props;
5866
return (
@@ -112,6 +120,30 @@ class SettingsDialog extends React.Component {
112120
/>
113121
</FormGroup>
114122
</DialogContent>
123+
<DialogTitle id="form-dialog-title">Other</DialogTitle>
124+
<DialogContent>
125+
<FormControl
126+
className={classes.formControl}
127+
aria-describedby="holdoff-helper-text"
128+
>
129+
<InputLabel shrink={true}>Editor hold-off time</InputLabel>
130+
<Input
131+
className={classes.holdOffInput}
132+
id="holdoff"
133+
type="number"
134+
value={this.props.holdOff}
135+
onChange={this.handleHoldOffChange}
136+
endAdornment={<InputAdornment position="end"> seconds</InputAdornment>}
137+
inputProps={{
138+
'aria-label': 'Holdoff',
139+
min: 0.0,
140+
max: 9.9,
141+
step: 0.1,
142+
}}
143+
/>
144+
<FormHelperText id="holdoff-helper-text">Time of editor inactivity after which graph rendering starts</FormHelperText>
145+
</FormControl>
146+
</DialogContent>
115147
</Dialog>
116148
</div>
117149
);

src/TextEditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TextEditor extends React.Component {
1717
if (this.pendingChanges === 0) {
1818
this.props.onTextChange(value);
1919
}
20-
}, this.props.holdOff);
20+
}, this.props.holdOff * 1000);
2121
};
2222

2323
render() {

src/pages/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class Index extends React.Component {
5858
defaultNodeAttributes: JSON.parse(localStorage.getItem('defaultNodeAttributes')) || {},
5959
defaultEdgeAttributes: JSON.parse(localStorage.getItem('defaultEdgeAttributes')) || {},
6060
error: null,
61+
holdOff: localStorage.getItem('holdOff') || 0.2,
6162
};
6263
}
6364

@@ -171,6 +172,12 @@ class Index extends React.Component {
171172
});
172173
}
173174

175+
handleHoldOffChange = (holdOff) => {
176+
this.setPersistentState({
177+
holdOff: holdOff,
178+
});
179+
}
180+
174181
handleNodeShapeClick = (shape) => {
175182
let x0 = null;
176183
let y0 = null;
@@ -355,6 +362,8 @@ class Index extends React.Component {
355362
fitGraph={this.state.fitGraph}
356363
onEngineSelectChange={this.handleEngineSelectChange}
357364
onFitGraphSwitchChange={this.handleFitGraphSwitchChange}
365+
holdOff={this.state.holdOff}
366+
onHoldOffChange={this.handleHoldOffChange}
358367
onSettingsClose={this.handleSettingsClose}
359368
/>
360369
<Grid container
@@ -392,7 +401,7 @@ class Index extends React.Component {
392401
dotSrc={this.state.dotSrc}
393402
onTextChange={this.handleTextChange}
394403
error={this.state.error}
395-
holdOff={200}
404+
holdOff={this.state.holdOff}
396405
/>
397406
)}
398407
</div>

0 commit comments

Comments
 (0)