ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-9944 RU: web should not display older versions by default. (ababiichuk)
Date Thu, 05 Mar 2015 18:52:01 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.0 e9623812e -> 2cfc618ec


AMBARI-9944 RU: web should not display older versions by default. (ababiichuk)


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

Branch: refs/heads/branch-2.0.0
Commit: 2cfc618ecbcfd4b055fd82d68d02efdf94b69a83
Parents: e962381
Author: aBabiichuk <ababiichuk@hortonworks.com>
Authored: Thu Mar 5 20:50:57 2015 +0200
Committer: aBabiichuk <ababiichuk@hortonworks.com>
Committed: Thu Mar 5 20:51:54 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/config.js                        |  1 +
 ambari-web/app/mappers/hosts_mapper.js          |  7 +-
 ambari-web/app/models/host_stack_version.js     |  2 +-
 ambari-web/app/templates/main/host.hbs          |  2 +-
 .../main/admin/stack_upgrade/versions_view.js   | 10 ++-
 ambari-web/app/views/main/host.js               | 10 +--
 .../app/views/main/host/stack_versions_view.js  |  4 +-
 .../admin/stack_upgrade/version_view_test.js    | 72 ++++++++++++--------
 .../views/main/host/stack_versions_view_test.js | 10 +--
 9 files changed, 74 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc618e/ambari-web/app/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js
index 02bf616..2bcdab4 100644
--- a/ambari-web/app/config.js
+++ b/ambari-web/app/config.js
@@ -64,6 +64,7 @@ App.enableExperimental = false;
 App.supports = {
   preUpgradeCheck: true,
   stackUpgrade: true,
+  displayOlderVersions: false,
   autoRollbackHA: false,
   alwaysEnableManagedMySQLForHive: false,
   preKerberizeCheck: false,

http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc618e/ambari-web/app/mappers/hosts_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/hosts_mapper.js b/ambari-web/app/mappers/hosts_mapper.js
index 5af2dae..f09da5d 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -74,7 +74,8 @@ App.hostsMapper = App.QuickDataMapper.create({
     version: 'HostStackVersions.version',
     status: 'HostStackVersions.state',
     host_name: 'host_name',
-    host_id: 'host_name'
+    host_id: 'host_name',
+    is_visible: 'is_visible'
   },
   map: function (json, returnMapped) {
     returnMapped = !!returnMapped;
@@ -109,8 +110,12 @@ App.hostsMapper = App.QuickDataMapper.create({
         }, this);
 
         if (App.get('supports.stackUpgrade')) {
+          var currentVersion = item.stack_versions.findProperty('HostStackVersions.state',
'CURRENT');
+          var currentVersionNumber = Em.get(currentVersion.repository_versions[0], 'RepositoryVersions.repository_version');
           item.stack_versions.forEach(function (stackVersion) {
             stackVersion.host_name = item.Hosts.host_name;
+            stackVersion.is_visible = stringUtils.compareVersions(Em.get(stackVersion.repository_versions[0],
'RepositoryVersions.repository_version'), currentVersionNumber) >= 0
+              || App.get('supports.displayOlderVersions') || !currentVersionNumber;
             stackVersions.push(this.parseIt(stackVersion, this.stackVersionConfig));
           }, this);
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc618e/ambari-web/app/models/host_stack_version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host_stack_version.js b/ambari-web/app/models/host_stack_version.js
index 55639ab..2d49a76 100644
--- a/ambari-web/app/models/host_stack_version.js
+++ b/ambari-web/app/models/host_stack_version.js
@@ -24,7 +24,7 @@ App.HostStackVersion = DS.Model.extend({
   repo: DS.belongsTo('App.Repository'),
   repoVersion: DS.attr('string'),
   displayName: DS.attr('string'),
-
+  isVisible: DS.attr('boolean', {defaultValue: true}),
   /**
    * possible property value defined at App.HostStackVersion.statusDefinition
    * @type {string}

http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc618e/ambari-web/app/templates/main/host.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host.hbs b/ambari-web/app/templates/main/host.hbs
index ec3ba93..dce28a4 100644
--- a/ambari-web/app/templates/main/host.hbs
+++ b/ambari-web/app/templates/main/host.hbs
@@ -140,7 +140,7 @@
               {{view.currentVersion}}
             </a>
             <div {{bindAttr class="view.isVersionsCollapsed:noDisplay:display :stack-versions
:collapsed-list"}}>
-              {{{view.versionlabels}}}
+              {{{view.versionLabels}}}
             </div>
           </td>
           <td class="host-table-components">

http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc618e/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 e6832f8..3b2848d 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
@@ -138,7 +138,7 @@ App.MainAdminStackVersionsView = Em.View.extend({
   filterBy: function (versions, filter) {
     var currentVersion = this.get('controller.currentVersion');
     if (filter && filter.get('value')) {
-      return versions.filter(function (version) {
+      versions = versions.filter(function (version) {
         var status = version.get('status');
         if (status === 'INSTALLED' && ['UPGRADE_READY', 'INSTALLED'].contains(filter.get('value')))
{
           if (filter.get('value') === 'UPGRADE_READY') {
@@ -153,7 +153,13 @@ App.MainAdminStackVersionsView = Em.View.extend({
         }
       }, this);
     }
-    return versions.toArray();
+    if (App.get('supports.displayOlderVersions')) {
+      return versions.toArray();
+    } else {
+      return versions.filter(function(v) {
+        return stringUtils.compareVersions(v.get('repositoryVersion'), Em.get(currentVersion,
'repository_version')) >= 0;
+      }).toArray();
+    }
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc618e/ambari-web/app/views/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host.js b/ambari-web/app/views/main/host.js
index 4535c0f..67f3a26 100644
--- a/ambari-web/app/views/main/host.js
+++ b/ambari-web/app/views/main/host.js
@@ -599,7 +599,7 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
      * @returns {Boolean}
      */
     hasSingleVersion: function() {
-      return this.get('content.stackVersions.length') < 2;
+      return this.get('content.stackVersions').filterProperty('isVisible', true).length <
2;
     }.property('content.stackVersions.length'),
 
     /**
@@ -616,8 +616,10 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
      * String with list of host components <code>displayName</code>
      * @returns {String}
      */
-    versionlabels: function () {
-      return this.get('content.stackVersions').filterProperty('isCurrent', false).map(function
(version) {
+    versionLabels: function () {
+      return this.get('content.stackVersions').filter(function(sv) {
+        return sv.get('isVisible') === true && sv.get('isCurrent') === false;
+      }).map(function (version) {
         return version.get('displayName');
       }).join("<br />");
     }.property('content.stackVersions.length'),
@@ -1047,7 +1049,7 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
               value: '',
               label: Em.I18n.t('common.all')
             }
-          ].concat(this.get('controller.allHostStackVersions').mapProperty('displayName').uniq().map(function
(version) {
+          ].concat(this.get('controller.allHostStackVersions').filterProperty('isVisible',
true).mapProperty('displayName').uniq().map(function (version) {
             return {
               value: version,
               label: version

http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc618e/ambari-web/app/views/main/host/stack_versions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/stack_versions_view.js b/ambari-web/app/views/main/host/stack_versions_view.js
index 5e57a21..df1e38f 100644
--- a/ambari-web/app/views/main/host/stack_versions_view.js
+++ b/ambari-web/app/views/main/host/stack_versions_view.js
@@ -35,8 +35,8 @@ App.MainHostStackVersionsView = App.TableView.extend({
    * @type {Ember.Array}
    */
   content: function () {
-    return this.get('host.stackVersions');
-  }.property('host.stackVersions'),
+    return this.get('host.stackVersions').filterProperty('isVisible', true);
+  }.property('host.stackVersions.length'),
 
   /**
    * return filtered number of all content number information displayed on the page footer
bar

http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc618e/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 8e12b5c..5a457bf 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
@@ -33,10 +33,12 @@ describe('App.mainAdminStackVersionsView', function () {
   describe("#filterBy()", function () {
     var versions = [
       Em.Object.create({
-        status: "INIT"
+        status: "INIT",
+        repositoryVersion: "2.2.1.1"
       }),
       Em.Object.create({
-        status: "INSTALLING"
+        status: "INSTALLING",
+        repositoryVersion: "2.2.1.1"
       }),
       Em.Object.create({
         status: "INSTALLED",
@@ -47,19 +49,24 @@ describe('App.mainAdminStackVersionsView', function () {
         repositoryVersion: "2.2.2.1"
       }),
       Em.Object.create({
-        status: "INSTALL_FAILED"
+        status: "INSTALL_FAILED",
+        repositoryVersion: "2.2.1.1"
       }),
       Em.Object.create({
-        status: "OUT_OF_SYNC"
+        status: "OUT_OF_SYNC",
+        repositoryVersion: "2.2.1.1"
       }),
       Em.Object.create({
-        status: "UPGRADING"
+        status: "UPGRADING",
+        repositoryVersion: "2.2.1.1"
       }),
       Em.Object.create({
-        status: "UPGRADED"
+        status: "UPGRADED",
+        repositoryVersion: "2.2.1.1"
       }),
       Em.Object.create({
-        status: "CURRENT"
+        status: "CURRENT",
+        repositoryVersion: "2.2.1.1"
       })
     ];
 
@@ -70,33 +77,36 @@ describe('App.mainAdminStackVersionsView', function () {
         }),
         filteredVersions: [
           Em.Object.create({
-            status: "INIT"
+            status: "INIT",
+            repositoryVersion: "2.2.1.1"
           }),
           Em.Object.create({
-            status: "INSTALLING"
-          }),
-          Em.Object.create({
-            status: "INSTALLED",
-            repositoryVersion: "2.2.0.1"
+            status: "INSTALLING",
+            repositoryVersion: "2.2.1.1"
           }),
           Em.Object.create({
             status: "INSTALLED",
             repositoryVersion: "2.2.2.1"
           }),
           Em.Object.create({
-            status: "INSTALL_FAILED"
+            status: "INSTALL_FAILED",
+            repositoryVersion: "2.2.1.1"
           }),
           Em.Object.create({
-            status: "OUT_OF_SYNC"
+            status: "OUT_OF_SYNC",
+            repositoryVersion: "2.2.1.1"
           }),
           Em.Object.create({
-            status: "UPGRADING"
+            status: "UPGRADING",
+            repositoryVersion: "2.2.1.1"
           }),
           Em.Object.create({
-            status: "UPGRADED"
+            status: "UPGRADED",
+            repositoryVersion: "2.2.1.1"
           }),
           Em.Object.create({
-            status: "CURRENT"
+            status: "CURRENT",
+            repositoryVersion: "2.2.1.1"
           })
         ]
       },
@@ -106,16 +116,20 @@ describe('App.mainAdminStackVersionsView', function () {
         }),
         filteredVersions: [
           Em.Object.create({
-            status: "INIT"
+            status: "INIT",
+            repositoryVersion: "2.2.1.1"
           }),
           Em.Object.create({
-            status: "INSTALLING"
+            status: "INSTALLING",
+            repositoryVersion: "2.2.1.1"
           }),
           Em.Object.create({
-            status: "INSTALL_FAILED"
+            status: "INSTALL_FAILED",
+            repositoryVersion: "2.2.1.1"
           }),
           Em.Object.create({
-            status: "OUT_OF_SYNC"
+            status: "OUT_OF_SYNC",
+            repositoryVersion: "2.2.1.1"
           })
         ]
       },
@@ -124,10 +138,7 @@ describe('App.mainAdminStackVersionsView', function () {
           value: 'INSTALLED'
         }),
         filteredVersions: [
-          Em.Object.create({
-            status: "INSTALLED",
-            repositoryVersion: "2.2.0.1"
-          })
+
         ]
       },
       {
@@ -147,7 +158,8 @@ describe('App.mainAdminStackVersionsView', function () {
         }),
         filteredVersions: [
           Em.Object.create({
-            status: "CURRENT"
+            status: "CURRENT",
+            repositoryVersion: "2.2.1.1"
           })
         ]
       },
@@ -157,7 +169,8 @@ describe('App.mainAdminStackVersionsView', function () {
         }),
         filteredVersions: [
           Em.Object.create({
-            status: "UPGRADING"
+            status: "UPGRADING",
+            repositoryVersion: "2.2.1.1"
           })
         ]
       },
@@ -167,7 +180,8 @@ describe('App.mainAdminStackVersionsView', function () {
         }),
         filteredVersions: [
           Em.Object.create({
-            status: "UPGRADED"
+            status: "UPGRADED",
+            repositoryVersion: "2.2.1.1"
           })
         ]
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc618e/ambari-web/test/views/main/host/stack_versions_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/stack_versions_view_test.js b/ambari-web/test/views/main/host/stack_versions_view_test.js
index 86bcbff..8023cc9 100644
--- a/ambari-web/test/views/main/host/stack_versions_view_test.js
+++ b/ambari-web/test/views/main/host/stack_versions_view_test.js
@@ -21,7 +21,11 @@ var App = require('app');
 describe('App.MainHostStackVersionsView', function() {
   var view = App.MainHostStackVersionsView.create({
     filteredCount: 0,
-    totalCount: 0
+    totalCount: 0,
+    host: {
+      id: 1,
+      stackVersions: []
+    }
   });
 
   describe("#host", function () {
@@ -39,9 +43,7 @@ describe('App.MainHostStackVersionsView', function() {
     });
     it("", function () {
       view.propertyDidChange('host');
-      expect(view.get('host')).to.eql(Em.Object.create({
-        id: 1
-      }));
+      expect(view.get('host.id')).to.equal(1);
     });
   });
 


Mime
View raw message