Skip to content

Commit aeb506f

Browse files
jseminckCompuIves
authored andcommitted
Show modal instead of alert (codesandbox#216)
* Show modal instead of alert * Delete sandbox instead of Delete File * Close sandbox, remove async, fix prop-types
1 parent 4bf94a8 commit aeb506f

File tree

2 files changed

+24
-11
lines changed
  • src/app/pages

2 files changed

+24
-11
lines changed

src/app/pages/Profile/Sandboxes/index.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { connect } from 'react-redux';
77
import Button from 'app/components/buttons/Button';
88
import type { PaginatedSandboxes } from 'common/types';
99

10+
import modalActionCreators from 'app/store/modal/actions';
11+
import Alert from 'app/components/Alert';
12+
1013
import SandboxList from 'app/components/sandbox/SandboxList';
1114
import 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-
123135
const 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);

src/app/pages/Sandbox/Editor/Workspace/SandboxActions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class SandboxSettings extends React.PureComponent {
5050
modalActions.openModal({
5151
Body: (
5252
<Alert
53-
title="Delete File"
53+
title="Delete Sandbox"
5454
body={<span>Are you sure you want to delete this sandbox?</span>}
5555
onCancel={modalActions.closeModal}
5656
onDelete={() => {

0 commit comments

Comments
 (0)