Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 5eb3bb432 -> 0fc586fb3


AMBARI-18847. Issues after fast switching service page tabs (akovalenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0fc586fb
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0fc586fb
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0fc586fb

Branch: refs/heads/branch-2.5
Commit: 0fc586fb3ac5007c70b6aab6a8a65af7807cd1ec
Parents: 5eb3bb4
Author: Aleksandr Kovalenko <akovale...@hortonworks.com>
Authored: Fri Nov 11 14:43:11 2016 +0200
Committer: Aleksandr Kovalenko <akovale...@hortonworks.com>
Committed: Fri Nov 11 15:33:38 2016 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 26 +++--------
 .../app/controllers/wizard/step7_controller.js  |  3 +-
 ambari-web/app/mappers/configs/themes_mapper.js |  4 +-
 ambari-web/app/mixins.js                        |  1 +
 .../app/mixins/common/track_request_mixin.js    | 47 ++++++++++++++++++++
 .../app/mixins/common/widgets/widget_mixin.js   |  8 ++--
 .../app/mixins/main/service/groups_mapping.js   |  4 +-
 .../models/configs/objects/service_config.js    |  1 +
 ambari-web/app/utils/blueprint.js               |  4 +-
 ambari-web/app/utils/ember_reopen.js            |  2 +-
 .../test/controllers/wizard/step7_test.js       | 13 ++++++
 11 files changed, 82 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js 
b/ambari-web/app/controllers/main/service/info/configs.js
index 31ea248..946a1b9 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -21,7 +21,7 @@ var batchUtils = require('utils/batch_scheduled_requests');
 
 App.MainServiceInfoConfigsController = 
Em.Controller.extend(App.AddSecurityConfigs, App.ConfigsLoader,
   App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ThemesMappingMixin, 
App.ConfigsSaverMixin,
-  App.ConfigsComparator, App.ComponentActionsByConfigs, {
+  App.ConfigsComparator, App.ComponentActionsByConfigs, App.TrackRequestMixin, 
{
 
   name: 'mainServiceInfoConfigsController',
 
@@ -43,8 +43,6 @@ App.MainServiceInfoConfigsController = 
Em.Controller.extend(App.AddSecurityConfi
 
   selectedConfigGroup: null,
 
-  requestsInProgress: [],
-
   groupsStore: App.ServiceConfigGroup.find(),
 
   /**
@@ -232,25 +230,11 @@ App.MainServiceInfoConfigsController = 
Em.Controller.extend(App.AddSecurityConfi
   },
 
   /**
-   * register request to view to track his progress
-   * @param {$.ajax} request
-   * @method trackRequest
-   */
-  trackRequest: function (request) {
-    this.get('requestsInProgress').push(request);
-  },
-
-  /**
    * clear and set properties to default value
    * @method clearStep
    */
   clearStep: function () {
-    this.get('requestsInProgress').forEach(function(r) {
-      if (r && r.readyState !== 4) {
-        r.abort();
-      }
-    });
-    this.get('requestsInProgress').clear();
+    this.abortRequests();
     App.set('componentToBeAdded', {});
     App.set('componentToBeDeleted', {});
     this.clearLoadInfo();
@@ -305,14 +289,14 @@ App.MainServiceInfoConfigsController = 
Em.Controller.extend(App.AddSecurityConfi
       acc.push(i);
       return Array.prototype.concat.apply(acc, 
App.StackService.find(i).get('dependentServiceNames').toArray()).without(serviceName).uniq();
     }, []));
-    this.loadConfigTheme(serviceName).always(function () {
+    this.trackRequest(this.loadConfigTheme(serviceName).always(function () {
       if (self.get('preSelectedConfigVersion')) {
         self.loadPreSelectedConfigVersion();
       } else {
         self.loadCurrentVersions();
       }
-      self.loadServiceConfigVersions();
-    });
+      self.trackRequest(self.loadServiceConfigVersions());
+    }));
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js 
b/ambari-web/app/controllers/wizard/step7_controller.js
index e466d4e..3d22fe9 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -42,7 +42,7 @@ var App = require('app');
  * @property {?object[]} slaveComponentHosts
  */
 
-App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, 
App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, App.GroupsMappingMixin, {
+App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, 
App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, App.GroupsMappingMixin, 
App.TrackRequestMixin, {
 
   name: 'wizardStep7Controller',
 
@@ -299,6 +299,7 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
    * @method clearStep
    */
   clearStep: function () {
+    this.abortRequests();
     this.setProperties({
       configValidationGlobalMessage: [],
       submitButtonClicked: false,

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/mappers/configs/themes_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/themes_mapper.js 
b/ambari-web/app/mappers/configs/themes_mapper.js
index f141156..8ad51bd 100644
--- a/ambari-web/app/mappers/configs/themes_mapper.js
+++ b/ambari-web/app/mappers/configs/themes_mapper.js
@@ -329,8 +329,8 @@ App.themesMapper = App.QuickDataMapper.create({
       var configProperty = App.configsCollection.getConfig(configId);
 
       if (configProperty) {
-        configProperty.widget = widget.widget;
-        configProperty.widgetType = Em.get(widget, 'widget.type');
+        Em.set(configProperty, 'widget', widget.widget);
+        Em.set(configProperty, 'widgetType', Em.get(widget, 'widget.type'));
       } else {
         var split = widget.config.split("/");
         var fileName =  split[0] + '.xml';

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/mixins.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js
index 7a78f6d..ad682d7 100644
--- a/ambari-web/app/mixins.js
+++ b/ambari-web/app/mixins.js
@@ -29,6 +29,7 @@ require('mixins/common/reload_popup');
 require('mixins/common/serverValidator');
 require('mixins/common/table_server_view_mixin');
 require('mixins/common/table_server_mixin');
+require('mixins/common/track_request_mixin');
 require('mixins/main/dashboard/widgets/editable');
 require('mixins/main/dashboard/widgets/editable_with_limit');
 require('mixins/main/dashboard/widgets/single_numeric_threshold');

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/mixins/common/track_request_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/track_request_mixin.js 
b/ambari-web/app/mixins/common/track_request_mixin.js
new file mode 100644
index 0000000..6fcc991
--- /dev/null
+++ b/ambari-web/app/mixins/common/track_request_mixin.js
@@ -0,0 +1,47 @@
+/**
+ * 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');
+
+App.TrackRequestMixin = Em.Mixin.create({
+
+  requestsInProgress: [],
+
+  /**
+   * register request to view to track his progress
+   * @param {$.ajax} request
+   * @method trackRequest
+   */
+  trackRequest: function (request) {
+    this.get('requestsInProgress').push(request);
+  },
+
+  /**
+   * abort all tracked requests
+   * @method abortRequest
+   */
+  abortRequests: function () {
+    this.get('requestsInProgress').forEach(function(r) {
+      if (r && r.readyState !== 4) {
+        r.abort();
+      }
+    });
+    this.get('requestsInProgress').clear();
+  }
+
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/mixins/common/widgets/widget_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/widgets/widget_mixin.js 
b/ambari-web/app/mixins/common/widgets/widget_mixin.js
index 5ec4dd6..65d6160 100644
--- a/ambari-web/app/mixins/common/widgets/widget_mixin.js
+++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js
@@ -458,9 +458,11 @@ App.WidgetMixin = Ember.Mixin.create({
 
     if (this.get('isLoaded')) {
       Em.run.next(function(){
-        App.tooltip(self.$(".corner-icon > .icon-copy"), {title: 
Em.I18n.t('common.clone')});
-        App.tooltip(self.$(".corner-icon > .icon-edit"), {title: 
Em.I18n.t('common.edit')});
-        App.tooltip(self.$(".corner-icon > .icon-save"), {title: 
Em.I18n.t('common.export')});
+        if (self.get('state') === 'inDOM') {
+          App.tooltip(self.$(".corner-icon > .icon-copy"), {title: 
Em.I18n.t('common.clone')});
+          App.tooltip(self.$(".corner-icon > .icon-edit"), {title: 
Em.I18n.t('common.edit')});
+          App.tooltip(self.$(".corner-icon > .icon-save"), {title: 
Em.I18n.t('common.export')});
+        }
       });
     }
   }.observes('isLoaded'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/mixins/main/service/groups_mapping.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/groups_mapping.js 
b/ambari-web/app/mixins/main/service/groups_mapping.js
index 3271714..df2fabf 100644
--- a/ambari-web/app/mixins/main/service/groups_mapping.js
+++ b/ambari-web/app/mixins/main/service/groups_mapping.js
@@ -37,7 +37,7 @@ App.GroupsMappingMixin = Em.Mixin.create({
       this.set('configGroupsAreLoaded', true);
       dfd.resolve();
     } else {
-      App.ajax.send({
+      this.trackRequest(App.ajax.send({
         name: 'configs.config_groups.load.services',
         sender: this,
         data: {
@@ -45,7 +45,7 @@ App.GroupsMappingMixin = Em.Mixin.create({
           dfd: dfd
         },
         success: 'saveConfigGroupsToModel'
-      });
+      }));
     }
     return dfd.promise();
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/models/configs/objects/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/objects/service_config.js 
b/ambari-web/app/models/configs/objects/service_config.js
index a0800fa..7d07467 100644
--- a/ambari-web/app/models/configs/objects/service_config.js
+++ b/ambari-web/app/models/configs/objects/service_config.js
@@ -63,6 +63,7 @@ App.ServiceConfig = Ember.Object.extend({
   }.observes('configs.@each.isActive', 'configs.@each.isRequiredByAgent', 
'configs.@each.value'),
 
   setActivePropertiesOnce: function() {
+    if (this.get('isDestroyed')) return false;
     var activeProperties = this.get('configs').filter(function(c) {
       return c.get('isActive') && (c.get('isRequiredByAgent') || 
c.get('isRequired'));
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/utils/blueprint.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/blueprint.js 
b/ambari-web/app/utils/blueprint.js
index 696f7a4..f1d0514 100644
--- a/ambari-web/app/utils/blueprint.js
+++ b/ambari-web/app/utils/blueprint.js
@@ -319,7 +319,9 @@ module.exports = {
   buildConfigsJSON: function (stepConfigs) {
     var configurations = {};
     stepConfigs.forEach(function (stepConfig) {
-      stepConfig.get('configs').forEach(function (config) {
+      var configs = stepConfig.get('configs');
+      if (!configs) return false;
+      configs.forEach(function (config) {
         if (config.get('filename') === 'cluster-env.xml' || 
config.get('isRequiredByAgent')) {
           var type = 
App.config.getConfigTagFromFileName(config.get('filename'));
           if (!configurations[type]) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/app/utils/ember_reopen.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ember_reopen.js 
b/ambari-web/app/utils/ember_reopen.js
index bf091da..8e47091 100644
--- a/ambari-web/app/utils/ember_reopen.js
+++ b/ambari-web/app/utils/ember_reopen.js
@@ -233,7 +233,7 @@ Ember._HandlebarsBoundView.reopen({
     if(!this.get('isDestroyed') && !this.get('isDestroying')){
       this._super(buffer);
     } else {
-      console.debug('Calling set on destroyed view');
+      console.debug('Calling render on destroyed view');
     }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc586fb/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js 
b/ambari-web/test/controllers/wizard/step7_test.js
index 3ec63d1..cd6b21c 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -372,6 +372,15 @@ describe('App.InstallerStep7Controller', function () {
   });
 
   describe('#clearStep', function () {
+
+    beforeEach(function () {
+      sinon.stub(installerStep7Controller, 'abortRequests');
+    });
+
+    afterEach(function () {
+      installerStep7Controller.abortRequests.restore();
+    });
+
     it('should clear stepConfigs', function () {
       installerStep7Controller.set('stepConfigs', [
         {},
@@ -394,6 +403,10 @@ describe('App.InstallerStep7Controller', function () {
       installerStep7Controller.clearStep();
       
expect(installerStep7Controller.get('filterColumns').everyProperty('selected', 
false)).to.equal(true);
     });
+    it('should call abortRequests', function () {
+      installerStep7Controller.clearStep();
+      expect(installerStep7Controller.abortRequests.calledOnce).to.be.true;
+    });
   });
 
   describe('#getConfigTags', function () {

Reply via email to