You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/04/21 17:18:56 UTC

ambari git commit: AMBARI-10630. Empty config category should be hidden on Advanced config tab. (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk c136edff1 -> 0c428ebae


AMBARI-10630. Empty config category should be hidden on Advanced config tab. (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0c428eba
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0c428eba
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0c428eba

Branch: refs/heads/trunk
Commit: 0c428ebae5f9f2f6a0744df8b8485a2c267ab838
Parents: c136edf
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Tue Apr 21 18:14:55 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Tue Apr 21 18:14:55 2015 +0300

----------------------------------------------------------------------
 .../configs/service_configs_by_category_view.js |  7 +-
 .../service_configs_by_category_view_test.js    | 90 ++++++++++++++++++++
 2 files changed, 95 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0c428eba/ambari-web/app/views/common/configs/service_configs_by_category_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_configs_by_category_view.js b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
index ca8a1e5..3153cf5 100644
--- a/ambari-web/app/views/common/configs/service_configs_by_category_view.js
+++ b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
@@ -79,8 +79,11 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
    * @type {boolean}
    */
   isShowBlock: function () {
-    return this.get('category.customCanAddProperty') || this.get('categoryConfigs').filterProperty('isHiddenByFilter', false).length > 0;
-  }.property('category.customCanAddProperty', 'categoryConfigs.@each.isHiddenByFilter'),
+    var isCustomPropertiesCategory = this.get('category.customCanAddProperty');
+    var emptyFiltered = this.get('categoryConfigs').filterProperty('isHiddenByFilter', false).length > 0;
+    var isWidgetsOnlyCategory = this.get('categoryConfigs.length') == this.get('categoryConfigs').filterProperty('widget').length;
+    return isCustomPropertiesCategory || (emptyFiltered && !isWidgetsOnlyCategory);
+  }.property('category.customCanAddProperty', 'categoryConfigs.@each.isHiddenByFilter', 'categoryConfigs.@each.widget'),
 
   /**
    * Re-order the configs to list content displayType properties at last in the category

http://git-wip-us.apache.org/repos/asf/ambari/blob/0c428eba/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
index 16ea8b6..6505cf0 100644
--- a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
+++ b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
@@ -278,6 +278,96 @@ describe('App.ServiceConfigsByCategoryView', function () {
       });
     });
 
+    describe('#isShowBlock', function() {
+      var tests = [
+        {
+          categoryConfigs: Em.A([
+            { isHiddenByFilter: false }
+          ]),
+          category: {},
+          m: 'no configs with widget, filtered properties are visible. Panel should be shown',
+          e: true
+        },
+        {
+          categoryConfigs: Em.A([]),
+          category: Em.Object.create({ customCanAddProperty: true}),
+          m: 'Category with custom properties. Panel should be shown',
+          e: true
+        },
+        {
+          categoryConfigs: Em.A([
+            { isHiddenByFilter: false }
+          ]),
+          category: Em.Object.create({ customCanAddProperty: true}),
+          m: 'Category with custom properties. Filtered configs are hidden. Panel should be shown',
+          e: true
+        },
+        {
+          categoryConfigs: Em.A([
+            { isHiddenByFilter: true }
+          ]),
+          category: Em.Object.create({ customCanAddProperty: false }),
+          m: 'Filtered configs are hidden. Category not for custom properties. Panel should be hidden',
+          e: false
+        },
+        {
+          categoryConfigs: Em.A([]),
+          category: Em.Object.create({ customCanAddProperty: false }),
+          m: 'Category without properties and not for custom configurations. Panel should be hidden',
+          e: false
+        },
+        {
+          categoryConfigs: Em.A([
+            { widget: {someProp: 'a'}},
+            { widget: {someProp: 'b'}}
+          ]),
+          category: Em.Object.create({ customCanAddProperty: false }),
+          m: 'All properties have widgets and category is not custom. Panel should be hidden',
+          e: false
+        },
+        {
+          categoryConfigs: Em.A([
+            { widget: null },
+            { widget: null }
+          ]),
+          category: Em.Object.create({ customCanAddProperty: false }),
+          m: 'All properties have widgets set to `null` and category is not custom. Panel should be hidden',
+          e: false
+        },
+        {
+          categoryConfigs: Em.A([
+            { widget: {someProp: 'a'} },
+            { isHiddenByFilter: true }
+          ]),
+          category: Em.Object.create({ customCanAddProperty: false }),
+          m: 'Category contains mixed properties. Properties are hidden by filter. Panel should be hidden',
+          e: false
+        },
+        {
+          categoryConfigs: Em.A([
+            { widget: {someProp: 'a'} },
+            { isHiddenByFilter: false }
+          ]),
+          category: Em.Object.create({ customCanAddProperty: false }),
+          m: 'Category contains mixed properties. Properties are visible. Panel should be shown',
+          e: true
+        }
+      ];
+
+      tests.forEach(function(test) {
+        it(test.m, function() {
+          var _view = App.ServiceConfigsByCategoryView.create({
+            serviceConfigs: Em.A([]),
+            category: test.category,
+            categoryConfigs: test.categoryConfigs
+          });
+          sinon.stub(_view, 'filteredCategoryConfigs', Em.K);
+          _view.filteredCategoryConfigs.restore();
+          expect(_view.get('isShowBlock')).to.be.eql(test.e);
+          _view.destroy();
+        });
+      });
+    });
   });
 
 });