On 05/13/2013 04:51 PM, Petr Vobornik wrote:
> On 05/07/2013 05:16 PM, Ana Krivokapic wrote:
>> https://fedorahosted.org/freeipa/ticket/3591
> 1) The change from on_success to on_error is causing problems when
> some command in a batch doesn't fail. Ie.: disable multiple users on
> user search facet. Disabling already disabled user causes an error.
> The dialog is shown but the page is not refreshed so the newly
> disabled records are still displayed as enabled. We might even call
> this case a success.
> IMO we shouldn't change the method because the batch itself succeeded.
> The problem should be fixed on caller side (users of batch command).
> 2) Also `ajax` context should be left there instead of `this`,
> otherwise it would get the context of on_ok handler:
> 3) (not an actual issue) Some of my old code doesn't contain space
> between for/if and opening curly bracet, opposite to the rest of the
> Web UI. Spaces should be added when touching these parts of code.

Since the problem occurs in the case when the batch succeeds, but some
commands from the batch fail, it should be enough to modify the message
that is displayed. I modified it so it shows exactly how many items from
the batch succeeded.

Updated patch is attached.


Ana Krivokapic
Associate Software Engineer
FreeIPA team
Red Hat Inc.

From c852a37bcd4138ad21aad34c4f8953796a4de9ae Mon Sep 17 00:00:00 2001
From: Ana Krivokapic <akriv...@redhat.com>
Date: Wed, 15 May 2013 17:33:21 +0200
Subject: [PATCH] Do not display success message on failure in web UI

 install/ui/src/freeipa/search.js   | 4 +++-
 install/ui/test/data/ipa_init.json | 2 +-
 ipalib/plugins/internal.py         | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js
index 8af5a29d3de0b010390fb733072a2ae2b7a7c000..a77f1768c173f17e124474d646cd252ea0debe7c 100644
--- a/install/ui/src/freeipa/search.js
+++ b/install/ui/src/freeipa/search.js
@@ -337,7 +337,9 @@ IPA.search_deleter_dialog = function(spec) {
         batch.on_success = function(data, text_status, xhr) {
-            IPA.notify_success('@i18n:search.deleted');
+            var succeeded = batch.commands.length - batch.errors.errors.length;
+            var msg = text.get('@i18n:search.deleted').replace('${count}', succeeded);
+            IPA.notify_success(msg);
         batch.on_error = function() {
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index d025f6958d644d2382282e8d06458e7770eeebb6..45f5e8e61673b558dbcd9112e95c292e21edd94b 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -521,7 +521,7 @@
                     "search": {
                         "delete_confirm": "Are you sure you want to delete selected entries?",
-                        "deleted": "Selected entries were deleted.",
+                        "deleted": "${count} items were deleted",
                         "disable_confirm": "Are you sure you want to disable selected entries?",
                         "disabled": "${count} items were disabled",
                         "enable_confirm": "Are you sure you want to enable selected entries?",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index d50ffb543f0f35a368f7d18341b1af845786e20a..4c32745ee33389f6d07a060ca8a63752da925d4c 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -657,7 +657,7 @@ class i18n_messages(Command):
         "search": {
             "delete_confirm": _("Are you sure you want to delete selected entries?"),
-            "deleted": _("Selected entries were deleted."),
+            "deleted": _("${count} items were deleted"),
             "disable_confirm": _("Are you sure you want to disable selected entries?"),
             "disabled": _("${count} items were disabled"),
             "enable_confirm": _("Are you sure you want to enable selected entries?"),

Freeipa-devel mailing list

Reply via email to