瀏覽代碼

AMBARI-8854. Alerts UI: Misc Config Tab is broken on Add Service Wizard (onechiporenko)

Oleg Nechiporenko 10 年之前
父節點
當前提交
84d642fb1d

+ 1 - 0
ambari-web/app/assets/test/tests.js

@@ -214,6 +214,7 @@ var files = ['test/init_model_test',
   'test/views/main/admin/highAvailability/nameNode/wizard_view_test',
   'test/views/common/configs/overriddenProperty_view_test',
   'test/views/common/configs/services_config_test',
+  'test/views/common/configs/custom_category_views/notification_configs_view_test',
   'test/views/wizard/step3/hostLogPopupBody_view_test',
   'test/views/wizard/step3/hostWarningPopupBody_view_test',
   'test/views/wizard/step3/hostWarningPopupFooter_view_test',

+ 7 - 2
ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js

@@ -21,7 +21,7 @@ var App = require('app');
 /**
  * Custom view for Notification section for MISC tab
  * Used only in the Install Wizard
- * Show configs for creating Init Notification (@see 'data/HDP2/site_properties' for list of the configs used here)
+ * Show configs for creating Init Notification (@see 'data/site_properties' for list of the configs used here)
  *
  * @type {App.NotificationsConfigsView}
  */
@@ -53,8 +53,13 @@ App.NotificationsConfigsView = App.ServiceConfigsByCategoryView.extend({
     return this.get('categoryConfigs').findProperty('name', 'smtp_use_auth');
   }.property(),
 
-  willInsertElement: function () {
+  /**
+   * Empty categoryConfigsAll means that user isn't at Installer, so manage notification view shouldn't be processed
+   * @method didInsertElement
+   */
+  didInsertElement: function () {
     this._super();
+    if (!this.get('categoryConfigsAll.length')) return;
     this.set('createNotification', this.get('categoryConfigsAll').findProperty('name', 'create_notification').get('value'));
     this.set('tlsOrSsl', this.get('categoryConfigsAll').findProperty('name', 'mail.smtp.starttls.enable').get('value') ? 'tls' : 'ssl');
     var smtp_use_auth = this.get('categoryConfigsAll').findProperty('name', 'smtp_use_auth');

+ 61 - 0
ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js

@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('views/common/configs/custom_category_views/notification_configs_view');
+var view;
+
+describe('App.NotificationsConfigsView', function () {
+
+  beforeEach(function () {
+    view = App.NotificationsConfigsView.create({
+      $: function() {
+        return {show: Em.K, hide: Em.K};
+      },
+      category: {
+        name: 'name'
+      },
+      serviceConfigs: [],
+      parentView: Em.View.create({
+        filter: '',
+        columns: []
+      })
+    });
+  });
+
+  describe('#didInsertElement', function () {
+
+    beforeEach(function () {
+      sinon.stub(view, 'updateCategoryConfigs', Em.K);
+    });
+
+    afterEach(function () {
+      view.updateCategoryConfigs.restore();
+    });
+
+    it('should not do nothing if no configs', function () {
+
+      view.set('categoryConfigsAll', []);
+      view.didInsertElement();
+      expect(view.updateCategoryConfigs.called).to.equal(false);
+
+    });
+
+  });
+
+});