-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathmodal.js
56 lines (51 loc) · 1.44 KB
/
modal.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
import React from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
import ModalBody from 'components/OptionsModal';
export function showOptionsModal({ setModalData }) {
return new Promise((resolve, reject) => {
setModalData({
title: 'Options',
body: <ModalBody />,
visible: true,
cancelClick: reject,
actions: [],
});
});
}
export function showChooseCollectionModal({ collections, setModalData }) {
return new Promise((resolve, reject) => {
let selectedIndex = 0;
setModalData({
title: 'Select collections',
body: (
<div>
<FormGroup controlId="formControlsSelect">
<ControlLabel>
Which collection would you like to save this request to?
</ControlLabel>
<FormControl
componentClass="select"
onChange={e => { selectedIndex = e.target.value; }}
autoFocus
>
{collections.map((collection, index) => (
<option
value={index}
key={collection.get('id')}
>
{collection.get('name')}
</option>
))}
</FormControl>
</FormGroup>
</div>
),
visible: true,
cancelClick: reject,
actions: [{
text: 'Save',
click: () => resolve(selectedIndex),
}],
});
});
}