0
0
Fork 0

Add confirmation modal when closing media edit modal with unsaved changes (#16518)

* Add confirmation modal when closing media edit modal with unsaved changes

* Move focal point media state to redux so it does not get erased by confirmation dialog

* Change upload modal behavior to keep it open while saving changes

Instead of closing it immediately and losing changes if they fail to save…

* Make it work with react-intl 2.9
This commit is contained in:
Claire 2021-07-25 01:14:43 +02:00 committed by GitHub
parent af08229ff4
commit a8a7066e97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 142 additions and 69 deletions

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { closeModal } from '../../../actions/modal';
import { openModal, closeModal } from '../../../actions/modal';
import ModalRoot from '../components/modal_root';
const mapStateToProps = state => ({
@ -8,8 +8,18 @@ const mapStateToProps = state => ({
});
const mapDispatchToProps = dispatch => ({
onClose () {
dispatch(closeModal());
onClose (confirmationMessage) {
if (confirmationMessage) {
dispatch(
openModal('CONFIRM', {
message: confirmationMessage.message,
confirm: confirmationMessage.confirm,
onConfirm: () => dispatch(closeModal()),
}),
);
} else {
dispatch(closeModal());
}
},
});