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

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

Repository: ambari
Updated Branches:
  refs/heads/trunk 55d06c3d7 -> 5ff0c8674


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


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

Branch: refs/heads/trunk
Commit: 5ff0c867447a311fd94ef605441215212c04b8d0
Parents: 55d06c3
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Tue Apr 21 21:40:23 2015 +0300
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Wed Apr 22 08:36:06 2015 +0300

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


http://git-wip-us.apache.org/repos/asf/ambari/blob/5ff0c867/ambari-web/app/views/common/configs/service_config_layout_tab_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_config_layout_tab_view.js b/ambari-web/app/views/common/configs/service_config_layout_tab_view.js
index 9e48ab0..c3c3762 100644
--- a/ambari-web/app/views/common/configs/service_config_layout_tab_view.js
+++ b/ambari-web/app/views/common/configs/service_config_layout_tab_view.js
@@ -192,7 +192,7 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, {
     this.get('parentView').pickActiveTab(this.get('parentView.tabs'));
   }.observes('parentView.filter', 'parentView.columns.@each.selected'),
 
-  willInsertElement: function () {
+  didInsertElement: function () {
     this._super();
     this.prepareConfigProperties();
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ff0c867/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/5ff0c867/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();
+        });
+      });
+    });
   });
 
 });