e3ffab
From da57475f30f086b2420652b1aeab9e2902fb8664 Mon Sep 17 00:00:00 2001
e3ffab
From: Petr Vobornik <pvoborni@redhat.com>
e3ffab
Date: Wed, 3 Sep 2014 17:23:33 +0200
e3ffab
Subject: [PATCH] webui: prohibit setting rid base with ipa-trust-ad-posix type
e3ffab
e3ffab
Base RID is no longer editable for ipa-trust-ad-posix range type
e3ffab
e3ffab
Adder dialog:
e3ffab
- Range type selector was moved up because it affects a field above it
e3ffab
e3ffab
Details page:
e3ffab
- Only fields relevant to range's type are visible
e3ffab
e3ffab
https://fedorahosted.org/freeipa/ticket/4221
e3ffab
e3ffab
Reviewed-By: Tomas Babej <tbabej@redhat.com>
e3ffab
---
e3ffab
 install/ui/src/freeipa/idrange.js | 77 ++++++++++++++++++++++++++++++---------
e3ffab
 1 file changed, 60 insertions(+), 17 deletions(-)
e3ffab
e3ffab
diff --git a/install/ui/src/freeipa/idrange.js b/install/ui/src/freeipa/idrange.js
e3ffab
index 12c0b288b766c059db6b844f445fb88b5821a1db..4e5dbfa00dcf80495d8a96f7fc961b9c6676691f 100644
e3ffab
--- a/install/ui/src/freeipa/idrange.js
e3ffab
+++ b/install/ui/src/freeipa/idrange.js
e3ffab
@@ -54,6 +54,11 @@ return {
e3ffab
                         'cn',
e3ffab
                         'iparangetype',
e3ffab
                         {
e3ffab
+                            name: 'iparangetyperaw',
e3ffab
+                            read_only: true,
e3ffab
+                            visible: false
e3ffab
+                        },
e3ffab
+                        {
e3ffab
                             name: 'ipabaseid',
e3ffab
                             label: '@i18n:objects.idrange.ipabaseid',
e3ffab
                             title: '@mo-param:idrange:ipabaseid:label'
e3ffab
@@ -80,6 +85,9 @@ return {
e3ffab
                         }
e3ffab
                     ]
e3ffab
                 }
e3ffab
+            ],
e3ffab
+            policies: [
e3ffab
+                exp.idrange_policy
e3ffab
             ]
e3ffab
         }
e3ffab
     ],
e3ffab
@@ -89,21 +97,6 @@ return {
e3ffab
                 name: 'cn'
e3ffab
             },
e3ffab
             {
e3ffab
-                name: 'ipabaseid',
e3ffab
-                label: '@i18n:objects.idrange.ipabaseid',
e3ffab
-                title: '@mo-param:idrange:ipabaseid:label'
e3ffab
-            },
e3ffab
-            {
e3ffab
-                name: 'ipaidrangesize',
e3ffab
-                label: '@i18n:objects.idrange.ipaidrangesize',
e3ffab
-                title: '@mo-param:idrange:ipaidrangesize:label'
e3ffab
-            },
e3ffab
-            {
e3ffab
-                name: 'ipabaserid',
e3ffab
-                label: '@i18n:objects.idrange.ipabaserid',
e3ffab
-                title: '@mo-param:idrange:ipabaserid:label'
e3ffab
-            },
e3ffab
-            {
e3ffab
                 name: 'iparangetype',
e3ffab
                 $type: 'radio',
e3ffab
                 label: '@i18n:objects.idrange.type',
e3ffab
@@ -125,6 +118,21 @@ return {
e3ffab
                 ]
e3ffab
             },
e3ffab
             {
e3ffab
+                name: 'ipabaseid',
e3ffab
+                label: '@i18n:objects.idrange.ipabaseid',
e3ffab
+                title: '@mo-param:idrange:ipabaseid:label'
e3ffab
+            },
e3ffab
+            {
e3ffab
+                name: 'ipaidrangesize',
e3ffab
+                label: '@i18n:objects.idrange.ipaidrangesize',
e3ffab
+                title: '@mo-param:idrange:ipaidrangesize:label'
e3ffab
+            },
e3ffab
+            {
e3ffab
+                name: 'ipabaserid',
e3ffab
+                label: '@i18n:objects.idrange.ipabaserid',
e3ffab
+                title: '@mo-param:idrange:ipabaserid:label'
e3ffab
+            },
e3ffab
+            {
e3ffab
                 name: 'ipasecondarybaserid',
e3ffab
                 label: '@i18n:objects.idrange.ipasecondarybaserid',
e3ffab
                 title: '@mo-param:idrange:ipasecondarybaserid:label'
e3ffab
@@ -147,7 +155,9 @@ IPA.idrange_adder_policy = function(spec) {
e3ffab
     The logic for enabling/requiring ipabaserid, ipasecondarybaserid and
e3ffab
     ipanttrusteddomainsid is as follows:
e3ffab
         1) for AD ranges (range type is ipa-ad-trust or ipa-ad-trust-posix):
e3ffab
-           * ipabaserid and ipanttrusteddomainsid are requred
e3ffab
+           * ipanttrusteddomainsid is required
e3ffab
+           * ipabaserid is required for ipa-ad-trust but disabled for
e3ffab
+             ipa-ad-trust-posix
e3ffab
            * ipasecondarybaserid is disabled
e3ffab
         2) for local ranges
e3ffab
            *  ipanttrusteddomainsid is disabled
e3ffab
@@ -206,7 +216,11 @@ IPA.idrange_adder_policy = function(spec) {
e3ffab
         var is_ad_range = (type_v === 'ipa-ad-trust' || type_v === 'ipa-ad-trust-posix');
e3ffab
 
e3ffab
         if (is_ad_range) {
e3ffab
-            require(baserid_f);
e3ffab
+            if (type_v === 'ipa-ad-trust') {
e3ffab
+                require(baserid_f);
e3ffab
+            } else {
e3ffab
+                disable(baserid_f);
e3ffab
+            }
e3ffab
             require(trusteddomainsid_f);
e3ffab
             disable(secondarybaserid_f);
e3ffab
         } else {
e3ffab
@@ -230,6 +244,35 @@ IPA.idrange_adder_policy = function(spec) {
e3ffab
     return that;
e3ffab
 };
e3ffab
 
e3ffab
+exp.idrange_policy = function(spec) {
e3ffab
+
e3ffab
+    spec = spec || {};
e3ffab
+    var that = IPA.facet_policy(spec);
e3ffab
+
e3ffab
+    that.post_load = function() {
e3ffab
+        var type_f = that.container.fields.get_field('iparangetyperaw');
e3ffab
+        var widgets = that.container.widgets;
e3ffab
+        var type_v = type_f.get_value()[0];
e3ffab
+
e3ffab
+        var baserid = true;
e3ffab
+        var secrid = true;
e3ffab
+        var sid = true;
e3ffab
+
e3ffab
+        if (type_v === 'ipa-local') {
e3ffab
+            sid = false;
e3ffab
+        } else if (type_v === 'ipa-ad-trust-posix') {
e3ffab
+            baserid = secrid = false;
e3ffab
+        } else if (type_v === 'ipa-ad-trust') {
e3ffab
+            secrid = false;
e3ffab
+        }
e3ffab
+
e3ffab
+        widgets.get_widget('details.ipabaserid').set_visible(baserid);
e3ffab
+        widgets.get_widget('details.ipasecondarybaserid').set_visible(secrid);
e3ffab
+        widgets.get_widget('details.ipanttrusteddomainsid').set_visible(sid);
e3ffab
+    };
e3ffab
+    return that;
e3ffab
+};
e3ffab
+
e3ffab
 exp.entity_spec = make_spec();
e3ffab
 exp.register = function() {
e3ffab
     var e = reg.entity;
e3ffab
-- 
e3ffab
2.1.0
e3ffab