change(ui) - project delete moved to modal
This commit is contained in:
parent
c3bb5aeb07
commit
c4b371507d
1 changed files with 20 additions and 4 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { Input, Button, Label } from 'UI';
|
||||
import { save, edit, update , fetchList } from 'Duck/site';
|
||||
import { Input, Button, Icon } from 'UI';
|
||||
import { save, edit, update , fetchList, remove } from 'Duck/site';
|
||||
import { pushNewSite } from 'Duck/user';
|
||||
import { setSiteId } from 'Duck/site';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import styles from './siteForm.css';
|
||||
import { confirm } from 'UI/Confirmation';
|
||||
|
||||
@connect(state => ({
|
||||
site: state.getIn([ 'site', 'instance' ]),
|
||||
|
|
@ -13,6 +14,7 @@ import styles from './siteForm.css';
|
|||
loading: state.getIn([ 'site', 'save', 'loading' ]),
|
||||
}), {
|
||||
save,
|
||||
remove,
|
||||
edit,
|
||||
update,
|
||||
pushNewSite,
|
||||
|
|
@ -52,6 +54,17 @@ export default class NewSiteForm extends React.PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
remove = async (site) => {
|
||||
if (await confirm({
|
||||
header: 'Projects',
|
||||
confirmation: `Are you sure you want to delete this Project? We won't be able to record anymore sessions.`
|
||||
})) {
|
||||
this.props.remove(site.id).then(() => {
|
||||
this.props.onClose(null)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
edit = ({ target: { name, value } }) => {
|
||||
this.setState({ existsError: false });
|
||||
this.props.edit({ [ name ]: value });
|
||||
|
|
@ -72,7 +85,7 @@ export default class NewSiteForm extends React.PureComponent {
|
|||
className={ styles.input }
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<div className="mt-6 flex justify-between">
|
||||
<Button
|
||||
primary
|
||||
type="submit"
|
||||
|
|
@ -80,7 +93,10 @@ export default class NewSiteForm extends React.PureComponent {
|
|||
loading={ loading }
|
||||
content={site.exists() ? 'Update' : 'Add'}
|
||||
/>
|
||||
</div>
|
||||
<Button type="button" plain onClick={() => this.remove(site)}>
|
||||
<Icon name="trash" size="16" />
|
||||
</Button>
|
||||
</div>
|
||||
{ this.state.existsError &&
|
||||
<div className={ styles.errorMessage }>
|
||||
{ "Site exists already. Please choose another one." }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue