Repository: ambari
Updated Branches:
  refs/heads/trunk e146aa2ba -> eac8a0ce5


AMBARI-11964. Allow services to hide "custom" configurations. (Di Li via Jaimin)


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

Branch: refs/heads/trunk
Commit: eac8a0ce54099aad24d2baed0a2e4c3fb02d0e0e
Parents: e146aa2
Author: Jaimin Jetly <jai...@hortonworks.com>
Authored: Thu Nov 19 11:58:22 2015 -0800
Committer: Jaimin Jetly <jai...@hortonworks.com>
Committed: Thu Nov 19 11:58:22 2015 -0800

----------------------------------------------------------------------
 .../1.4.0.2.0/configuration/flume-conf.xml      |  2 +-
 .../0.12.0.2.0/configuration/pig-properties.xml |  2 +-
 .../services/FLUME/configuration/flume-conf.xml |  2 +-
 .../PIG/configuration/pig-properties.xml        |  2 +-
 .../PIG/configuration/pig-properties.xml        |  2 +-
 .../PIG/configuration/pig-properties.xml        |  2 +-
 .../PIG/configuration/pig-properties.xml        |  2 +-
 .../PIG/configuration/pig-properties.xml        |  2 +-
 .../services/FLUME/configuration/flume-conf.xml |  2 +-
 .../services/FLUME/configuration/flume-conf.xml |  2 +-
 .../services/FLUME/configuration/flume-conf.xml |  2 +-
 .../PIG/configuration/pig-properties.xml        |  2 +-
 ambari-web/app/models/stack_service.js          |  3 +-
 ambari-web/app/utils/config.js                  | 23 +++++++-
 .../views/common/configs/service_config_view.js |  3 +-
 .../configs/service_configs_by_category_view.js |  1 +
 ambari-web/test/utils/config_test.js            | 60 ++++++++++++++++++++
 .../common/configs/service_config_view_test.js  | 16 ++++--
 18 files changed, 110 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-conf.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-conf.xml
 
b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-conf.xml
index f91be65..71f5a8e 100644
--- 
a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-conf.xml
+++ 
b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-conf.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Flume agent configurations. 

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/configuration/pig-properties.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/configuration/pig-properties.xml
 
b/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/configuration/pig-properties.xml
index fbb6949..8e2e1d7 100644
--- 
a/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/configuration/pig-properties.xml
+++ 
b/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/configuration/pig-properties.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/configuration/flume-conf.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/configuration/flume-conf.xml
 
b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/configuration/flume-conf.xml
index 36de434..6089b27 100644
--- 
a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/configuration/flume-conf.xml
+++ 
b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/configuration/flume-conf.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Describe all the Flume agent configurations</description>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/PIG/configuration/pig-properties.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/PIG/configuration/pig-properties.xml
 
b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/PIG/configuration/pig-properties.xml
index 909bc98..7f1dc08 100644
--- 
a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/PIG/configuration/pig-properties.xml
+++ 
b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/PIG/configuration/pig-properties.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/main/resources/stacks/HDP/2.0.6.GlusterFS/services/PIG/configuration/pig-properties.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.0.6.GlusterFS/services/PIG/configuration/pig-properties.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6.GlusterFS/services/PIG/configuration/pig-properties.xml
index 9fc8188..5f05da0 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.0.6.GlusterFS/services/PIG/configuration/pig-properties.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6.GlusterFS/services/PIG/configuration/pig-properties.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/PIG/configuration/pig-properties.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/PIG/configuration/pig-properties.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/PIG/configuration/pig-properties.xml
index 9fc8188..5f05da0 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/PIG/configuration/pig-properties.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/PIG/configuration/pig-properties.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/main/resources/stacks/HDP/2.1/services/PIG/configuration/pig-properties.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.1/services/PIG/configuration/pig-properties.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.1/services/PIG/configuration/pig-properties.xml
index 1a3a0d6..b943305 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.1/services/PIG/configuration/pig-properties.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.1/services/PIG/configuration/pig-properties.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/main/resources/stacks/HDP/2.3/services/PIG/configuration/pig-properties.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.3/services/PIG/configuration/pig-properties.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.3/services/PIG/configuration/pig-properties.xml
index ebba6be..ffaa0fb 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.3/services/PIG/configuration/pig-properties.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.3/services/PIG/configuration/pig-properties.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/FLUME/configuration/flume-conf.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/FLUME/configuration/flume-conf.xml
 
b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/FLUME/configuration/flume-conf.xml
index f91be65..71f5a8e 100644
--- 
a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/FLUME/configuration/flume-conf.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/FLUME/configuration/flume-conf.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Flume agent configurations. 

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/test/resources/stacks/HDP/2.0.6.1/services/FLUME/configuration/flume-conf.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/resources/stacks/HDP/2.0.6.1/services/FLUME/configuration/flume-conf.xml
 
b/ambari-server/src/test/resources/stacks/HDP/2.0.6.1/services/FLUME/configuration/flume-conf.xml
index 36de434..6089b27 100644
--- 
a/ambari-server/src/test/resources/stacks/HDP/2.0.6.1/services/FLUME/configuration/flume-conf.xml
+++ 
b/ambari-server/src/test/resources/stacks/HDP/2.0.6.1/services/FLUME/configuration/flume-conf.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Describe all the Flume agent configurations</description>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-conf.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-conf.xml
 
b/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-conf.xml
index 36de434..6089b27 100644
--- 
a/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-conf.xml
+++ 
b/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-conf.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Describe all the Flume agent configurations</description>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
index 9f86180..79e504b 100644
--- 
a/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
+++ 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-web/app/models/stack_service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_service.js 
b/ambari-web/app/models/stack_service.js
index bdcf303..88e2bfa 100644
--- a/ambari-web/app/models/stack_service.js
+++ b/ambari-web/app/models/stack_service.js
@@ -371,8 +371,7 @@ App.StackService.configCategories = function () {
 
   // Add custom section for every configType to all the services
   configTypes.forEach(function (type) {
-    var configTypesWithNoCustomSection = 
['capacity-scheduler','mapred-queue-acls','flume-conf', 
'pig-properties','topology','users-ldif', 'admin-topology', 'knoxsso-topology'];
-    if (type.endsWith('-env') || type.endsWith('-log4j') || 
configTypesWithNoCustomSection.contains(type)) {
+    if (type.endsWith('-env') || type.endsWith('-log4j')) {
       return;
     }
     serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index b113a21..be3a2dc 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -278,6 +278,7 @@ App.config = Em.Object.create({
       recommendedValue: null,
       recommendedIsFinal: null,
       supportsFinal: this.shouldSupportFinal(serviceName, fileName),
+      supportsAddingForbidden: this.shouldSupportAddingForbidden(serviceName, 
fileName),
       serviceName: serviceName,
       displayName: name,
       displayType: this.getDefaultDisplayType(coreObject ? coreObject.value : 
''),
@@ -580,7 +581,8 @@ App.config = Em.Object.create({
     var configTypes = service.get('configTypes');
     var configTypesInfo = {
       items: [],
-      supportsFinal: []
+      supportsFinal: [],
+      supportsAddingForbidden: []
     };
     if (configTypes) {
       for (var key in configTypes) {
@@ -589,6 +591,9 @@ App.config = Em.Object.create({
           if (configTypes[key].supports && configTypes[key].supports.final === 
"true") {
             configTypesInfo.supportsFinal.push(key);
           }
+          if (configTypes[key].supports && 
configTypes[key].supports.adding_forbidden === "true"){
+            configTypesInfo.supportsAddingForbidden.push(key);
+          }
         }
       }
     }
@@ -917,6 +922,22 @@ App.config = Em.Object.create({
     }
   },
 
+  shouldSupportAddingForbidden: function(serviceName, filename) {
+    var unsupportedServiceNames = ['MISC', 'Cluster'];
+    if (!serviceName || unsupportedServiceNames.contains(serviceName) || 
!filename) {
+      return false;
+    } else {
+      var stackServiceName = 
App.StackService.find().findProperty('serviceName', serviceName);
+      if (!stackServiceName) {
+        return false;
+      }
+      var stackService = App.StackService.find(serviceName);
+      return 
!!this.getConfigTypesInfoFromService(stackService).supportsAddingForbidden.find(function
 (configType) {
+        return filename.startsWith(configType);
+      });
+    }
+  },
+
   /**
    * Remove all ranger-related configs, that should be available only if 
Ranger is installed
    * @param configs - stepConfigs object

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-web/app/views/common/configs/service_config_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_config_view.js 
b/ambari-web/app/views/common/configs/service_config_view.js
index 1c12217..39d61e9 100644
--- a/ambari-web/app/views/common/configs/service_config_view.js
+++ b/ambari-web/app/views/common/configs/service_config_view.js
@@ -152,7 +152,8 @@ App.ServiceConfigView = Em.View.extend({
 
     if (controller.get('selectedConfigGroup')) {
       
controller.get('selectedService.configCategories').filterProperty('siteFileName').forEach(function
 (config) {
-        config.set('customCanAddProperty', config.get('canAddProperty'));
+        var supportsAddingForbidden = 
App.config.shouldSupportAddingForbidden(controller.get('selectedService').serviceName,
 config.siteFileName); //true if the UI should not display the Custom ... 
section
+        config.set('customCanAddProperty', !supportsAddingForbidden);
       });
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/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 ffbea76..a1641f2 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
@@ -354,6 +354,7 @@ App.ServiceConfigsByCategoryView = 
Em.View.extend(App.UserPref, App.ConfigOverri
       savedValue: null,
       recommendedValue: null,
       supportsFinal: App.config.shouldSupportFinal(propertyObj.serviceName, 
propertyObj.filename),
+      supportsAddingForbidden: false, //Can add a new property implies the 
given categrary allows adding new properties...
       filename: propertyObj.filename || '',
       isUserProperty: true,
       isNotSaved: true,

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js 
b/ambari-web/test/utils/config_test.js
index c90b758..62a6689 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -469,6 +469,65 @@ describe('App.config', function () {
 
   });
 
+  describe('#shouldSupportAddingForbidden', function () {
+
+    var cases = [
+      {
+        shouldSupportAddingForbidden: false,
+        title: 'no service name specified'
+      },
+      {
+        serviceName: 's0',
+        shouldSupportAddingForbidden: false,
+        title: 'no filename specified'
+      },
+      {
+        serviceName: 'MISC',
+        shouldSupportAddingForbidden: false,
+        title: 'MISC'
+      },
+      {
+        serviceName: 's0',
+        filename: 's0-site',
+        shouldSupportAddingForbidden: true,
+        title: 'adding forbidden supported'
+      },
+      {
+        serviceName: 's0',
+        filename: 's0-properties',
+        shouldSupportAddingForbidden: false,
+        title: 'adding forbidden not supported'
+      }
+    ];
+
+    beforeEach(function () {
+      sinon.stub(App.StackService, 'find').returns([
+        Em.Object.create({
+          serviceName: 's0',
+          configTypes: {
+            's0-size': {},
+            's0-properties': {}
+          }
+        })
+      ]);
+      sinon.stub(App.config, 'getConfigTypesInfoFromService').returns({
+        supportsAddingForbidden: ['s0-site']
+      });
+    });
+
+    afterEach(function () {
+      App.StackService.find.restore();
+      App.config.getConfigTypesInfoFromService.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        expect(App.config.shouldSupportAddingForbidden(item.serviceName, 
item.filename)).to.equal(item.shouldSupportAddingForbidden);
+      });
+    });
+
+  });
+
   describe('#removeRangerConfigs', function () {
 
     it('should remove ranger configs and categories', function () {
@@ -783,6 +842,7 @@ describe('App.config', function () {
       recommendedValue: null,
       recommendedIsFinal: null,
       supportsFinal: true,
+      supportsAddingForbidden: false,
       serviceName: 'pServiceName',
       displayName: 'pName',
       displayType: 'pDisplayType',

http://git-wip-us.apache.org/repos/asf/ambari/blob/eac8a0ce/ambari-web/test/views/common/configs/service_config_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_config_view_test.js 
b/ambari-web/test/views/common/configs/service_config_view_test.js
index 1f0cd60..f0757a3 100644
--- a/ambari-web/test/views/common/configs/service_config_view_test.js
+++ b/ambari-web/test/views/common/configs/service_config_view_test.js
@@ -44,8 +44,8 @@ describe('App.ServiceConfigView', function () {
         serviceName: 'TEST',
         configCategories: [
           App.ServiceConfigCategory.create({ name: 'category1', 
canAddProperty: false}),
-          App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 
'xml', canAddProperty: true}),
-          App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 
'xml', canAddProperty: false})
+          App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 
'category2.xml', canAddProperty: true}),
+          App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 
'category3.xml', canAddProperty: false})
         ],
         configs: []
       }
@@ -62,8 +62,8 @@ describe('App.ServiceConfigView', function () {
         serviceName: 'TEST',
         configCategories: [
           App.ServiceConfigCategory.create({ name: 'category1', 
canAddProperty: true}),
-          App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 
'xml', canAddProperty: true}),
-          App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 
'xml', canAddProperty: false})
+          App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 
'category2.xml', canAddProperty: true}),
+          App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 
'category3.xml', canAddProperty: false})
         ],
         configs: []
       }
@@ -71,6 +71,14 @@ describe('App.ServiceConfigView', function () {
   ];
 
   describe('#checkCanEdit', function () {
+    before(function () {
+      sinon.stub(App.config, 'shouldSupportAddingForbidden').withArgs('TEST', 
'category2.xml').returns(true).withArgs('TEST', 'category3.xml').returns(false);
+    });
+
+    after(function () {
+      App.config.shouldSupportAddingForbidden.restore();
+    });
+
     testCases.forEach(function (test) {
       it(test.title, function () {
         controller.set('selectedService', test.selectedService);

Reply via email to