-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathConfigOverlay.js
66 lines (59 loc) · 2.17 KB
/
ConfigOverlay.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* eslint-disable no-unused-vars */
import React, { useState } from 'camunda-modeler-plugin-helpers/react';
import { Overlay, Section } from 'camunda-modeler-plugin-helpers/components';
const OFFSET = { right: 0 };
// we can even use hooks to render into the application
export default function ConfigOverlay({ anchor, initValues, onClose }) {
const [ enabled, setEnabled ] = useState(initValues.enabled);
const [ interval, setAutoSaveInterval ] = useState(initValues.interval);
const onSubmit = () => onClose({ enabled, interval });
// we can use the built-in styles, e.g. by adding "btn btn-primary" class names
return (
<Overlay anchor={ anchor } onClose={ onClose } offset={ OFFSET }>
<Section>
<Section.Header>Auto save configuration</Section.Header>
<Section.Body>
<form id="autoSaveConfigForm" onSubmit={ onSubmit }>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input
name="enabled"
className="custom-control-input"
id="enabled"
type="checkbox"
onChange={ () => setEnabled(!enabled) }
value={ enabled }
defaultChecked={ enabled } />
<label className="custom-control-label" htmlFor="enabled">
Enabled
</label>
</div>
</div>
<div className="form-group">
<label htmlFor="interval">Interval (seconds)</label>
<input
type="number"
className="form-control"
name="interval"
min="1"
value={ interval }
onChange={ (event) =>
setAutoSaveInterval(Number(event.target.value))
}
/>
</div>
</form>
<Section.Actions>
<button
type="submit"
className="btn btn-primary"
form="autoSaveConfigForm"
>
Save
</button>
</Section.Actions>
</Section.Body>
</Section>
</Overlay>
);
}