Преглед на файлове

AMBARI-15425 Required empty fields for AM (Grafana) are present after after upgrade from 2.2.0.0 etc to 2.2.2.0. (ababiichuk)

ababiichuk преди 9 години
родител
ревизия
803bc73545

+ 19 - 10
ambari-web/app/mixins/common/configs/config_recommendation_parser.js

@@ -66,11 +66,11 @@ App.ConfigRecommendationParser = Em.Mixin.create(App.ConfigRecommendations, {
           if (propertyAttributes) {
             var stackProperty = App.configsCollection.getConfigByName(name, fileName);
             for (var attr in propertyAttributes) {
-              if (attr == 'delete' && this.allowUpdateProperty(parentProperties, name, fileName)) {
+              if (attr === 'delete' && this.allowUpdateProperty(parentProperties, name, fileName)) {
                 propertiesToDelete.push(config);
-              } else if (stackProperty) {
+              } else if ((attr === 'visible') || stackProperty) {
                 /** update config boundaries **/
-                updateBoundariesCallback(stackProperty, attr, propertyAttributes[attr], configGroup);
+                updateBoundariesCallback(stackProperty, attr, propertyAttributes[attr], name, fileName, configGroup);
               }
             }
           }
@@ -221,15 +221,24 @@ App.ConfigRecommendationParser = Em.Mixin.create(App.ConfigRecommendations, {
 	 * @param {Object} stackProperty
 	 * @param {string} attr
 	 * @param {Number|String|Boolean} value
+	 * @param {String} name
+	 * @param {String} fileName
 	 * @protected
 	 */
-	_updateBoundaries: function(stackProperty, attr, value) {
-    App.assertObject(stackProperty);
-    if (!Em.get(stackProperty, 'valueAttributes')) {
-      stackProperty.valueAttributes = {};
-    }
-		Em.set(stackProperty.valueAttributes, attr, value);
-    return stackProperty;
+	_updateBoundaries: function(stackProperty, attr, value, name, fileName) {
+		if (attr === 'visible') {
+			var p = App.config.findConfigProperty(this.get('stepConfigs'), name, App.config.getOriginalFileName(fileName));
+			if (p) {
+				p.set('isVisible', value);
+			}
+		}
+		if (stackProperty) {
+			if (!Em.get(stackProperty, 'valueAttributes')) {
+				stackProperty.valueAttributes = {};
+			}
+			Em.set(stackProperty.valueAttributes, attr, value);
+		}
+    return stackProperty || null;
 	},
 
   /**

+ 3 - 1
ambari-web/app/mixins/common/configs/config_with_override_recommendation_parser.js

@@ -100,10 +100,12 @@ App.ConfigWithOverrideRecommendationParser = Em.Mixin.create(App.ConfigRecommend
 	 * @param {Object} stackProperty
 	 * @param {string} attr
 	 * @param {Number|String|Boolean} value
+	 * @param {String} name
+	 * @param {String} fileName
 	 * @param {App.ServiceConfigGroup} configGroup
 	 * @protected
 	 */
-	_updateOverrideBoundaries: function(stackProperty, attr, value, configGroup) {
+	_updateOverrideBoundaries: function(stackProperty, attr, value, name, fileName, configGroup) {
 		if (!stackProperty.valueAttributes[configGroup.get('name')]) {
 			stackProperty.valueAttributes[configGroup.get('name')] = {};
 		}

+ 2 - 6
ambari-web/test/mixins/common/configs/config_recommendation_parser_test.js

@@ -100,12 +100,12 @@ describe('App.ConfigRecommendationParser', function() {
 
       it('updateBoundariesCallback maximum', function() {
         expect(instanceObject.updateBoundariesCallback.calledWith({ name: 'p3', filename: 'fileName1' },
-          'maximum', 100, null)).to.be.true;
+          'maximum', 100, 'p3', 'fileName1', null)).to.be.true;
       });
 
       it('updateBoundariesCallback minimum', function() {
         expect(instanceObject.updateBoundariesCallback.calledWith({ name: 'p3', filename: 'fileName1' },
-          'minimum', 1, null)).to.be.true;
+          'minimum', 1, 'p3', 'fileName1', null)).to.be.true;
       });
     });
 
@@ -325,10 +325,6 @@ describe('App.ConfigRecommendationParser', function() {
     it('sets appropriate attribute', function() {
       expect(instanceObject._updateBoundaries({}, 'attr1', 'v1')).to.eql({ valueAttributes: {'attr1': 'v1'}});
     });
-
-    it('throws error', function() {
-      expect(instanceObject._updateBoundaries.bind(instanceObject, null, 'attr1', 'v1')).to.throw(App.ObjectTypeError);
-    });
   });
 
   describe('#_getCoreProperties', function() {