فهرست منبع

AMBARI-8183. Install Wizard > Customize Services > Config Groups: the config group names do not show on overridden props (Max Shepel via onechiporenko)

Oleg Nechiporenko 10 سال پیش
والد
کامیت
f003a20bfe

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

@@ -172,6 +172,7 @@ var files = ['test/init_model_test',
   'test/views/main/service/item_test',
   'test/views/main/service/item_test',
   'test/views/main/service/info/config_test',
   'test/views/main/service/info/config_test',
   'test/views/main/service/info/summary_test',
   'test/views/main/service/info/summary_test',
+  'test/views/common/configs/overriddenProperty_view_test',
   'test/views/common/configs/services_config_test',
   'test/views/common/configs/services_config_test',
   'test/views/wizard/step3/hostLogPopupBody_view_test',
   'test/views/wizard/step3/hostLogPopupBody_view_test',
   'test/views/wizard/step3/hostWarningPopupBody_view_test',
   'test/views/wizard/step3/hostWarningPopupBody_view_test',

+ 0 - 1
ambari-web/app/data/HDP2/site_properties.js

@@ -2848,7 +2848,6 @@ module.exports =
       "radioName": "hive-database",
       "radioName": "hive-database",
       "isOverridable": false,
       "isOverridable": false,
       "isVisible": true,
       "isVisible": true,
-      "isObserved": true,
       "serviceName": "HIVE",
       "serviceName": "HIVE",
       "filename": "hive-env.xml",
       "filename": "hive-env.xml",
       "category": "HIVE_METASTORE",
       "category": "HIVE_METASTORE",

+ 14 - 1
ambari-web/app/views/common/configs/overriddenProperty_view.js

@@ -24,7 +24,20 @@ App.ServiceConfigView.SCPOverriddenRowsView = Ember.View.extend({
   // we are declaring this from configs.hbs ( we are initializing this from UI )
   // we are declaring this from configs.hbs ( we are initializing this from UI )
   categoryConfigs: null, // just declared as viewClass need it
   categoryConfigs: null, // just declared as viewClass need it
 
 
-  didInsertElement: function (){
+  init: function () {
+    this._super();
+    this.addObserver('isDefaultGroupSelected', this, 'setSwitchText');
+  },
+
+  didInsertElement: function () {
+    this.setSwitchText();
+  },
+
+  willDestroyElement: function () {
+    this.removeObserver('isDefaultGroupSelected', this, 'setSwitchText');
+  },
+
+  setSwitchText: function () {
     Em.$('body>.tooltip').remove();
     Em.$('body>.tooltip').remove();
     if (this.get('isDefaultGroupSelected')) {
     if (this.get('isDefaultGroupSelected')) {
       var overrides = this.get('serviceConfigProperty.overrides');
       var overrides = this.get('serviceConfigProperty.overrides');

+ 83 - 0
ambari-web/test/views/common/configs/overriddenProperty_view_test.js

@@ -0,0 +1,83 @@
+/**
+ * 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/overriddenProperty_view');
+
+describe('App.ServiceConfigView.SCPOverriddenRowsView', function () {
+
+  var view = App.ServiceConfigView.SCPOverriddenRowsView.create();
+
+  describe('#didInsertElement', function () {
+
+    beforeEach(function () {
+      sinon.spy(view, 'setSwitchText');
+      sinon.stub(App, 'tooltip', Em.K);
+    });
+
+    afterEach(function () {
+      view.setSwitchText.restore();
+      App.tooltip.restore();
+    });
+
+    it('setSwitchLinks method should be executed', function () {
+      view.didInsertElement();
+      expect(view.setSwitchText.calledOnce).to.be.true;
+    });
+
+  });
+
+  describe('#setSwitchText', function () {
+
+    var view = App.ServiceConfigView.SCPOverriddenRowsView.create({
+      serviceConfigProperty: {
+        overrides: [
+          Em.Object.create({
+            group: Em.Object.create({
+              displayName: 'hcg',
+              switchGroupTextShort: 'short',
+              switchGroupTextFull: 'full'
+            })
+          })
+        ]
+      }
+    });
+
+    beforeEach(function () {
+      sinon.stub(App, 'tooltip', Em.K);
+    });
+
+    afterEach(function () {
+      App.tooltip.restore();
+    });
+
+    it('should not modify overrides', function () {
+      view.set('isDefaultGroupSelected', false);
+      expect(view.get('serviceConfigProperty.overrides.firstObject.group.switchGroupTextShort')).to.equal('short');
+      expect(view.get('serviceConfigProperty.overrides.firstObject.group.switchGroupTextFull')).to.equal('full');
+    });
+
+    it('should set switchGroupTextShort and switchGroupTextFull', function () {
+      view.set('isDefaultGroupSelected', true);
+      expect(view.get('serviceConfigProperty.overrides.firstObject.group.switchGroupTextShort')).to.equal(Em.I18n.t('services.service.config_groups.switchGroupTextShort').format('hcg'));
+      expect(view.get('serviceConfigProperty.overrides.firstObject.group.switchGroupTextFull')).to.equal(Em.I18n.t('services.service.config_groups.switchGroupTextFull').format('hcg'));
+    });
+
+  });
+
+});