@@ -7,6 +7,9 @@ import { connect } from 'react-redux';
7
7
import Button from 'app/components/buttons/Button' ;
8
8
import type { PaginatedSandboxes } from 'common/types' ;
9
9
10
+ import modalActionCreators from 'app/store/modal/actions' ;
11
+ import Alert from 'app/components/Alert' ;
12
+
10
13
import SandboxList from 'app/components/sandbox/SandboxList' ;
11
14
import sandboxActionCreators from 'app/store/entities/sandboxes/actions' ;
12
15
@@ -36,6 +39,7 @@ type Props = {
36
39
fetchSandboxes : Function ,
37
40
sandboxes : PaginatedSandboxes ,
38
41
sandboxActions : typeof sandboxActionCreators ,
42
+ modalActions : typeof modalActionCreators ,
39
43
isCurrentUser : boolean ,
40
44
} ;
41
45
@@ -66,13 +70,23 @@ class Sandboxes extends React.PureComponent<Props> {
66
70
return Math . ceil ( sandboxCount / PER_PAGE_COUNT ) ;
67
71
} ;
68
72
69
- deleteSandbox = async ( id : string ) => {
70
- // eslint-disable-next-line no-alert
71
- const really = confirm ( `Are you sure you want to delete this sandbox?` ) ; // TODO: confirm???
72
- if ( really ) {
73
- await this . props . sandboxActions . deleteSandbox ( id ) ;
74
- this . fetch ( true ) ;
75
- }
73
+ deleteSandbox = ( id : string ) => {
74
+ const { modalActions } = this . props ;
75
+
76
+ modalActions . openModal ( {
77
+ Body : (
78
+ < Alert
79
+ title = "Delete Sandbox"
80
+ body = { < span > Are you sure you want to delete this sandbox?</ span > }
81
+ onCancel = { modalActions . closeModal }
82
+ onDelete = { async ( ) => {
83
+ await this . props . sandboxActions . deleteSandbox ( id ) ;
84
+ this . fetch ( true ) ;
85
+ modalActions . closeModal ( ) ;
86
+ } }
87
+ />
88
+ ) ,
89
+ } ) ;
76
90
} ;
77
91
78
92
render ( ) {
@@ -118,10 +132,9 @@ class Sandboxes extends React.PureComponent<Props> {
118
132
}
119
133
}
120
134
121
- const mapStateToProps = ( ) => ( { } ) ;
122
-
123
135
const mapDispatchToProps = dispatch => ( {
124
136
sandboxActions : bindActionCreators ( sandboxActionCreators , dispatch ) ,
137
+ modalActions : bindActionCreators ( modalActionCreators , dispatch ) ,
125
138
} ) ;
126
139
127
- export default connect ( mapStateToProps , mapDispatchToProps ) ( Sandboxes ) ;
140
+ export default connect ( undefined , mapDispatchToProps ) ( Sandboxes ) ;
0 commit comments