Browse Source

AMBARI-15014 Incorrect #of required properties at Ranger Customize Services page (Next button not enabled). (ababiichuk)

ababiichuk 9 years ago
parent
commit
2ca172d4ce

+ 1 - 4
ambari-web/app/controllers/wizard/step7_controller.js

@@ -676,10 +676,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
               themeResource.get('configProperties').forEach(function (_configId) {
                 configs.forEach(function (item) {
                   if (App.config.configId(item.name, item.filename) === _configId) {
-                    // if config has already been hidden by condition with "subsection" or "subsectionTab" type
-                    // then ignore condition of "config" type
-                    if (configCondition.get('type') === 'config' && item.hiddenBySection) return false;
-                    item.hiddenBySection = !valueAttributes['visible'];
+                    item.isVisible = valueAttributes['visible'];
                   }
                 });
               }, this);

+ 1 - 1
ambari-web/app/mixins/common/serverValidator.js

@@ -301,7 +301,7 @@ App.ServerValidatorMixin = Em.Mixin.create({
         : self.get('stepConfigs');
       var configsWithErrors = stepConfigs.some(function (step) {
         return step.get('configs').some(function(c) {
-          return c.get('isVisible') && !c.get('hiddenBySection') && (c.get('warn') || c.get('error'));
+          return c.get('isVisible') && (c.get('warn') || c.get('error'));
         })
       });
       if (configsWithErrors) {

+ 1 - 5
ambari-web/app/models/configs/objects/service_config.js

@@ -38,11 +38,7 @@ App.ServiceConfig = Ember.Object.extend({
 
   errorCount: Em.computed.alias('configsWithErrors.length'),
 
-  visibleProperties: function() {
-    return this.get('configs').filter(function(c) {
-      return c.get('isVisible') && !c.get('hiddenBySection');
-    });
-  }.property('configs.@each.isVisible', 'configs.@each.hiddenBySection'),
+  visibleProperties: Em.computed.filterBy('configs', 'isVisible', true),
 
   configsWithErrors: function() {
     return this.get('visibleProperties').filter(function(c) {

+ 0 - 6
ambari-web/app/models/configs/objects/service_config_property.js

@@ -179,12 +179,6 @@ App.ServiceConfigProperty = Em.Object.extend({
   rowStyleClass: null, // CSS-Class to be applied on the row showing this config
   showAsTextBox: false,
 
-  /**
-   * config is invisible since wrapper section is hidden
-   * @type {boolean}
-   */
-  hiddenBySection: false,
-
   /**
    * @type {boolean}
    */

+ 3 - 9
ambari-web/app/models/configs/theme/sub_section.js

@@ -94,11 +94,7 @@ App.SubSection = DS.Model.extend({
 
   showTabs: Em.computed.and('hasTabs', 'someSubSectionTabIsVisible'),
 
-  visibleProperties: function() {
-    return this.get('configs').filter(function(c) {
-      return c.get('isVisible') && !c.get('hiddenBySection');
-    });
-  }.property('configs.@each.isVisible', 'configs.@each.hiddenBySection'),
+  visibleProperties: Em.computed.filterBy('configs', 'isVisible', true),
 
   visibleTabs: Em.computed.filterBy('subSectionTabs', 'isVisible', true),
 
@@ -178,11 +174,9 @@ App.SubSection = DS.Model.extend({
    * @type {boolean}
    */
   isHiddenByFilter: function () {
-    var configs = this.get('configs').filter(function(c) {
-      return !c.get('hiddenBySection') && c.get('isVisible');
-    });
+    var configs = this.get('visibleProperties');
     return configs.length ? configs.everyProperty('isHiddenByFilter', true) : false;
-  }.property('configs.@each.isHiddenByFilter'),
+  }.property('visibleProperties.@each.isHiddenByFilter'),
 
   /**
    * @type {boolean}

+ 1 - 5
ambari-web/app/models/configs/theme/sub_section_tab.js

@@ -55,11 +55,7 @@ App.SubSectionTab = DS.Model.extend({
    */
   isActive: DS.attr('boolean', {defaultValue: false}),
 
-  visibleProperties: function() {
-    return this.get('configs').filter(function(c) {
-      return c.get('isVisible') && !c.get('hiddenBySection');
-    });
-  }.property('configs.@each.isVisible', 'configs.@each.hiddenBySection'),
+  visibleProperties: Em.computed.filterBy('configs', 'isVisible', true),
 
   /**
    * Number of the errors in all configs

+ 22 - 24
ambari-web/app/templates/common/modal_popups/config_recommendation_popup.hbs

@@ -31,30 +31,28 @@
       {{#each service in view.serviceConfigs}}
         {{#each property in service.configs}}
           {{#if property.isVisible}}
-            {{#unless property.hiddenBySection}}
-              {{#if property.warn}}
-                <tr>
-                  <td>{{property.serviceName}}</td>
-                  <td>{{property.name}}</td>
-                  <td>{{property.value}}</td>
-                  <td>
-                    <div class="property-message">{{property.warnMessage}}</div>
-                    <div class="property-description">{{property.description}}</div>
-                  </td>
-                </tr>
-              {{/if}}
-              {{#if property.error}}
-                <tr>
-                  <td>{{property.serviceName}}</td>
-                  <td>{{property.name}}</td>
-                  <td>{{property.value}}</td>
-                  <td>
-                    <div class="property-message">{{property.errorMessage}}</div>
-                    <div class="property-description">{{property.description}}</div>
-                  </td>
-                </tr>
-              {{/if}}
-            {{/unless}}
+            {{#if property.warn}}
+              <tr>
+                <td>{{property.serviceName}}</td>
+                <td>{{property.name}}</td>
+                <td>{{property.value}}</td>
+                <td>
+                  <div class="property-message">{{property.warnMessage}}</div>
+                  <div class="property-description">{{property.description}}</div>
+                </td>
+              </tr>
+            {{/if}}
+            {{#if property.error}}
+              <tr>
+                <td>{{property.serviceName}}</td>
+                <td>{{property.name}}</td>
+                <td>{{property.value}}</td>
+                <td>
+                  <div class="property-message">{{property.errorMessage}}</div>
+                  <div class="property-description">{{property.description}}</div>
+                </td>
+              </tr>
+            {{/if}}
           {{/if}}
         {{/each}}
       {{/each}}

+ 1 - 4
ambari-web/app/views/common/configs/widgets/config_widget_view.js

@@ -434,9 +434,6 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo
         var conditionalConfig = serviceConfigs.filterProperty('filename',conditionalConfigFileName).findProperty('name', conditionalConfigName);
         if (conditionalConfig) {
           conditionalConfig.set(valueAttribute, valueAttributes[key]);
-          if (valueAttribute === 'isVisible') {
-            conditionalConfig.set('hiddenBySection', !valueAttributes[key]);
-          }
         }
       }
     }
@@ -460,7 +457,7 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo
           themeResource = App.SubSectionTab.find().findProperty('name', subsectionConditionName);
         }
         themeResource.set('isHiddenByConfig', !valueAttributes['visible']);
-        themeResource.get('configs').setEach('hiddenBySection', !valueAttributes['visible']);
+        themeResource.get('configs').setEach('isVisible', valueAttributes['visible']);
       }
     }
   },

+ 1 - 6
ambari-web/test/models/configs/objects/service_config_test.js

@@ -25,35 +25,30 @@ var serviceConfig,
       Em.Object.create({
         'name': 'p1',
         'isVisible': true,
-        'hiddenBySection': false,
         'isValid': true,
         'isValidOverride': true
       }),
       Em.Object.create({
         'name': 'p2',
         'isVisible': false,
-        'hiddenBySection': false,
         'isValid': true,
         'isValidOverride': true
       }),
       Em.Object.create({
         'name': 'p3',
         'isVisible': true,
-        'hiddenBySection': true,
         'isValid': true,
         'isValidOverride': true
       }),
       Em.Object.create({
         'name': 'p4',
         'isVisible': true,
-        'hiddenBySection': false,
         'isValid': false,
         'isValidOverride': true
       }),
       Em.Object.create({
         'name': 'p5',
         'isVisible': true,
-        'hiddenBySection': false,
         'isValid': true,
         'isValidOverride': false
       })
@@ -69,7 +64,7 @@ describe('App.ServiceConfig', function () {
 
   describe('#visibleProperties', function() {
     it('returns collection of properties that should be shown', function() {
-      expect(serviceConfig.get('visibleProperties').mapProperty('name')).to.be.eql(['p1','p4','p5']);
+      expect(serviceConfig.get('visibleProperties').mapProperty('name')).to.be.eql(['p1','p3', 'p4','p5']);
     });
   });