ad0d0f
From abe2dd0796e77eafca439f35e61ae743b7ac4b16 Mon Sep 17 00:00:00 2001
ad0d0f
From: Serhii Tsymbaliuk <stsymbal@redhat.com>
ad0d0f
Date: Wed, 13 May 2020 15:54:17 +0200
ad0d0f
Subject: [PATCH] WebUI: Add confirmation dialog for changing default user/host
ad0d0f
 group
ad0d0f
ad0d0f
Changing default group on automember rules page is too easy.
ad0d0f
Add a confirmation dialog to avoid misclick in the case.
ad0d0f
ad0d0f
Ticket: https://pagure.io/freeipa/issue/8322
ad0d0f
ad0d0f
Signed-off-by: Serhii Tsymbaliuk <stsymbal@redhat.com>
ad0d0f
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
ad0d0f
---
ad0d0f
 install/ui/src/freeipa/automember.js | 21 ++++++++++++++++-----
ad0d0f
 ipaserver/plugins/internal.py        |  3 +++
ad0d0f
 2 files changed, 19 insertions(+), 5 deletions(-)
ad0d0f
ad0d0f
diff --git a/install/ui/src/freeipa/automember.js b/install/ui/src/freeipa/automember.js
ad0d0f
index a1d56a1b15244d81506c20284bb8341ab5e30d59..7223d0fa9a283a28dc985526375744805dc4f8b2 100644
ad0d0f
--- a/install/ui/src/freeipa/automember.js
ad0d0f
+++ b/install/ui/src/freeipa/automember.js
ad0d0f
@@ -594,11 +594,22 @@ IPA.automember.default_group_widget = function(spec) {
ad0d0f
 
ad0d0f
         if (group === that.group) return;
ad0d0f
 
ad0d0f
-        if (group === '') {
ad0d0f
-            that.remove_default_group();
ad0d0f
-        } else {
ad0d0f
-            that.set_default_group(group);
ad0d0f
-        }
ad0d0f
+        var dialog = IPA.confirm_dialog({
ad0d0f
+            title: that.get_title(),
ad0d0f
+            message: text.get('@i18n:objects.automember.default_group_confirm'),
ad0d0f
+            on_ok: function() {
ad0d0f
+                if (group === '') {
ad0d0f
+                    that.remove_default_group();
ad0d0f
+                } else {
ad0d0f
+                    that.set_default_group(group);
ad0d0f
+                }
ad0d0f
+            },
ad0d0f
+            on_cancel: function() {
ad0d0f
+                that.group_select.update([that.group]);
ad0d0f
+            }
ad0d0f
+        });
ad0d0f
+
ad0d0f
+        dialog.open();
ad0d0f
     };
ad0d0f
 
ad0d0f
     that.load = function(data) {
ad0d0f
diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py
ad0d0f
index c293e0b5e06677f09daa4b820ffd06a2671cd6e1..8588a7198c7def6727ba33d0b80b9e0be5cae701 100644
ad0d0f
--- a/ipaserver/plugins/internal.py
ad0d0f
+++ b/ipaserver/plugins/internal.py
ad0d0f
@@ -363,6 +363,9 @@ class i18n_messages(Command):
ad0d0f
                 "add_condition": _("Add Condition into ${pkey}"),
ad0d0f
                 "add_rule": _("Add Rule"),
ad0d0f
                 "attribute": _("Attribute"),
ad0d0f
+                "default_group_confirm": _(
ad0d0f
+                    "Are you sure you want to change default group?"
ad0d0f
+                ),
ad0d0f
                 "default_host_group": _("Default host group"),
ad0d0f
                 "default_user_group": _("Default user group"),
ad0d0f
                 "exclusive": _("Exclusive"),
ad0d0f
-- 
ad0d0f
2.34.3
ad0d0f