You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2016/09/28 17:28:09 UTC

[16/17] ambari git commit: AMBARI-18472 Can't switch to not current version for not default config gorup. (ababiichuk)

AMBARI-18472 Can't switch to not current version for not default config gorup. (ababiichuk)


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

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: aad2133f857e6067f37a01cce8870f27a72d933b
Parents: e44b880
Author: ababiichuk <ab...@hortonworks.com>
Authored: Wed Sep 28 10:50:10 2016 +0300
Committer: ababiichuk <ab...@hortonworks.com>
Committed: Wed Sep 28 15:30:43 2016 +0300

----------------------------------------------------------------------
 .../app/mixins/common/configs/configs_loader.js |  2 +-
 .../views/common/configs/config_history_flow.js | 46 ++++++++++----------
 .../common/configs/configs_loader_test.js       | 10 ++---
 3 files changed, 29 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aad2133f/ambari-web/app/mixins/common/configs/configs_loader.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_loader.js b/ambari-web/app/mixins/common/configs/configs_loader.js
index 87dec7f..666cef8 100644
--- a/ambari-web/app/mixins/common/configs/configs_loader.js
+++ b/ambari-web/app/mixins/common/configs/configs_loader.js
@@ -71,6 +71,7 @@ App.ConfigsLoader = Em.Mixin.create(App.GroupsMappingMixin, {
     if (!this.get('preSelectedConfigVersion')) {
       this.set('selectedVersion', this.get('currentDefaultVersion'));
     }
+    this.set('preSelectedConfigVersion', null);
   },
 
   /**
@@ -92,7 +93,6 @@ App.ConfigsLoader = Em.Mixin.create(App.GroupsMappingMixin, {
       });
       self.set('selectedConfigGroup', selectedGroup);
       self.loadSelectedVersion(preSelectedVersion.get('version'), selectedGroup);
-      self.set('preSelectedConfigVersion', null);
       preSelectedVersion = null;
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/aad2133f/ambari-web/app/views/common/configs/config_history_flow.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/config_history_flow.js b/ambari-web/app/views/common/configs/config_history_flow.js
index 07f111a..5ad65ac 100644
--- a/ambari-web/app/views/common/configs/config_history_flow.js
+++ b/ambari-web/app/views/common/configs/config_history_flow.js
@@ -173,6 +173,7 @@ App.ConfigHistoryFlowView = Em.View.extend({
       placement: 'top'
     });
     this.$(".version-info-bar-wrapper").stick_in_parent({parent: '#serviceConfig', offset_top: 10});
+    this.onChangeConfigGroup();
   },
 
   willDestroyElement: function() {
@@ -211,38 +212,37 @@ App.ConfigHistoryFlowView = Em.View.extend({
   onChangeConfigGroup: function () {
     var serviceVersions = this.get('serviceVersions');
     var selectedGroupName = this.get('controller.selectedConfigGroup.name');
+    var preselectedVersion = this.get('controller.selectedVersion');
     var startIndex = 0;
     var currentIndex = 0;
+    var isCurrentInDefaultGroupIndex = null;
+
 
     serviceVersions.setEach('isDisplayed', false);
-    //display the version belongs to current group
-    if (this.get('controller.selectedConfigGroup.isDefault')) {
-      // display current in default group
-      serviceVersions.forEach(function (serviceVersion, index) {
-        // find current in default group
-        if (serviceVersion.get('isCurrent') && serviceVersion.get('groupName') === App.ServiceConfigGroup.defaultGroupName) {
-          serviceVersion.set('isDisplayed', true);
-          currentIndex = index + 1;
-        }
-      });
-    } else {
-      // display current in selected group
+    // display selected version from config history
+    serviceVersions.forEach(function (serviceVersion, index) {
+      // find selected version in group
+      if (serviceVersion.get('version') === preselectedVersion && serviceVersion.get('groupName') === selectedGroupName) {
+        serviceVersion.set('isDisplayed', true);
+        currentIndex = index + 1;
+      }
+    });
+    // display current in selected group
+    if (!currentIndex) {
       serviceVersions.forEach(function (serviceVersion, index) {
         // find current in selected group
         if (serviceVersion.get('isCurrent') && serviceVersion.get('groupName') === selectedGroupName) {
           serviceVersion.set('isDisplayed', true);
           currentIndex = index + 1;
         }
+        if (serviceVersion.get('isCurrent') && serviceVersion.get('groupName') === App.ServiceConfigGroup.defaultGroupName) {
+          isCurrentInDefaultGroupIndex = index;
+        }
       });
-      // no current version for selected group, show default group current version
-      if (currentIndex == 0) {
-        serviceVersions.forEach(function (serviceVersion, index) {
-          // find current in default group
-          if (serviceVersion.get('isCurrent') && serviceVersion.get('groupName') === App.ServiceConfigGroup.defaultGroupName) {
-            currentIndex = index + 1;
-            serviceVersion.set('isDisplayed', true);
-          }
-        });
+      // if there is no current version in selected group show current version from default group
+      if (!currentIndex) {
+        serviceVersions[isCurrentInDefaultGroupIndex].set('isDisplayed', true);
+        currentIndex = isCurrentInDefaultGroupIndex + 1;
       }
     }
     // show current version as the last one
@@ -251,7 +251,7 @@ App.ConfigHistoryFlowView = Em.View.extend({
     }
     this.set('startIndex', startIndex);
     this.adjustFlowView();
-  }.observes('controller.selectedConfigGroup.name'),
+  }.observes('controller.selectedConfigGroup'),
 
   /**
    *  define the first element in viewport
@@ -641,4 +641,4 @@ App.ConfigHistoryDropdownSubMenuView = Em.View.extend({
       $("#config_version_popup").removeAttr('style');
     }
   })
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/aad2133f/ambari-web/test/mixins/common/configs/configs_loader_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/configs_loader_test.js b/ambari-web/test/mixins/common/configs/configs_loader_test.js
index e718bbe..8f22b44 100644
--- a/ambari-web/test/mixins/common/configs/configs_loader_test.js
+++ b/ambari-web/test/mixins/common/configs/configs_loader_test.js
@@ -103,6 +103,11 @@ describe('App.ConfigsLoader', function() {
       mixin.loadServiceConfigVersionsSuccess({items: []});
       expect(mixin.get('selectedVersion')).to.be.equal('v1');
     });
+
+    it("preSelectedConfigVersion should be null", function() {
+      mixin.loadServiceConfigVersionsSuccess();
+      expect(mixin.get('preSelectedConfigVersion')).to.be.null;
+    });
   });
 
   describe("#loadPreSelectedConfigVersion()", function () {
@@ -213,11 +218,6 @@ describe('App.ConfigsLoader', function() {
       mixin.loadPreSelectedConfigVersion();
       expect(mixin.loadSelectedVersion.calledOnce).to.be.true;
     });
-
-    it("preSelectedConfigVersion should be null", function() {
-      mixin.loadPreSelectedConfigVersion();
-      expect(mixin.get('preSelectedConfigVersion')).to.be.null;
-    });
   });
 
   describe("#loadCurrentVersions()", function () {