Blob Blame History Raw
From 8dcaa8f17b94fd7056340622e49d8ab505694603 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvoborni@redhat.com>
Date: Wed, 15 Jan 2014 18:01:02 +0100
Subject: [PATCH] Trust domains Web UI

Add Web UI counterpart of following CLI commands:

* trust-fetch-domains Refresh list of the domains associated with the trust
* trustdomain-del Remove infromation about the domain associated with the trust.
* trustdomain-disable Disable use of IPA resources by the domain of the trust
* trustdomain-enable Allow use of IPA resources by the domain of the trust
* trustdomain-find Search domains of the trust

https://fedorahosted.org/freeipa/ticket/4119
---
 install/ui/src/freeipa/search.js   | 11 +++---
 install/ui/src/freeipa/trust.js    | 68 ++++++++++++++++++++++++++++++++++++++
 install/ui/test/data/ipa_init.json |  1 +
 ipalib/plugins/internal.py         |  1 +
 4 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js
index c2e678a35e7d7d5179c1b766eea88599710593c3..3f7fdf9b1e6716c73e0657dc678abe332f6fc8c0 100644
--- a/install/ui/src/freeipa/search.js
+++ b/install/ui/src/freeipa/search.js
@@ -470,20 +470,23 @@ IPA.batch_items_action = function(spec) {
     that.execute_action = function(facet, on_success, on_error) {
 
         var entity = facet.managed_entity;
-        var pkeys = facet.get_selected_values();
+        var selected_keys = facet.get_selected_values();
+        var pkeys = facet.get_pkeys();
+        if (!pkeys[0]) pkeys = []; // correction for search facet
 
         that.batch = IPA.batch_command({
             name: entity.name + '_batch_'+ that.method,
             on_success: that.get_on_success(facet, on_success)
         });
 
-        for (var i=0; i<pkeys.length; i++) {
-            var pkey = pkeys[i];
+        for (var i=0; i<selected_keys.length; i++) {
+            var item_keys = pkeys.splice(0);
+            item_keys.push(selected_keys[i]);
 
             var command = IPA.command({
                 entity: entity.name,
                 method: that.method,
-                args: [pkey]
+                args: item_keys
             });
 
             that.batch.add_command(command);
diff --git a/install/ui/src/freeipa/trust.js b/install/ui/src/freeipa/trust.js
index 2653d3e67c2c5591f000e32c43a3a5878eef28fd..51f2000b47fd7943cb9a200c9bec7ebd3459178a 100644
--- a/install/ui/src/freeipa/trust.js
+++ b/install/ui/src/freeipa/trust.js
@@ -48,6 +48,7 @@ return {
             dest_facet: 'search'
         }
     ],
+    facet_groups: [ 'settings', 'trustdomain' ],
     facets: [
         {
             $type: 'search',
@@ -56,6 +57,63 @@ return {
             ]
         },
         {
+            $type: 'nested_search',
+            $pre_ops: [
+                // trustdomain-add is hidden, remove add button
+                { $del: [[ 'control_buttons', [{ name: 'add'}] ]] }
+            ],
+            nested_entity: 'trustdomain',
+            facet_group: 'trustdomain',
+            name: 'domains',
+            label: '@mo:trustdomain.label',
+            tab_label: '@mo:trustdomain.label',
+            search_all_entries: true,
+            actions: [
+                {
+                    $type: 'batch_disable'
+                },
+                {
+                    $type: 'batch_enable'
+                },
+                {
+                    $type: 'object',
+                    name: 'fetch',
+                    label: '@i18n:objects.trust.fetch_domains',
+                    method: 'fetch_domains'
+                }
+            ],
+            control_buttons: [
+                {
+                    name: 'disable',
+                    label: '@i18n:buttons.disable',
+                    icon: 'fa-minus'
+                },
+                {
+                    name: 'enable',
+                    label: '@i18n:buttons.enable',
+                    icon: 'fa-check'
+                },
+                {
+                    name: 'fetch',
+                    label: '@i18n:objects.trust.fetch_domains',
+                    icon: 'fa-download'
+                }
+            ],
+            columns: [
+                {
+                    name: 'cn',
+                    link: false
+                },
+                {
+                    name: 'domain_enabled',
+                    label: '@i18n:status.label',
+                    formatter: 'boolean_status'
+                },
+                'ipantflatname',
+                'ipanttrusteddomainsid'
+            ]
+        },
+        {
             $type: 'details',
             sections: [
                 {
@@ -261,6 +319,13 @@ IPA.trust.adder_dialog = function(spec) {
     return that;
 };
 
+
+var make_trustdomain_spec = function() {
+return {
+    name: 'trustdomain',
+    containing_entity: 'trust'
+};};
+
 var make_trustconfig_spec = function() {
 return {
     name: 'trustconfig',
@@ -349,14 +414,17 @@ exp.remove_menu_item = function() {
 };
 
 exp.trust_spec = make_trust_spec();
+exp.trustdomain_spec = make_trustdomain_spec();
 exp.trustconfig_spec = make_trustconfig_spec();
 
+
 IPA.trust.register = function() {
     var e = reg.entity;
     var w = reg.widget;
     var f = reg.field;
 
     e.register({type: 'trust', spec: exp.trust_spec});
+    e.register({type: 'trustdomain', spec: exp.trustdomain_spec});
     e.register({type: 'trustconfig', spec: exp.trustconfig_spec});
 
     w.register('trust_fallbackgroup_select', IPA.trust.fallbackgroup_select_widget);
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 8e0b2a33cc45d2a68878b7f3ab49b1491ae7c3f5..80a1c08ed3745bdce44676c6f2716e207f653e8d 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -464,6 +464,7 @@
                             "details": "Trust Settings",
                             "domain": "Domain",
                             "establish_using": "Establish using",
+                            "fetch_domains": "Fetch domains",
                             "ipantflatname": "Domain NetBIOS name",
                             "ipanttrusteddomainsid": "Domain Security Identifier",
                             "preshared_password": "Pre-shared password",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 83b505dae1c6349097f7ad5ed20ab25b5a262aa8..dbd40f91ef2b84beb1bb521dcbcdb059cd3b3c7e 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -600,6 +600,7 @@ class i18n_messages(Command):
                 "details": _("Trust Settings"),
                 "domain": _("Domain"),
                 "establish_using": _("Establish using"),
+                "fetch_domains": _("Fetch domains"),
                 "ipantflatname": _("Domain NetBIOS name"),
                 "ipanttrusteddomainsid": _("Domain Security Identifier"),
                 "preshared_password": _("Pre-shared password"),
-- 
1.8.4.2