Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional confirmation UI before destructive actions #3006

Merged
merged 6 commits into from
Apr 26, 2023
Prev Previous commit
Next Next commit
Display success toast after deleting investigation
  • Loading branch information
tillprochaska committed Apr 24, 2023
commit b3ad267b1b58d1ff860db273058106b73a99cbf5
20 changes: 17 additions & 3 deletions ui/src/dialogs/CollectionDeleteDialog/CollectionDeleteDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
import React, { Component } from 'react';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
import { compose } from 'redux';
import { connect } from 'react-redux';

import { showSuccessToast } from 'app/toast';
import withRouter from 'app/withRouter';
import { deleteCollection } from 'actions';
import { DeleteDialog } from 'components/common';

const messages = defineMessages({
success: {
id: 'collection.delete.success',
defaultMessage: 'Successfully deleted {label}',
},
});

class CollectionDeleteDialog extends Component {
constructor(props) {
super(props);
this.onDelete = this.onDelete.bind(this);
}

async onDelete() {
const { collection, navigate, deleteCollection } = this.props;
const { collection, navigate, deleteCollection, intl } = this.props;
const path = collection.casefile ? '/investigations' : '/datasets';
const successMessage = intl.formatMessage(messages.success, {
label: collection.label,
});

await deleteCollection(collection);
showSuccessToast(successMessage);
navigate({ pathname: path });
}

Expand Down Expand Up @@ -82,5 +95,6 @@ const mapDispatchToProps = { deleteCollection };

export default compose(
withRouter,
connect(null, mapDispatchToProps)
connect(null, mapDispatchToProps),
injectIntl
)(CollectionDeleteDialog);
16 changes: 7 additions & 9 deletions ui/src/dialogs/EntitySetDeleteDialog/EntitySetDeleteDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ class EntitySetDeleteDialog extends Component {
this.onDelete = this.onDelete.bind(this);
}

onDelete() {
const { entitySet, navigate, intl } = this.props;
this.props
.deleteEntitySet(entitySet.id)
.then(() =>
showSuccessToast(
intl.formatMessage(messages.success, { title: entitySet.label })
)
);
async onDelete() {
const { entitySet, navigate, intl, deleteEntitySet } = this.props;
const successMessage = intl.formatMessage(messages.success, {
title: entitySet.label,
});

await deleteEntitySet(entitySet.id);
showSuccessToast(successMessage);
navigate(getCollectionLink({ collection: entitySet.collection }));
}

Expand Down