Skip to content

Commit 7583204

Browse files
committed
fix(GeneralSettings): warn user before deleting project
1 parent c8c65d2 commit 7583204

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

lib/manager/components/GeneralSettings.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import ReactDOM from 'react-dom'
44
import DateTimeField from 'react-bootstrap-datetimepicker'
55
import update from 'react-addons-update'
66
import { shallowEqual } from 'react-pure-render'
7+
import { browserHistory } from 'react-router'
78
import moment from 'moment'
89
import { Row, Col, Button, Panel, Glyphicon, Checkbox, FormGroup, InputGroup, ControlLabel, FormControl, ListGroup, ListGroupItem } from 'react-bootstrap'
910

11+
import ConfirmModal from '../../common/components/ConfirmModal'
1012
import { getMessage, getComponentMessages } from '../../common/util/config'
1113
import TimezoneSelect from '../../common/components/TimezoneSelect'
1214
import LanguageSelect from '../../common/components/LanguageSelect'
@@ -26,14 +28,25 @@ export default class GeneralSettings extends Component {
2628
shouldComponentUpdate (nextProps, nextState) {
2729
return !shallowEqual(nextProps, this.props) || !shallowEqual(nextState, this.state)
2830
}
31+
confirmDeleteProject (project, messages) {
32+
this.refs.confirm.open({
33+
title: 'Delete Project?',
34+
body: 'Are you sure you want to delete this project? This action cannot be undone and all feed sources and their versions will be permanently deleted.',
35+
onConfirm: () => {
36+
this.props.deleteProject(project)
37+
.then(() => browserHistory.push(`/home`))
38+
}
39+
})
40+
}
2941
render () {
3042
const messages = getComponentMessages('ProjectSettings')
31-
const { project, editDisabled, updateProjectSettings, deleteProject } = this.props
43+
const { project, editDisabled, updateProjectSettings } = this.props
3244
const noEdits = Object.keys(this.state.general).length === 0 && this.state.general.constructor === Object
3345
const autoFetchChecked = typeof this.state.general.autoFetchFeeds !== 'undefined' ? this.state.general.autoFetchFeeds : project.autoFetchFeeds
3446
const DEFAULT_FETCH_TIME = moment().startOf('day').add(2, 'hours')
3547
return (
3648
<div className='general-settings-panel'>
49+
<ConfirmModal ref='confirm' />
3750
<Panel header={<h4>{getMessage(messages, 'title')}</h4>}>
3851
<ListGroup fill>
3952
<ListGroupItem>
@@ -227,9 +240,11 @@ export default class GeneralSettings extends Component {
227240
<Panel bsStyle='danger' header={<h3>Danger zone</h3>}>
228241
<ListGroup fill>
229242
<ListGroupItem>
230-
<Button onClick={() => deleteProject(project)} className='pull-right' bsStyle='danger'><Icon type='trash' /> Delete organization</Button>
231-
<h4>Delete this organization.</h4>
232-
<p>Once you delete an organization, the organization and all feed sources it contains cannot be recovered.</p>
243+
<Button onClick={() => this.confirmDeleteProject(project, messages)} className='pull-right' bsStyle='danger'>
244+
<Icon type='trash' /> Delete project
245+
</Button>
246+
<h4>Delete this project.</h4>
247+
<p>Once you delete an project, the project and all feed sources it contains cannot be recovered.</p>
233248
</ListGroupItem>
234249
</ListGroup>
235250
</Panel>

0 commit comments

Comments
 (0)