Hello,

please review these patches. First two patches fix two minor bugs in custom_command_multivalued_widget.

The rest of patches add webui for kerberos aliases.

https://fedorahosted.org/freeipa/ticket/5927

--
Pavel^3 Vomacka

From d6e0337fd83a4e337c429ecc23038e7af754312e Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 30 Jun 2016 14:32:27 +0200
Subject: [PATCH 1/6] Change error handling of remove command

The custom_command_multivalued_widget handles remove command error correctly and shows
errror message.

Part of: https://fedorahosted.org/freeipa/ticket/5381
---
 install/ui/src/freeipa/widget.js | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 0972efadb46ac7b5811f4e072121a448618fe434..1f767ed14342bd3bb5c8c7ac5384c34a9b2c3abe 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -1548,8 +1548,11 @@ IPA.custom_command_multivalued_widget = function(spec) {
     /**
      * Called on error of remove command. Override point.
      */
-    that.on_error_remove = function(data) {
-        IPA.notify(data.result.summary, 'error');
+    that.on_error_remove = function(xhr, text_status, error_thrown) {
+        if (error_thrown.message) {
+            var msg = error_thrown.message;
+            IPA.notify(msg, 'error');
+        }
     };
 
     /**
-- 
2.5.5

From a132113a19d92c7c3bb3a6f0fdc3b922009c8f0e Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 30 Jun 2016 14:34:10 +0200
Subject: [PATCH 2/6] Set default confirmation button label to 'Remove'

Part of: https://fedorahosted.org/freeipa/ticket/5831
---
 install/ui/src/freeipa/widget.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 1f767ed14342bd3bb5c8c7ac5384c34a9b2c3abe..c422f8aa9aefdf67a5770ff0b58754e0d3eb9e04 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -1672,7 +1672,8 @@ IPA.custom_command_multivalued_widget = function(spec) {
         var spec = that.remove_dialog_spec || {
             title: title,
             message: message,
-            on_ok: perform_remove
+            on_ok: perform_remove,
+            ok_label: '@i18n:buttons.remove'
         };
 
         that.remove_dialog = IPA.confirm_dialog(spec);
-- 
2.5.5

From d7d6a29361b30e09e4c58451ea3bf21c1bd0168d Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 30 Jun 2016 14:34:33 +0200
Subject: [PATCH 3/6] Add widgets for kerberos aliases

Create own custom_command_multivalued_widget for kerberos aliases.

https://fedorahosted.org/freeipa/ticket/5927
---
 install/ui/src/freeipa/widget.js   | 99 ++++++++++++++++++++++++++++++++++++++
 install/ui/test/data/ipa_init.json |  6 +++
 ipaserver/plugins/internal.py      |  6 +++
 3 files changed, 111 insertions(+)

diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index c422f8aa9aefdf67a5770ff0b58754e0d3eb9e04..96a1643bb87980cce674ef97de45d3f2823cfa3e 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -1793,6 +1793,101 @@ IPA.custom_command_multivalued_widget = function(spec) {
     return that;
 };
 
+IPA.krb_custom_command_multivalued_widget = function (spec) {
+
+    spec = spec || {};
+
+    spec.adder_dialog_spec = spec.adder_dialog_spec || {
+        title: '@i18n:krbaliases.adder_title',
+        fields: [
+            {
+                $type: 'text',
+                name: 'krbprincalname',
+                label: '@i18n:krbaliases.add_krbal_label'
+            }
+        ]
+    };
+
+    var that = IPA.custom_command_multivalued_widget(spec);
+
+    that.create_remove_dialog_title = function(row) {
+        return text.get('@i18n:krbaliases.remove_title');
+    };
+
+    that.create_remove_dialog_message = function(row) {
+        var message = text.get('@i18n:krbaliases.remove_message');
+        message = message.replace('${alias}', row.widget.principal_name);
+
+        return message;
+    };
+
+
+    that.create_remove_args = function(row) {
+        var pkey = that.facet.get_pkey();
+        var krbprincipalname = row.widget.principal_name;
+        krbprincipalname = [ krbprincipalname ];
+
+        var args = [
+            pkey,
+            krbprincipalname
+        ];
+
+        return args;
+    };
+
+    that.create_add_args = function(row) {
+        var pkey = that.facet.get_pkey();
+        var krbprincipalname = that.adder_dialog.get_field('krbprincalname').value;
+
+        var args = [
+            pkey,
+            krbprincipalname
+        ];
+
+        return args;
+    };
+
+    return that;
+};
+
+IPA.krb_principal_widget = function(spec) {
+    spec = spec || {};
+
+    var that = IPA.input_widget();
+
+    that.create = function(container) {
+        that.widget_create(container);
+
+        that.principal_text = $('<span />', {
+            'class': 'krb-principal-name',
+            text: ''
+        }).appendTo(container);
+
+        if (that.undo) {
+            that.create_undo(container);
+        }
+
+        that.create_error_link(container);
+    };
+
+    that.update = function(value) {
+
+        var principal_name = value[0];
+
+        if (!principal_name || principal_name === '') {
+            principal_name = {};
+        }
+
+        that.principal_name = principal_name;
+        that.update_text();
+    };
+
+    that.update_text = function() {
+        that.principal_text.text(that.principal_name);
+    };
+
+    return that;
+};
 
 /**
  * Option widget base
@@ -7048,6 +7143,10 @@ exp.register = function() {
     w.register('multivalued', IPA.multivalued_widget);
     w.register('custom_command_multivalued',
         IPA.custom_command_multivalued_widget);
+    w.register('krb_custom_command_multivalued',
+                            IPA.krb_custom_command_multivalued_widget);
+    w.register('krb_principal',
+                            IPA.krb_principal_widget);
     w.register('password', IPA.password_widget);
     w.register('radio', IPA.radio_widget);
     w.register('select', IPA.select_widget);
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 8768766ed883ea438c422b4286bb73eb757f2c5f..77d6fce4e9ca0cf281d89e09f803d6a1a81c6870 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -170,6 +170,12 @@
                         "remove_create": "Disallow ${other_entity} to create keytab of ${primary_key}",
                         "remove_retrieve": "Disallow ${other_entity} to retrieve keytab of ${primary_key}"
                     },
+                    "krbaliases": {
+                        "adder_title": "Add Kerberos Principal Alias",
+                        "add_krbal_label": "New kerberos principal alias",
+                        "remove_title": "Remove Kerberos Alias",
+                        "remove_message": "Do you want to remove kerberos alias ${alias}?"
+                    },
                     "krbauthzdata": {
                         "inherited": "Inherited from server configuration",
                         "mspac": "MS-PAC",
diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py
index 5c1cfb8855881c9d7e3c19080a47722ba2948a67..ac09d5b4882afafed4f7bf4d3a10ec91c96b79ed 100644
--- a/ipaserver/plugins/internal.py
+++ b/ipaserver/plugins/internal.py
@@ -312,6 +312,12 @@ class i18n_messages(Command):
             "remove_create": _("Disallow ${other_entity} to create keytab of ${primary_key}"),
             "remove_retrieve": _("Disallow ${other_entity} to retrieve keytab of ${primary_key}"),
         },
+        "krbaliases": {
+            "adder_title": _("Add Kerberos Principal Alias"),
+            "add_krbal_label": _("New kerberos principal alias"),
+            "remove_title": _("Remove Kerberos Alias"),
+            "remove_message": _("Do you want to remove kerberos alias ${alias}?"),
+        },
         "krbauthzdata": {
             "inherited": _("Inherited from server configuration"),
             "mspac": _("MS-PAC"),
-- 
2.5.5

From 67094153c773fe500458a1d4270a44dc226aa781 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 30 Jun 2016 14:12:49 +0200
Subject: [PATCH 4/6] Add widget for kerberos aliases to user page

https://fedorahosted.org/freeipa/ticket/5927
---
 install/ui/src/freeipa/user.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js
index d8d22ffbc67adec39a75009cd4de0ebc6500b03c..ac8f256711ffbffc6a0bf8a2ab7800c0356dd021 100644
--- a/install/ui/src/freeipa/user.js
+++ b/install/ui/src/freeipa/user.js
@@ -187,7 +187,14 @@ return {
                         },
                         'uidnumber',
                         'gidnumber',
-                        'krbprincipalname',
+                        {
+                            $type: 'krb_custom_command_multivalued',
+                            name: 'krbprincipalname',
+                            item_name: 'principal',
+                            child_spec: {
+                                $type: 'krb_principal'
+                            }
+                        },
                         {
                             $type: 'datetime',
                             name: 'krbprincipalexpiration'
-- 
2.5.5

From 07c88f304ca67ac56459644af0fd683df72d6000 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 30 Jun 2016 14:13:33 +0200
Subject: [PATCH 5/6] Add widget for kerberos aliases to hosts page

https://fedorahosted.org/freeipa/ticket/5927
---
 install/ui/src/freeipa/host.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/install/ui/src/freeipa/host.js b/install/ui/src/freeipa/host.js
index ba8d0f2a5a7e9903bd8f810e6bd23125a0ec2cc5..7ddb269003b3af6f50c6833c9a6bd363009a34cf 100644
--- a/install/ui/src/freeipa/host.js
+++ b/install/ui/src/freeipa/host.js
@@ -88,7 +88,14 @@ return {
                             name: 'fqdn',
                             other_entity: 'dnsrecord'
                         },
-                        'krbprincipalname',
+                        {
+                            $type: 'krb_custom_command_multivalued',
+                            name: 'krbprincipalname',
+                            item_name: 'principal',
+                            child_spec: {
+                                $type: 'krb_principal'
+                            }
+                        },
                         {
                             $type: 'textarea',
                             name: 'description'
-- 
2.5.5

From 6bf1fe633fe5bac4c2611a1830706a8d09324fcb Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 30 Jun 2016 14:13:53 +0200
Subject: [PATCH 6/6] Add widget for kerberos aliases to service page

Also changes the name of option which is send during adding new service from
'krbprincipalname' to 'krbcanonicalname'.

https://fedorahosted.org/freeipa/ticket/5927
---
 install/ui/src/freeipa/service.js | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/install/ui/src/freeipa/service.js b/install/ui/src/freeipa/service.js
index a9a4c1bcb91ede1d388014a80749d215a8840c12..1cc8953cd7bf59c024858ec3f6580c7a17857d77 100644
--- a/install/ui/src/freeipa/service.js
+++ b/install/ui/src/freeipa/service.js
@@ -58,7 +58,7 @@ return {
     facets: [
         {
             $type: 'search',
-            columns: [ 'krbprincipalname' ]
+            columns: [ 'krbcanonicalname' ]
         },
         {
             $type: 'details',
@@ -67,7 +67,14 @@ return {
                 {
                     name: 'details',
                     fields: [
-                        'krbprincipalname',
+                        {
+                            $type: 'krb_custom_command_multivalued',
+                            name: 'krbprincipalname',
+                            item_name: 'principal',
+                            child_spec: {
+                                $type: 'krb_principal'
+                            }
+                        },
                         {
                             name: 'service',
                             label: '@i18n:objects.service.service',
@@ -435,14 +442,14 @@ IPA.service_adder_dialog = function(spec) {
 
     var init = function() {
 
-        //small hack - krbprincipalname should not be displayed. This way
+        //small hack - krbcanonicalname should not be displayed. This way
         //creation of associated widget is skipped.
         //In future it would be better split section definion into widget and
         //fields definition and create custom field with two associated
         //widgets - 'service' and 'host' with this dialog's save logic.
         that.builder.build_field({
             $type: 'field',
-            name: 'krbprincipalname',
+            name: 'krbcanonicalname',
             required: false
         });
     };
@@ -455,7 +462,7 @@ IPA.service_adder_dialog = function(spec) {
         field = that.fields.get_field('host');
         var host = field.save()[0];
 
-        record['krbprincipalname'] = [ service+'/'+host ];
+        record['krbcanonicalname'] = [ service+'/'+host ];
 
         field = that.fields.get_field('force');
         record['force'] = field.save();
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to