On 17.10.2014 22:51, Endi Sukma Dewata wrote:
On 10/10/2014 6:45 AM, Petr Vobornik wrote:
https://fedorahosted.org/freeipa/ticket/4616


This patch does not apply. Does it depend on another patch?


rebased version attached. Should be applicable on master, ipa-4-1 and patchset 767-770.
--
Petr Vobornik
From 033e88fb5d75092732d07449b76c0b9c3987456a Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 10 Oct 2014 10:50:56 +0200
Subject: [PATCH] webui: do not offer ipa users to Default Trust View

https://fedorahosted.org/freeipa/ticket/4616
---
 install/ui/doc/categories.json     |  6 +++++
 install/ui/src/freeipa/add.js      |  2 +-
 install/ui/src/freeipa/idviews.js  | 51 +++++++++++++++++++++++++++++++++++++-
 install/ui/test/data/ipa_init.json |  6 +++--
 ipalib/plugins/internal.py         |  2 ++
 5 files changed, 63 insertions(+), 4 deletions(-)

diff --git a/install/ui/doc/categories.json b/install/ui/doc/categories.json
index e9507795b9557880cfb4ce34c0808b6bd2d2ab2c..c84077682eafa42981e8a1c1a2f93c712e6421fd 100644
--- a/install/ui/doc/categories.json
+++ b/install/ui/doc/categories.json
@@ -149,6 +149,12 @@
                 ]
             },
             {
+                "name": "Dialog policies",
+                "classes": [
+                    "idviews.idoverride_adder_policy"
+                ]
+            },
+            {
                 "name": "Evaluators & Summaries",
                 "classes": [
                     "*_evaluator",
diff --git a/install/ui/src/freeipa/add.js b/install/ui/src/freeipa/add.js
index 7f5c29807bae8cc9db00e4e826a68facd1e5758a..8f24c7733d1614aaf05b544ecfb641ff57f292f2 100644
--- a/install/ui/src/freeipa/add.js
+++ b/install/ui/src/freeipa/add.js
@@ -198,7 +198,7 @@ IPA.entity_adder_dialog = function(spec) {
             var field = fields[j];
 
             var values = record[field.param];
-            if (!values || values.length === 0) continue;
+            if (!values || values.length === 0 || !field.enabled) continue;
             if (field.flags.indexOf('no_command') > -1) continue;
 
             if (field.param === pkey_name) {
diff --git a/install/ui/src/freeipa/idviews.js b/install/ui/src/freeipa/idviews.js
index 1d082c4d4918c9ce70535febb6c9e5bf18a7d4b5..cbc78ae7c62916b6334a8ef0cdf12a92485b0876 100644
--- a/install/ui/src/freeipa/idviews.js
+++ b/install/ui/src/freeipa/idviews.js
@@ -20,6 +20,7 @@
  */
 
 define([
+        'dojo/on',
         './ipa',
         './jquery',
         './menu',
@@ -31,7 +32,7 @@ define([
         './facet',
         './search',
         './entity'],
-            function(IPA, $, menu, phases, reg, rpc, text, mod_details, mod_facet) {
+            function(on, IPA, $, menu, phases, reg, rpc, text, mod_details, mod_facet) {
 /**
  * ID Views module
  * @class
@@ -268,6 +269,9 @@ return {
     ],
 
     adder_dialog: {
+        policies: [
+            { $factory: idviews.idoverride_adder_policy }
+        ],
         fields: [
             {
                 $type: 'entity_select',
@@ -278,6 +282,14 @@ return {
                 editable: true,
                 tooltip: '@i18n:objects.idoverrideuser.anchor_tooltip'
             },
+            {
+                label: '@i18n:objects.idoverrideuser.anchor_label',
+                name: 'ipaanchoruuid_default',
+                param: 'ipaanchoruuid',
+                tooltip: '@i18n:objects.idoverrideuser.anchor_tooltip_ad',
+                visible: false,
+                enabled: false
+            },
             'uid',
             'gecos',
             'uidnumber',
@@ -341,6 +353,9 @@ return {
     ],
 
     adder_dialog: {
+        policies: [
+            { $factory: idviews.idoverride_adder_policy }
+        ],
         fields: [
              {
                 $type: 'entity_select',
@@ -351,6 +366,14 @@ return {
                 editable: true,
                 tooltip: '@i18n:objects.idoverridegroup.anchor_tooltip'
             },
+            {
+                label: '@i18n:objects.idoverridegroup.anchor_label',
+                name: 'ipaanchoruuid_default',
+                param: 'ipaanchoruuid',
+                tooltip: '@i18n:objects.idoverridegroup.anchor_tooltip_ad',
+                visible: false,
+                enabled: false
+            },
             'cn',
             'gidnumber',
             {
@@ -406,6 +429,32 @@ idviews.idview_facet_header = function(spec) {
 };
 
 /**
+ * Switches between combobox and textbox for ipaanchoruuid, depending on if
+ * current view is Default Trust View
+ * @class idviews.idoverride_adder_policy
+ * @extends IPA.facet_policy
+ */
+idviews.idoverride_adder_policy = function (spec) {
+    var that = IPA.facet_policy(spec);
+    that.init = function() {
+        on(that.container, 'open', that.on_open);
+    };
+
+    that.on_open = function() {
+        var d = that.container; // dialog
+        var default_view = d.pkey_prefix.slice(-1)[0] === idviews.DEFAULT_TRUST_VIEW;
+        var f1 = d.fields.get_field('ipaanchoruuid');
+        var f2 = d.fields.get_field('ipaanchoruuid_default');
+        f1.set_enabled(!default_view);
+        f1.widget.set_visible(!default_view);
+        f2.set_enabled(default_view);
+        f2.widget.set_visible(default_view);
+    };
+
+    return that;
+};
+
+/**
  * Apply Id view on hosts on hostgroup action base class
  *
  * @class idviews.apply_action
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index c0e17947af051fc11f05b792514ce76b43c54e15..32415413de85dfe409312689133b7a0913912c75 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -362,11 +362,13 @@
                         },
                         "idoverrideuser": {
                             "anchor_label": "User to override",
-                            "anchor_tooltip": "Enter trusted or IPA user login. Note: search doesn't list users from trusted domains."
+                            "anchor_tooltip": "Enter trusted or IPA user login. Note: search doesn't list users from trusted domains.",
+                            "anchor_tooltip_ad": "Enter trusted user login."
                         },
                         "idoverridegroup": {
                             "anchor_label": "Group to override",
-                            "anchor_tooltip": "Enter trusted or IPA group name. Note: search doesn't list groups from trusted domains."
+                            "anchor_tooltip": "Enter trusted or IPA group name. Note: search doesn't list groups from trusted domains.",
+                            "anchor_tooltip_ad": "Enter trusted group name."
                         },
                         "idview": {
                             "appliesto_tab": "${primary_key} applies to:",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index c7f400a902e855a654abee7e07df9ab719c60389..c73530f7f5bfea4454081bdf05944d7821b5f9bb 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -507,10 +507,12 @@ class i18n_messages(Command):
             "idoverrideuser": {
                 "anchor_label": _("User to override"),
                 "anchor_tooltip": _("Enter trusted or IPA user login. Note: search doesn't list users from trusted domains."),
+                "anchor_tooltip_ad": _("Enter trusted user login."),
             },
             "idoverridegroup": {
                 "anchor_label": _("Group to override"),
                 "anchor_tooltip": _("Enter trusted or IPA group name. Note: search doesn't list groups from trusted domains."),
+                "anchor_tooltip_ad": _("Enter trusted group name."),
             },
             "idview": {
                 "appliesto_tab": _("${primary_key} applies to:"),
-- 
1.9.3

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

Reply via email to