Notification of success was added to:
 * details facet: update
 * association facet and association widget: add, delete items
* attribute facet: delete items (notification of add should be handled in entity adder dialog)
 * sudo rule: add, remove option
 * dnsrecord: add, update, delete

https://fedorahosted.org/freeipa/ticket/2977
--
Petr Vobornik
From bcd93674450ad3bfbc1e3781cf699692b2928e3c Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Wed, 29 Aug 2012 17:35:07 +0200
Subject: [PATCH] Notify success on add, delete and update

Notification of success was added to:
 * details facet: update
 * association facet and association widget: add, delete items
 * attribute facet: delete items (notification of add should be handled in entity adder dialog)
 * sudo rule: add, remove option
 * dnsrecord: add, update, delete

https://fedorahosted.org/freeipa/ticket/2977
---
 install/ui/add.js                  | 12 ++++++++----
 install/ui/association.js          |  5 +++++
 install/ui/details.js              | 10 ++++++++++
 install/ui/dns.js                  | 17 +++++++++++++----
 install/ui/hbac.js                 |  1 +
 install/ui/netgroup.js             |  1 +
 install/ui/selinux.js              |  1 +
 install/ui/sudo.js                 |  3 +++
 install/ui/test/data/ipa_init.json |  7 ++++++-
 ipalib/plugins/internal.py         |  7 ++++++-
 10 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/install/ui/add.js b/install/ui/add.js
index caa1ab5a0b13e43c8c8988cec027707d45d72333..d855879452e5812c8c7fbae7bc9d1ff9035f1a6e 100644
--- a/install/ui/add.js
+++ b/install/ui/add.js
@@ -52,6 +52,7 @@ IPA.entity_adder_dialog = function(spec) {
                         var facet = IPA.current_entity.get_facet();
                         facet.refresh();
                         that.close();
+                        IPA.notify_success(that.get_success_message());
                     },
                     that.on_error);
             }
@@ -65,10 +66,7 @@ IPA.entity_adder_dialog = function(spec) {
                 that.add(
                     function(data, text_status, xhr) {
                         that.added.notify();
-                        var message = IPA.messages.dialogs.add_confirmation;
-                        message = message.replace('${entity}', that.subject);
-                        that.show_message(message);
-
+                        that.show_message(that.get_success_message());
                         var facet = IPA.current_entity.get_facet();
                         facet.refresh();
                         that.reset();
@@ -88,6 +86,7 @@ IPA.entity_adder_dialog = function(spec) {
                         that.close();
                         var result = data.result.result;
                         that.show_edit_page(that.entity, result);
+                        IPA.notify_success(that.get_success_message());
                     },
                     that.on_error);
             }
@@ -103,6 +102,11 @@ IPA.entity_adder_dialog = function(spec) {
         });
     };
 
+    that.get_success_message = function() {
+        var message = IPA.messages.dialogs.add_confirmation;
+        return  message.replace('${entity}', that.subject);
+    };
+
     function show_edit_page(entity,result) {
         var pkey_name = entity.metadata.primary_key;
         var pkey = result[pkey_name];
diff --git a/install/ui/association.js b/install/ui/association.js
index bb10387a51cd8081147eb6acd02b3b0587f30e56..edba681f0f943e66358c8a9c490ab0e00a96429f 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -571,6 +571,7 @@ IPA.association_table_widget = function (spec) {
                 function() {
                     that.refresh();
                     dialog.close();
+                    IPA.notify_success(IPA.messages.association.added);
                 },
                 function() {
                     that.refresh();
@@ -632,6 +633,7 @@ IPA.association_table_widget = function (spec) {
                 function() {
                     that.refresh();
                     dialog.close();
+                    IPA.notify_success(IPA.messages.association.removed);
                 },
                 function() {
                     that.refresh();
@@ -998,6 +1000,7 @@ IPA.association_facet = function (spec, no_init) {
                 on_success: function() {
                     that.refresh();
                     dialog.close();
+                    IPA.notify_success(IPA.messages.association.added);
                 },
                 on_error: function() {
                     that.refresh();
@@ -1049,6 +1052,7 @@ IPA.association_facet = function (spec, no_init) {
                 on_success: function() {
                     that.refresh();
                     dialog.close();
+                    IPA.notify_success(IPA.messages.association.removed);
                 },
                 on_error: function() {
                     that.refresh();
@@ -1308,6 +1312,7 @@ IPA.attribute_facet = function(spec, no_init) {
                     that.load(data);
                     that.show_content();
                     dialog.close();
+                    IPA.notify_success(IPA.messages.association.removed);
                 },
                 function() {
                     that.refresh();
diff --git a/install/ui/details.js b/install/ui/details.js
index 883bb06bfd56ffd800f1ce60e229bc0c1f4ec1bb..cdb6a82bf9708cffc6fe3bb80ea49bbce9b1bbcd 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -508,10 +508,20 @@ IPA.details_facet = function(spec, no_init) {
         return valid;
     };
 
+    that.nofify_update_success = function() {
+        var msg = IPA.messages.details.updated;
+        var key = that.get_primary_key();
+        key = key[key.length -1] || '';
+        msg = msg.replace('${entity}', that.entity.metadata.label_singular);
+        msg = msg.replace('${primary_key}', key);
+        IPA.notify_success(msg);
+    };
+
 
     that.update_on_success = function(data, text_status, xhr) {
         that.load(data);
         that.on_update.notify();
+        that.nofify_update_success();
     };
 
     that.update_on_error = function(xhr, text_status, error_thrown) {
diff --git a/install/ui/dns.js b/install/ui/dns.js
index 0803fdd3c3761483344aded81613f13235b1b6ff..33db481b84c0518ec1b326f8b016a8e487e3120b 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -384,6 +384,7 @@ IPA.dnszone_details_facet = function(spec, no_init) {
     that.update_on_success = function(data, text_status, xhr) {
         that.refresh();
         that.on_update.notify();
+        that.nofify_update_success();
     };
 
     that.update_on_error = function(xhr, text_status, error_thrown) {
@@ -1815,6 +1816,7 @@ IPA.dns.record_type_table_widget = function(spec) {
                     that.reload_facet(data);
                     dialog.close();
                     that.notify_facet_update();
+                    that.facet.nofify_update_success();
                 },
                 function() {
                     that.refresh_facet();
@@ -1872,6 +1874,13 @@ IPA.dns.record_type_table_widget = function(spec) {
 
         dialog.on_error = IPA.create_4304_error_handler(dialog);
 
+        dialog.get_add_message = function() {
+            var label = that.entity.metadata.label_singular;
+            var message = IPA.messages.dialogs.add_confirmation;
+            message = message.replace('${entity}', label);
+            return message;
+        };
+
         dialog.create_button({
             name: 'add',
             label: IPA.messages.buttons.add,
@@ -1887,6 +1896,7 @@ IPA.dns.record_type_table_widget = function(spec) {
                         }
                         dialog.close();
                         that.notify_facet_update();
+                        IPA.notify_success(dialog.get_add_message());
                     },
                     dialog.on_error);
             }
@@ -1899,10 +1909,8 @@ IPA.dns.record_type_table_widget = function(spec) {
                 dialog.hide_message();
                 dialog.add(
                     function(data, text_status, xhr) {
-                        var label = that.entity.metadata.label_singular;
-                        var message = IPA.messages.dialogs.add_confirmation;
-                        message = message.replace('${entity}', label);
-                        dialog.show_message(message);
+
+                        dialog.show_message(dialog.get_add_message());
 
                         if (data.result.result.dnsrecords) {
                             that.reload_facet(data);
@@ -2003,6 +2011,7 @@ IPA.dns.record_type_table_widget = function(spec) {
                 that.reload_facet(data);
                 dialog.close();
                 that.notify_facet_update();
+                that.facet.nofify_update_success();
             };
             command.on_error = function() {
                 that.refresh_facet();
diff --git a/install/ui/hbac.js b/install/ui/hbac.js
index a3683e7bb434e1102ff4c00d5856516059e696ce..63c928aab495f27b2e8e5fe072fdf105625d9e5d 100644
--- a/install/ui/hbac.js
+++ b/install/ui/hbac.js
@@ -538,6 +538,7 @@ IPA.hbacrule_details_facet = function(spec) {
     that.update_on_success = function(data, text_status, xhr) {
         that.refresh();
         that.on_update.notify();
+        that.nofify_update_success();
     };
 
     that.update_on_error = function(xhr, text_status, error_thrown) {
diff --git a/install/ui/netgroup.js b/install/ui/netgroup.js
index f7dccbeee97bd11f787575dc9b82697bce73a12c..73deec1006413b74b111efbe9a144b71d76b43fc 100644
--- a/install/ui/netgroup.js
+++ b/install/ui/netgroup.js
@@ -293,6 +293,7 @@ IPA.netgroup.details_facet = function(spec) {
     that.update_on_success = function(data, text_status, xhr) {
         that.refresh();
         that.on_update.notify();
+        that.nofify_update_success();
     };
 
     that.update_on_error = function(xhr, text_status, error_thrown) {
diff --git a/install/ui/selinux.js b/install/ui/selinux.js
index c754fabf10c194917468d69bdd67410dc51f763d..ca4700609ce4c940772d7aec08719544666d23b4 100644
--- a/install/ui/selinux.js
+++ b/install/ui/selinux.js
@@ -302,6 +302,7 @@ IPA.selinux_details_facet = function(spec) {
     that.update_on_success = function(data, text_status, xhr) {
         that.refresh();
         that.on_update.notify();
+        that.nofify_update_success();
     };
 
     that.update_on_error = function(xhr, text_status, error_thrown) {
diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index d18415ff6557ff59d47fa40ff8cf66c2acd02f15..ce020b6a2e490a775ed6de870bf8d22dbccb2a18 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -653,6 +653,7 @@ IPA.sudorule_details_facet = function(spec) {
     that.update_on_success = function(data, text_status, xhr) {
         that.refresh();
         that.on_update.notify();
+        that.nofify_update_success();
     };
 
     that.update_on_error = function(xhr, text_status, error_thrown) {
@@ -819,6 +820,7 @@ IPA.sudo.options_section = function(spec) {
                     on_success: function(data) {
                         that.table.load(data.result.result);
                         dialog.close();
+                        IPA.notify_success(IPA.messages.objects.sudorule.option_added);
                     },
                     on_error: function(data) {
                         that.reload();
@@ -880,6 +882,7 @@ IPA.sudo.options_section = function(spec) {
                     }
 
                     dialog.close();
+                    IPA.notify_success(IPA.messages.objects.sudorule.option_removed);
                 },
                 on_error: function(data) {
                     that.reload();
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index ff4c7489d235d0be7a2f1c98371921023a75cfa2..74d01706da5df4019f38dbff6b258002f119f04a 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -31,6 +31,7 @@
                             "memberof": "Add ${entity} ${primary_key} into ${other_entity}",
                             "sourcehost": "Add Source ${other_entity} into ${entity} ${primary_key}"
                         },
+                        "added": "Items added",
                         "direct_membership": "Direct Membership",
                         "indirect_membership": "Indirect Membership",
                         "no_entries": "No entries.",
@@ -45,6 +46,7 @@
                             "memberof": "Remove ${entity} ${primary_key} from ${other_entity}",
                             "sourcehost": "Remove Source ${other_entity} from ${entity} ${primary_key}"
                         },
+                        "removed": "Items removed",
                         "show_results": "Show Results"
                     },
                     "buttons": {
@@ -80,7 +82,8 @@
                         "general": "General",
                         "identity": "Identity Settings",
                         "settings": "${entity} ${primary_key} Settings",
-                        "to_top": "Back to Top"
+                        "to_top": "Back to Top",
+                        "updated": "${entity} ${primary_key} updated"
                     },
                     "dialogs": {
                         "add_confirmation": "${entity} successfully added",
@@ -430,6 +433,8 @@
                             "external": "External",
                             "host": "Access this host",
                             "ipaenabledflag": "Rule status",
+                            "option_added": "Option added",
+                            "option_removed": "Option(s) removed",
                             "options": "Options",
                             "runas": "As Whom",
                             "specified_commands": "Specified Commands and Groups",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 890ebb4523a45bb85767f033c51866683d36a699..26e1b63fbbf2de290cb32142b3e6c8075c84aabb 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -166,6 +166,7 @@ class i18n_messages(Command):
                 "memberof": _("Add ${entity} ${primary_key} into ${other_entity}"),
                 "sourcehost": _("Add Source ${other_entity} into ${entity} ${primary_key}"),
             },
+            "added": _("Items added"),
             "direct_membership": _("Direct Membership"),
             "indirect_membership": _("Indirect Membership"),
             "no_entries": _("No entries."),
@@ -180,6 +181,7 @@ class i18n_messages(Command):
                 "memberof": _("Remove ${entity} ${primary_key} from ${other_entity}"),
                 "sourcehost": _("Remove Source ${other_entity} from ${entity} ${primary_key}"),
             },
+            "removed": _("Items removed"),
             "show_results": _("Show Results"),
         },
         "buttons": {
@@ -215,7 +217,8 @@ class i18n_messages(Command):
             "general": _("General"),
             "identity": _("Identity Settings"),
             "settings": _("${entity} ${primary_key} Settings"),
-            "to_top": _("Back to Top")
+            "to_top": _("Back to Top"),
+            "updated": _("${entity} ${primary_key} updated"),
         },
         "dialogs": {
             "add_confirmation": _("${entity} successfully added"),
@@ -569,6 +572,8 @@ class i18n_messages(Command):
                 "external": _("External"),
                 "host": _("Access this host"),
                 "ipaenabledflag": _("Rule status"),
+                "option_added": _("Option added"),
+                "option_removed": _("Option(s) removed"),
                 "options": _("Options"),
                 "runas": _("As Whom"),
                 "specified_commands": _("Specified Commands and Groups"),
-- 
1.7.11.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to