Browse Source

AMBARI-18617. Adding custom property to hive-site adds it to other 'Custom' panels on hive. (jaimin)

Jaimin Jetly 8 năm trước cách đây
mục cha
commit
edbc4865f2

+ 15 - 9
ambari-web/app/views/common/configs/service_configs_by_category_view.js

@@ -47,13 +47,6 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
    */
   serviceConfigs: null,
 
-  /**
-   * Configs for current category filtered by <code>isVisible</code>
-   * and sorted by <code>displayType</code> and <code>index</code>
-   * @type {App.ServiceConfigProperty[]}
-   */
-  categoryConfigs: [],
-
   /**
    * This is array of all the properties which apply
    * to this category, irrespective of visibility. This
@@ -64,9 +57,20 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
    */
   categoryConfigsAll: [],
 
+  /**
+   * Configs for current category filtered by <code>isVisible</code>
+   * and sorted by <code>displayType</code> and <code>index</code>
+   * @type {App.ServiceConfigProperty[]}
+   */
+  categoryConfigs: [],
+
   didInsertElement: function () {
     var self = this;
-    this.setCategoryConfigs();
+    // If `this.categoryConfigsAll` is a computed property then don't set it.
+    // some extended class like `App.NotificationsConfigsView` overrides `categoryConfigsAll` as computed property
+    if ($.isArray(this.categoryConfigsAll)) {
+      this.setCategoryConfigsAll();
+    }
     this.setVisibleCategoryConfigs();
     var isCollapsed = this.calcIsCollapsed();
     this.set('category.isCollapsed', isCollapsed);
@@ -94,7 +98,9 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
     Em.run.once(this, 'addConfigToCategoryConfigs');
   }.observes('categoryConfigsAll.@each.isVisible'),
 
-  setCategoryConfigs: function () {
+  setCategoryConfigsAll: function () {
+    // reset `categoryConfigsAll` to empty array
+    this.set('categoryConfigsAll', []);
     var categoryConfigsAll = this.get('serviceConfigs').filterProperty('category', this.get('category.name'));
     if (categoryConfigsAll && categoryConfigsAll.length) {
       this.set('categoryConfigsAll',categoryConfigsAll);

+ 10 - 4
ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js

@@ -70,20 +70,26 @@ describe('App.NotificationsConfigsView', function () {
       var configs = [
         Em.Object.create({
           name: "create_notification",
-          value: 'yes'
+          value: 'yes',
+          filename: "alert_notification"
         }),
         Em.Object.create({
           name: 'mail.smtp.starttls.enable',
-          value: false
+          value: false,
+          filename: "alert_notification"
         }),
         Em.Object.create({
           name: 'smtp_use_auth',
-          value: 'true'
+          value: 'true',
+          filename: "alert_notification"
         })
       ];
 
       beforeEach(function () {
-        view.set('categoryConfigsAll', configs);
+        view.set('serviceConfigs', configs);
+        view.reopen({
+          categoryConfigsAll: Em.computed.filterBy('serviceConfigs', 'filename', 'alert_notification')
+        });
         view.didInsertElement();
       });
 

+ 1 - 1
ambari-web/test/views/common/configs/service_configs_by_category_view_test.js

@@ -312,7 +312,7 @@ describe('App.ServiceConfigsByCategoryView', function () {
           filteredCategoryConfigs: Em.K,
           collapseCategory: Em.K
         });
-        view.setCategoryConfigs();
+        view.setCategoryConfigsAll();
         view.setVisibleCategoryConfigs();
         expect(view.get('categoryConfigs').mapProperty('resultId')).to.deep.equal(result);
         view.destroy();