about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/ui/containers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-07-25 01:14:43 +0200
committerClaire <claire.github-309c@sitedethib.com>2021-07-25 12:59:03 +0200
commit34a573ac27fe9d5fb324d8910759cd2233911646 (patch)
tree85f33e297d5ad25d06568a0ce14aa80ee09b06e7 /app/javascript/flavours/glitch/features/ui/containers
parent08139d3cd72f28b7c4199f1123ab149651800f2c (diff)
[Glitch] Add confirmation modal when closing media edit modal with unsaved changes
Port a8a7066e977cb0aa1988d340ef8b7c542f179b14 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/features/ui/containers')
-rw-r--r--app/javascript/flavours/glitch/features/ui/containers/modal_container.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/javascript/flavours/glitch/features/ui/containers/modal_container.js b/app/javascript/flavours/glitch/features/ui/containers/modal_container.js
index e13e745e6..039aabd8a 100644
--- a/app/javascript/flavours/glitch/features/ui/containers/modal_container.js
+++ b/app/javascript/flavours/glitch/features/ui/containers/modal_container.js
@@ -1,5 +1,5 @@
 import { connect } from 'react-redux';
-import { closeModal } from 'flavours/glitch/actions/modal';
+import { openModal, closeModal } from 'flavours/glitch/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());
+    }
   },
 });