@@ -7,6 +7,9 @@ import { connect } from 'react-redux';
77import Button from 'app/components/buttons/Button' ;
88import type { PaginatedSandboxes } from 'common/types' ;
99
10+ import modalActionCreators from 'app/store/modal/actions' ;
11+ import Alert from 'app/components/Alert' ;
12+
1013import SandboxList from 'app/components/sandbox/SandboxList' ;
1114import sandboxActionCreators from 'app/store/entities/sandboxes/actions' ;
1215
@@ -36,6 +39,7 @@ type Props = {
3639 fetchSandboxes : Function ,
3740 sandboxes : PaginatedSandboxes ,
3841 sandboxActions : typeof sandboxActionCreators ,
42+ modalActions : typeof modalActionCreators ,
3943 isCurrentUser : boolean ,
4044} ;
4145
@@ -66,13 +70,23 @@ class Sandboxes extends React.PureComponent<Props> {
6670 return Math . ceil ( sandboxCount / PER_PAGE_COUNT ) ;
6771 } ;
6872
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+ } ) ;
7690 } ;
7791
7892 render ( ) {
@@ -118,10 +132,9 @@ class Sandboxes extends React.PureComponent<Props> {
118132 }
119133}
120134
121- const mapStateToProps = ( ) => ( { } ) ;
122-
123135const mapDispatchToProps = dispatch => ( {
124136 sandboxActions : bindActionCreators ( sandboxActionCreators , dispatch ) ,
137+ modalActions : bindActionCreators ( modalActionCreators , dispatch ) ,
125138} ) ;
126139
127- export default connect ( mapStateToProps , mapDispatchToProps ) ( Sandboxes ) ;
140+ export default connect ( undefined , mapDispatchToProps ) ( Sandboxes ) ;
0 commit comments