You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2014/07/30 22:23:28 UTC

git commit: AMBARI-6668. Config-Groups UI should allow overriding only final flag

Repository: ambari
Updated Branches:
  refs/heads/trunk 5d264f886 -> a84a65320


AMBARI-6668. Config-Groups UI should allow overriding only final flag


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

Branch: refs/heads/trunk
Commit: a84a6532006b085a22c555136ab1e63786237b16
Parents: 5d264f8
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Wed Jul 30 13:23:02 2014 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Wed Jul 30 13:23:07 2014 -0700

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 34 ++++++++------------
 ambari-web/app/controllers/wizard.js            |  1 +
 .../app/controllers/wizard/step7_controller.js  | 10 ++++--
 ambari-web/app/models/service_config.js         |  9 ++++--
 .../common/configs/overriddenProperty.hbs       |  3 ++
 .../common/configs/service_config_category.hbs  |  3 ++
 .../test/controllers/wizard/step7_test.js       | 16 ++++-----
 7 files changed, 41 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a84a6532/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 96649c7..1938fcf 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -1181,32 +1181,24 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
   buildGroupDesiredConfigs: function (configs, timeTag) {
     var sites = [];
     var time = timeTag || (new Date).getTime();
+    var siteFileNames = configs.mapProperty('filename');
+    sites = siteFileNames.map(function (filename) {
+      return {
+        type: filename.replace('.xml', ''),
+        tag: 'version' + time,
+        properties: []
+      };
+    });
+
     configs.forEach(function (config) {
       var type = config.get('filename').replace('.xml', '');
       var site = sites.findProperty('type', type);
-      if (site) {
-        site.properties.push({
-          name: config.get('name'),
-          value: config.get('value')
-        });
-      } else {
-        site = {
-          type: type,
-          tag: 'version' + time,
-          properties: [
-            {
-              name: config.get('name'),
-              value: config.get('value')
-            }
-          ]
-        };
-        sites.push(site);
-      }
+      site.properties.push(config);
     });
-    sites.forEach(function (site) {
-      site.properties = this.createSiteObj(site.type, site.tag, site.properties).properties;
+
+    return sites.map(function (site) {
+      return this.createSiteObj(site.type, site.tag, site.properties);
     }, this);
-    return sites;
   },
   /**
    * persist properties of config groups to server

http://git-wip-us.apache.org/repos/asf/ambari/blob/a84a6532/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 896f516..c996d56 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -891,6 +891,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
             isRequiredByAgent: property.get('isRequiredByAgent'),
             name: property.get('name'),
             value: property.get('value'),
+            isFinal: property.get('isFinal'),
             filename: property.get('filename')
           })
         });

http://git-wip-us.apache.org/repos/asf/ambari/blob/a84a6532/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 111c9a2..a4f2718 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -954,8 +954,14 @@ App.WizardStep7Controller = Em.Controller.extend({
         serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
           var readyGroup = App.ConfigGroup.create(configGroup);
           var wrappedProperties = [];
-          readyGroup.get('properties').forEach(function (property) {
-            wrappedProperties.pushObject(App.ServiceConfigProperty.create(property));
+          readyGroup.get('properties').forEach(function (propertyData) {
+            var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
+            var overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
+            overriddenSCP.set('isOriginalSCP', false);
+            overriddenSCP.set('parentSCP', parentSCP);
+            overriddenSCP.set('group', readyGroup);
+            overriddenSCP.setProperties(propertyData);
+            wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
           });
           wrappedProperties.setEach('group', readyGroup);
           readyGroup.set('properties', wrappedProperties);

http://git-wip-us.apache.org/repos/asf/ambari/blob/a84a6532/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index 177ac31..037b559 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -149,6 +149,7 @@ App.ServiceConfigProperty = Ember.Object.extend({
   isRequired: true, // by default a config property is required
   isReconfigurable: true, // by default a config property is reconfigurable
   isEditable: true, // by default a config property is editable
+  isNotEditable: Ember.computed.not('isEditable'),
   isFinal: false,
   defaultIsFinal: false,
   supportsFinal: false,
@@ -703,6 +704,8 @@ App.ServiceConfigProperty = Ember.Object.extend({
 
   validate: function () {
     var value = this.get('value');
+    var supportsFinal = this.get('supportsFinal');
+    var isFinal = this.get('isFinal');
     var valueRange = this.get('valueRange');
     var values = [];//value split by "," to check UNIX users, groups list
 
@@ -816,13 +819,13 @@ App.ServiceConfigProperty = Ember.Object.extend({
       var parentSCP = this.get('parentSCP');
       if (!isOriginalSCP) {
         if (!isError && parentSCP != null) {
-          if (value === parentSCP.get('value')) {
+          if (value === parentSCP.get('value') && supportsFinal && isFinal === parentSCP.get('isFinal')) {
             this.set('errorMessage', 'Configuration overrides must have different value');
             isError = true;
           } else {
             var overrides = parentSCP.get('overrides');
             overrides.forEach(function (override) {
-              if (self != override && value === override.get('value')) {
+              if (self != override && value === override.get('value')  && supportsFinal && isFinal === parentSCP.get('isFinal')) {
                 self.set('errorMessage', 'Multiple configuration overrides cannot have same value');
                 isError = true;
               }
@@ -854,7 +857,7 @@ App.ServiceConfigProperty = Ember.Object.extend({
       } else {
         this.set('error', true);
       }
-  }.observes('value', 'retypedPassword')
+  }.observes('value', 'isFinal', 'retypedPassword')
 
 });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a84a6532/ambari-web/app/templates/common/configs/overriddenProperty.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/overriddenProperty.hbs b/ambari-web/app/templates/common/configs/overriddenProperty.hbs
index 8fe54d9..db78536 100644
--- a/ambari-web/app/templates/common/configs/overriddenProperty.hbs
+++ b/ambari-web/app/templates/common/configs/overriddenProperty.hbs
@@ -19,6 +19,9 @@
   {{! Here serviceConfigBinding should ideally be serviceConfigPropertyBinding }}
   <div {{bindAttr class="overriddenSCP.errorMessage:error: :control-group :overrideField"}}>
     {{view overriddenSCP.viewClass serviceConfigBinding="overriddenSCP" categoryConfigsBinding="view.categoryConfigs"}}
+    {{#if overriddenSCP.supportsFinal}}
+      <label class="checkbox inline">{{view Ember.Checkbox checkedBinding="overriddenSCP.isFinal" disabledBinding="overriddenSCP.isNotEditable"}}{{t services.service.config.final}}</label>
+    {{/if}}
     {{#if view.isDefaultGroupSelected}}
       {{#if overriddenSCP.group}}
         <a rel='SwitchGroupTooltip' {{bindAttr data-original-title="overriddenSCP.group.switchGroupTextFull" }} class="action" {{action selectConfigGroup overriddenSCP.group target="controller"}}>

http://git-wip-us.apache.org/repos/asf/ambari/blob/a84a6532/ambari-web/app/templates/common/configs/service_config_category.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/service_config_category.hbs b/ambari-web/app/templates/common/configs/service_config_category.hbs
index 6a3f45a..489b11b 100644
--- a/ambari-web/app/templates/common/configs/service_config_category.hbs
+++ b/ambari-web/app/templates/common/configs/service_config_category.hbs
@@ -48,6 +48,9 @@
             {{! Here serviceConfigBinding should ideally be serviceConfigPropertyBinding }}
             <div {{bindAttr class="errorMessage:error: warnMessage:warning: :control-group"}}>
               {{view viewClass serviceConfigBinding="this" categoryConfigsAllBinding="view.categoryConfigsAll" }}
+              {{#if supportsFinal}}
+                <label class="checkbox inline">{{view Ember.Checkbox checkedBinding="isFinal" disabledBinding="isNotEditable"}}{{t services.service.config.final}}</label>
+              {{/if}}
               {{#if view.canEdit}}
                 {{#if isPropertyOverridable}}
                   {{#if view.supportsHostOverrides}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/a84a6532/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 432f265..859b83a 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -512,18 +512,16 @@ describe('App.InstallerStep7Controller', function () {
     it('should update configGroups for service', function () {
       var configGroups = [],
         serviceName = 'HDFS',
+        properties = [
+          { name: "p1", filename: "file.xml" },
+          { name: "p2", filename: "file.xml" }
+        ],
         serviceConfigGroups = [
-          {service: {id: 'HDFS'}, properties: [
-            {},
-            {}
-          ], isDefault: true, n: 'n1'},
-          {service: {id: 'HDFS'}, properties: [
-            {},
-            {}
-          ], isDefault: false, n: 'n2'}
+          {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: true, n: 'n1'},
+          {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: false, n: 'n2'}
         ];
       installerStep7Controller.reopen({
-        stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups})]
+        stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups, configs: properties})]
       });
       installerStep7Controller.loadConfigGroups(serviceConfigGroups);
       expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(2);