From 8ca5793160cf24268c405e51b0bb8ce267608b6b Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Tue, 24 Jun 2014 10:39:16 +0200 Subject: webui: add confirmation for dns zone permission actions All header actions should require confirmation. Reviewed-By: Endi Sukma Dewata --- install/ui/src/freeipa/dns.js | 48 +++++++------------------------------- install/ui/test/data/ipa_init.json | 4 +++- ipalib/plugins/internal.py | 2 ++ 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/install/ui/src/freeipa/dns.js b/install/ui/src/freeipa/dns.js index a54985d52..9ec255f57 100644 --- a/install/ui/src/freeipa/dns.js +++ b/install/ui/src/freeipa/dns.js @@ -581,29 +581,13 @@ IPA.dns.add_permission_action = function(spec) { spec = spec || {}; spec.name = spec.name || 'add_permission'; + spec.method = spec.method || 'add_permission'; spec.label = spec.label || '@i18n:objects.dnszone.add_permission'; spec.enable_cond = spec.enable_cond || ['permission-none', 'managedby_w']; + spec.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : true; + spec.confirm_msg = spec.confirm_msg || '@i18n:objects.dnszone.add_permission_confirm'; - var that = IPA.action(spec); - - that.execute_action = function(facet) { - - var pkey = facet.get_pkey(); - - var command = rpc.command({ - entity: 'dnszone', - method: 'add_permission', - args: [pkey], - options: {}, - on_success: function(data, text_status, xhr) { - facet.refresh(); - IPA.notify_success(data.result.summary); - } - }); - - command.execute(); - }; - + var that = IPA.object_action(spec); return that; }; @@ -611,29 +595,13 @@ IPA.dns.remove_permission_action = function(spec) { spec = spec || {}; spec.name = spec.name || 'remove_permission'; + spec.method = spec.method || 'remove_permission'; spec.label = spec.label || '@i18n:objects.dnszone.remove_permission'; spec.enable_cond = spec.enable_cond || ['permission-set', 'managedby_w']; + spec.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : true; + spec.confirm_msg = spec.confirm_msg || '@i18n:objects.dnszone.remove_permission_confirm'; - var that = IPA.action(spec); - - that.execute_action = function(facet) { - - var pkey = facet.get_pkey(); - - var command = rpc.command({ - entity: 'dnszone', - method: 'remove_permission', - args: [pkey], - options: {}, - on_success: function(data, text_status, xhr) { - facet.refresh(); - IPA.notify_success(data.result.summary); - } - }); - - command.execute(); - }; - + var that = IPA.object_action(spec); return that; }; diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json index 2ce5120e9..daba71b9a 100644 --- a/install/ui/test/data/ipa_init.json +++ b/install/ui/test/data/ipa_init.json @@ -283,7 +283,9 @@ "dnszone": { "identity": "DNS Zone Settings", "add_permission": "Add Permission", - "remove_permission": "Remove Permission" + "add_permission_confirm":"Are you sure you want to add permission for DNS Zone ${object}?", + "remove_permission": "Remove Permission", + "remove_permission_confirm": "Are you sure you want to remove permission for DNS Zone ${object}?" }, "group": { "details": "Group Settings", diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py index 4a3745ae7..f9ae831dc 100644 --- a/ipalib/plugins/internal.py +++ b/ipalib/plugins/internal.py @@ -422,7 +422,9 @@ class i18n_messages(Command): "dnszone": { "identity": _("DNS Zone Settings"), "add_permission":_("Add Permission"), + "add_permission_confirm":_("Are you sure you want to add permission for DNS Zone ${object}?"), "remove_permission": _("Remove Permission"), + "remove_permission_confirm": _("Are you sure you want to remove permission for DNS Zone ${object}?"), }, "group": { "details": _("Group Settings"), -- cgit