AMBARI-21647 PATCH upgrade with version less than current should be displayed. 
(atkach)


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

Branch: refs/heads/branch-2.6
Commit: 7b52efaa4cb900295e535187bdd6d6f62cfc546e
Parents: 902ffc3
Author: Andrii Tkach <atk...@apache.org>
Authored: Thu Aug 3 14:08:55 2017 +0300
Committer: Andrii Tkach <atk...@apache.org>
Committed: Thu Aug 3 14:08:55 2017 +0300

----------------------------------------------------------------------
 .../main/admin/stack_and_upgrade_controller.js  |  3 +-
 ambari-web/app/styles/stack_versions.less       |  2 +-
 .../main/admin/stack_upgrade/versions.hbs       |  2 +-
 .../main/admin/stack_upgrade/versions_view.js   | 22 +++++++++---
 .../admin/stack_and_upgrade_controller_test.js  |  6 ++--
 .../admin/stack_upgrade/version_view_test.js    | 37 ++++++++++++++++++++
 6 files changed, 63 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7b52efaa/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js 
b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index c9f27d6..6a83db5 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -396,7 +396,8 @@ App.MainAdminStackAndUpgradeController = 
Em.Controller.extend(App.LocalStorage,
       this.set('currentVersion', {
         repository_version: 
currentVersion.get('repositoryVersion.repositoryVersion'),
         repository_name: currentVersion.get('repositoryVersion.displayName'),
-        id: currentVersion.get('repositoryVersion.id')
+        id: currentVersion.get('repositoryVersion.id'),
+        stack_name: currentVersion.get('repositoryVersion.stackVersionType')
       });
     }
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b52efaa/ambari-web/app/styles/stack_versions.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/stack_versions.less 
b/ambari-web/app/styles/stack_versions.less
index 4174dc0..6512a2b 100644
--- a/ambari-web/app/styles/stack_versions.less
+++ b/ambari-web/app/styles/stack_versions.less
@@ -272,7 +272,7 @@
   }
   .version-column {
     min-height: 500px;
-    width: 115px;
+    min-width: 145px;
     margin: 15px 7px 0px 7px;
     .version-column-display-name {
       color: #000;

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b52efaa/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs 
b/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs
index c185f10..6eb1ef8 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs
@@ -58,7 +58,7 @@
   <div class="span10 versions-slides">
     {{#if isLoaded}}
       <div class="versions-slides-bar">
-        {{#each version in view.repoVersionsDisplay}}
+        {{#each version in view.sortedRepoVersions}}
           {{#if version.isVisible}}
             {{view App.UpgradeVersionColumnView contentBinding="version"}}
           {{/if}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b52efaa/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js 
b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
index 2647052..ce67d8a 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
@@ -127,10 +127,23 @@ App.MainAdminStackVersionsView = Em.View.extend({
    */
   repoVersions: App.RepositoryVersion.find(),
 
-  repoVersionsDisplay: function () {
-    return this.get('repoVersions').toArray().sort(function (a, b) {
-      return (a.get('repositoryVersion') > b.get('repositoryVersion')) ? 1 : 
((b.get('repositoryVersion') > a.get('repositoryVersion')) ? -1 : 0);
+  /**
+   * PATCH version should be displayed right after parent STANDARD version
+   */
+  sortedRepoVersions: function () {
+    var allVersions = this.get('repoVersions').filterProperty('isPatch', 
false).toArray().sort(function (a, b) {
+      return stringUtils.compareVersions(a.get('repositoryVersion'), 
b.get('repositoryVersion'));
+    });
+    this.get('repoVersions').filterProperty('isPatch').toArray().sort(function 
(a, b) {
+      return stringUtils.compareVersions(b.get('repositoryVersion'), 
a.get('repositoryVersion'));
+    }).forEach(function(patchVersion) {
+      var displayNames = allVersions.mapProperty('displayNameSimple');
+      var index = displayNames.indexOf(patchVersion.get('displayNameSimple'));
+      if (index !== -1) {
+        allVersions.splice(index + 1, 0, patchVersion);
+      }
     });
+    return allVersions;
   }.property('repoVersions'),
 
   /**
@@ -171,7 +184,8 @@ App.MainAdminStackVersionsView = Em.View.extend({
     } else {
       return versions.filter(function(v) {
         if (v.get('stackVersionType') === Em.get(currentVersion, 
'stack_name')) {
-          return stringUtils.compareVersions(v.get('repositoryVersion'), 
Em.get(currentVersion, 'repository_version')) >= 0;
+          // PATCH version should be visible even if patch number lower than 
current
+          return v.get('isPatch') || 
stringUtils.compareVersions(v.get('repositoryVersion'), Em.get(currentVersion, 
'repository_version')) >= 0;
         }
         return v.get('isCompatible');
       }).toArray();

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b52efaa/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js 
b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index ea71b28..2c4675b 100644
--- 
a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ 
b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -130,7 +130,8 @@ describe('App.MainAdminStackAndUpgradeController', 
function() {
         repositoryVersion: {
           id: '1',
           repositoryVersion: '2.2',
-          displayName: 'HDP-2.2'
+          displayName: 'HDP-2.2',
+          stackVersionType: 'HDP'
         }
       })]);
       controller.load();
@@ -158,7 +159,8 @@ describe('App.MainAdminStackAndUpgradeController', 
function() {
       expect(controller.get('currentVersion')).to.eql({
         "id": "1",
         "repository_version": "2.2",
-        "repository_name": "HDP-2.2"
+        "repository_name": "HDP-2.2",
+        "stack_name": "HDP"
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b52efaa/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js 
b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
index 32dc2e0..c2a6c2d 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
@@ -485,4 +485,41 @@ describe('App.mainAdminStackVersionsView', function () {
       expect(view.get('controller').load.called).to.be.false;
     });
   });
+
+  describe('#sortedRepoVersions', function() {
+    var repoVersions = [
+      Em.Object.create({
+        isPatch: false,
+        repositoryVersion: '2.5.3.0-10',
+        displayNameSimple: '2.5.3.0'
+      }),
+      Em.Object.create({
+        isPatch: false,
+        repositoryVersion: '2.5.4.0-10',
+        displayNameSimple: '2.5.4.0'
+      }),
+      Em.Object.create({
+        isPatch: true,
+        repositoryVersion: '2.5.3.0-9',
+        displayNameSimple: '2.5.3.0'
+      }),
+      Em.Object.create({
+        isPatch: true,
+        repositoryVersion: '2.5.3.0-11',
+        displayNameSimple: '2.5.3.0'
+      }),
+      Em.Object.create({
+        isPatch: false,
+        repositoryVersion: '2.5.4.0-12',
+        displayNameSimple: '2.5.4.0'
+      })
+    ];
+
+    it('should sort repository versions', function() {
+      view.set('repoVersions', repoVersions);
+      
expect(view.get('sortedRepoVersions').mapProperty('repositoryVersion')).to.be.eql([
+        '2.5.3.0-10', '2.5.3.0-9', '2.5.3.0-11', '2.5.4.0-10', '2.5.4.0-12'
+      ]);
+    });
+  });
 });

Reply via email to