Web UI part of:

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

Patch 767 is a little refactoring needed for $pre_op(as plain object) work as intended even with instantiated objects + fixes a bug where Evented objects were not considered a framework object.

Patch 768 switches tabs so we can hide it later

Patch 769 hides the tab

PAtch 770 is not really needed(would like to hear options whether to include it). It's in effect only if user somehow manages to open 'Applies to hosts' facet for 'Default trust view'. Maybe redirection would be better - if we need to act.
--
Petr Vobornik
From 1f70f5ebaed8ce52617341a7c8e826923b09030a Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 10 Oct 2014 10:50:35 +0200
Subject: [PATCH] webui: hide (un)apply buttons for Default Trust View

---
 install/ui/src/freeipa/idviews.js | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/install/ui/src/freeipa/idviews.js b/install/ui/src/freeipa/idviews.js
index 39424ef3e1e716a1e902a2580fa5fd57b0426371..ee522467501986116c759ef7150db294b9e34157 100644
--- a/install/ui/src/freeipa/idviews.js
+++ b/install/ui/src/freeipa/idviews.js
@@ -185,7 +185,17 @@ return {
                     target_entity: 'host',
                     target_facet: 'details'
                 }
-            ]
+            ],
+            state: {
+                evaluators: [
+                    {
+                        $factory: mod_details.value_state_evaluator,
+                        attribute: 'cn',
+                        value: idviews.DEFAULT_TRUST_VIEW,
+                        representation: 'cn_default_trust_view'
+                    }
+                ]
+            }
         }
     ],
 
@@ -395,6 +405,7 @@ idviews.apply_action = function(spec) {
     spec = spec || {};
     spec.name = spec.name || 'idview_apply';
     spec.label = spec.label || '@i18n:objects.idview.apply_hosts';
+    spec.hide_cond = spec.hide_cond || ['cn_default_trust_view'];
 
     var that = IPA.action(spec);
 
-- 
1.9.3

From 10fe2a4e62c4b2423b580d559260da57ca8c9870 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 10 Oct 2014 10:49:43 +0200
Subject: [PATCH] webui: hide applied to hosts tab for Default Trust View

because applying Default Trust view on hosts is not allowed

https://fedorahosted.org/freeipa/ticket/4615
---
 install/ui/src/freeipa/facet.js   |  5 ++++-
 install/ui/src/freeipa/idviews.js | 26 +++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index 556b17fe71f6a1eb460d40ce76746f868d0791ae..43627d9d531ed700ff780a0773451eaf17b1cbdd 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -211,7 +211,8 @@ exp.facet = IPA.facet = function(spec, no_init) {
      * Facet header
      * @property {facet.facet_header}
      */
-    that.header = spec.header || IPA.facet_header({ facet: that });
+    that.header = builder.build('',  spec.header || {}, {},
+        { $pre_ops: [{ facet: that }], $factory: IPA.facet_header });
 
     /**
      * Hard override for `needs_update()` logic. When set, `needs_update`
@@ -1400,6 +1401,8 @@ exp.facet_header = IPA.facet_header = function(spec) {
         that.load();
     };
 
+    that.facet_header_set_pkey = that.set_pkey;
+
     return that;
 };
 
diff --git a/install/ui/src/freeipa/idviews.js b/install/ui/src/freeipa/idviews.js
index a95806283225c0ab6d064b182df285e755637d04..39424ef3e1e716a1e902a2580fa5fd57b0426371 100644
--- a/install/ui/src/freeipa/idviews.js
+++ b/install/ui/src/freeipa/idviews.js
@@ -37,7 +37,9 @@ define([
  * @class
  * @singleton
  */
-var idviews = IPA.idviews = {};
+var idviews = IPA.idviews = {
+    DEFAULT_TRUST_VIEW: 'Default Trust View'
+};
 
 var make_spec = function() {
 return {
@@ -82,6 +84,7 @@ return {
         },
         {
             $type: 'details',
+            header: idviews.idview_facet_header,
             actions: [
                 'delete'
             ],
@@ -104,6 +107,7 @@ return {
         {
             $type: 'nested_search',
             facet_group: 'overrides',
+            header: idviews.idview_facet_header,
             nested_entity: 'idoverrideuser',
             search_all_entries: true,
             label: '@mo:idoverrideuser.label',
@@ -123,6 +127,7 @@ return {
         {
             $type: 'nested_search',
             facet_group: 'overrides',
+            header: idviews.idview_facet_header,
             nested_entity: 'idoverridegroup',
             search_all_entries: true,
             label: '@mo:idoverridegroup.label',
@@ -360,6 +365,25 @@ idviews.appliedtohosts_facet = function(spec, no_init) {
     return that;
 };
 
+idviews.idview_facet_header = function(spec) {
+
+    var that = mod_facet.facet_header(spec);
+
+    /**
+     * Set pkeys and hides 'appliedtohosts' facet for 'Default Trust View'
+     * @param {string} value pkey
+     */
+    that.set_pkey = function(value) {
+
+        that.facet_header_set_pkey(value);
+        var display = value === idviews.DEFAULT_TRUST_VIEW ? 'none' : '';
+        $('.facet-group[name="appliedto"]', that.facet_tabs).
+            css('display', display);
+    };
+
+    return that;
+};
+
 /**
  * Apply Id view on hosts on hostgroup action base class
  *
-- 
1.9.3

From 3267320e170d3ed2729d31150eccc12f3ba66ce3 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Thu, 9 Oct 2014 16:06:23 +0200
Subject: [PATCH] webui: change order of idview's facet groups

Applied to hosts facet should not be default because, e.g., for Default Trust View it shouldn't be even visible(o use).
---
 install/ui/src/freeipa/idviews.js | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/install/ui/src/freeipa/idviews.js b/install/ui/src/freeipa/idviews.js
index 18f48acb691ddc1265d8168139ba86472e126602..a95806283225c0ab6d064b182df285e755637d04 100644
--- a/install/ui/src/freeipa/idviews.js
+++ b/install/ui/src/freeipa/idviews.js
@@ -47,13 +47,13 @@ return {
     },
     facet_groups: [
         {
-            name: 'appliedto',
-            label: '@i18n:objects.idview.appliesto_tab'
-        },
-        {
             name: 'overrides',
             label: '@i18n:objects.idview.overrides_tab'
         },
+        {
+            name: 'appliedto',
+            label: '@i18n:objects.idview.appliesto_tab'
+        },
         'settings'
     ],
     facets: [
-- 
1.9.3

From 3869f7fa4395b098b0de556857a336ede23aa519 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 10 Oct 2014 10:21:30 +0200
Subject: [PATCH] webui: make Evented a part of base IPA.object

1. All framework objects to use event interface
2. Framework objects can be part of specification objects but they are not deep-cloned as the rest of specification objects - usually it would cause infinite loop. This make easier to add context as a $pre-op object without a need for $pre-op function.
---
 install/ui/src/freeipa/_base/Builder.js   |  2 +-
 install/ui/src/freeipa/_base/construct.js |  8 ++------
 install/ui/src/freeipa/dialog.js          |  2 +-
 install/ui/src/freeipa/facet.js           |  2 +-
 install/ui/src/freeipa/field.js           |  2 +-
 install/ui/src/freeipa/ipa.js             | 15 ++++++---------
 install/ui/src/freeipa/widget.js          |  6 +++---
 7 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/install/ui/src/freeipa/_base/Builder.js b/install/ui/src/freeipa/_base/Builder.js
index 890a98a491529f7d26f1a1fb46cdbb4fa063f025..9433a8126e160120fff046c792f4e74330052ea0 100644
--- a/install/ui/src/freeipa/_base/Builder.js
+++ b/install/ui/src/freeipa/_base/Builder.js
@@ -363,7 +363,7 @@ define(['dojo/_base/declare',
                 if (preop_t === 'function') {
                     spec = preop(spec, context);
                 } else if (preop_t === 'object') {
-                    var temp = lang.clone(preop);
+                    var temp = construct.clone(preop);
                     this.spec_mod.mod(spec, temp);
                     this.spec_mod.del_rules(temp);
                     lang.mixin(spec, temp);
diff --git a/install/ui/src/freeipa/_base/construct.js b/install/ui/src/freeipa/_base/construct.js
index 6db2134b8d470da9f7364e06209010879dcfba1b..1c415249e02f1986e2fb3c4064dcd0b8765056b1 100644
--- a/install/ui/src/freeipa/_base/construct.js
+++ b/install/ui/src/freeipa/_base/construct.js
@@ -43,18 +43,14 @@ define(['dojo/_base/declare',
         /**
          * Finds out if object is a spec object.
          *
-         * Object is not a spec object when any of following applies:
+         * Object is not a spec object when it has an `isInstanceOf` function.
          *
-         * - has `__fw_obj === true`
-         * - has `isInstanceOf` function - basically tells if it's a instance of
-         *                                   dojo-based class
          * @param {Object} obj
          */
         is_spec: function(obj) {
             var ret = false;
             if (typeof obj === 'object') {
-                ret = obj.__fw_obj === true ||
-                      typeof obj.isInstanceOf === 'function';
+                ret = typeof obj.isInstanceOf === 'function';
             }
             return !ret;
         },
diff --git a/install/ui/src/freeipa/dialog.js b/install/ui/src/freeipa/dialog.js
index def29cfca73f6a2874514ad7cd649190f53b00ab..c277518ac97d9c1eab04c397519fa17f8f564023 100644
--- a/install/ui/src/freeipa/dialog.js
+++ b/install/ui/src/freeipa/dialog.js
@@ -221,7 +221,7 @@ IPA.dialog = function(spec) {
 
     spec = spec || {};
 
-    var that = new Evented();
+    var that = IPA.object();
 
     /** @property {entity.entity} entity Entity */
     that.entity = IPA.get_entity(spec.entity);
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index c06df00a87bb2ce0961a5187a10d68e4ebb5ad44..556b17fe71f6a1eb460d40ce76746f868d0791ae 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -124,7 +124,7 @@ exp.facet = IPA.facet = function(spec, no_init) {
 
     spec = spec || {};
 
-    var that = new Evented();
+    var that = IPA.object();
 
     /**
      * Name of preferred facet container
diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js
index f53c6c1d06759645a4fa11f88c8cbadfbba26195..c2609c564157945d17666c3bf5bc26e5bd3539c8 100644
--- a/install/ui/src/freeipa/field.js
+++ b/install/ui/src/freeipa/field.js
@@ -60,7 +60,7 @@ var field = {};
 field.field = IPA.field = function(spec) {
     spec = spec || {};
 
-    var that = new Evented();
+    var that = IPA.object();
 
     /**
      * Entity
diff --git a/install/ui/src/freeipa/ipa.js b/install/ui/src/freeipa/ipa.js
index b414e48250c554c10a03059d234d825168a08789..6d3aeaaaaca11dfdaf20935e5c9084c9ed106e6c 100644
--- a/install/ui/src/freeipa/ipa.js
+++ b/install/ui/src/freeipa/ipa.js
@@ -23,7 +23,9 @@
 */
 
 define([
+        'dojo/_base/declare',
         'dojo/Deferred',
+        'dojo/Evented',
         'dojo/keys',
         'dojo/topic',
         './jquery',
@@ -38,8 +40,8 @@ define([
         './text',
         './util',
         'exports'
-    ], function(Deferred, keys, topic, $, JSON, i18n, auth, datetime,
-        metadata_provider, builder, reg, rpc, text, util, exports) {
+    ], function(declare, Deferred, Evented, keys, topic, $, JSON, i18n, auth,
+        datetime, metadata_provider, builder, reg, rpc, text, util, exports) {
 
 /**
  * @class
@@ -337,19 +339,14 @@ var IPA = function () {
         }
     };
 
-    that.obj_cls = function() {};
-    that.obj_cls.prototype.__fw_obj = true;
+    that.obj_cls = declare([Evented]);
 
     return that;
 }();
 
 /**
  * Framework objects created by factories should use this
- * instead of empty object when creating base objects. As an alternative
- * they can just set __fw_obj property.
- *
- * __fw_obj property serves for telling the framework that it's instantiated
- * object and not an object specification (spec).
+ * instead of empty object when creating base objects.
  *
  * @class
  */
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index b9ab82cbceff5a8cef12828b0d4006fea2cf578e..39ee19b8dcee1d9001b77af6da0bae1b0a12d7c0 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -83,7 +83,7 @@ IPA.widget = function(spec) {
 
     spec = spec || {};
 
-    var that = new Evented();
+    var that = IPA.object();
 
     /**
      * Normalize tooltip
@@ -1419,7 +1419,7 @@ IPA.option_widget_base = function(spec, that) {
     spec = spec || {};
 
     // when that is specified, this constructor behaves like a mixin
-    that = that || new Evented();
+    that = that || IPA.object();
 
     // classic properties
     that.name = spec.name;
@@ -5230,7 +5230,7 @@ IPA.widget_container = function(spec) {
 
     spec = spec || {};
 
-    var that = new Evented();
+    var that = IPA.object();
 
     that.new_container_for_child = spec.new_container_for_child !== undefined ?
     spec.new_container_for_child : true;
-- 
1.9.3

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

Reply via email to