ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject ambari git commit: AMBARI-22157. Web Client Should Never List Any Upgrade Actions On Only Stack In System (alexantonenko)
Date Fri, 06 Oct 2017 13:36:39 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 6bfcb838e -> 5eab1a569


AMBARI-22157. Web Client Should Never List Any Upgrade Actions On Only Stack In System (alexantonenko)


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

Branch: refs/heads/branch-2.6
Commit: 5eab1a569c4316efe9a5adc9f843a0e015ff4e1f
Parents: 6bfcb83
Author: Alex Antonenko <aantonenko@hortonworks.com>
Authored: Fri Oct 6 16:36:26 2017 +0300
Committer: Alex Antonenko <aantonenko@hortonworks.com>
Committed: Fri Oct 6 16:36:26 2017 +0300

----------------------------------------------------------------------
 .../stack_upgrade/upgrade_version_box_view.js   | 13 ++++--
 .../upgrade_version_box_view_test.js            | 44 ++++++++++++++++++--
 2 files changed, 49 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5eab1a56/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
index 95bdcc0..67dd498 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
@@ -203,7 +203,8 @@ App.UpgradeVersionBoxView = Em.View.extend({
     'controller.requestInProgressRepoId',
     'parentView.repoVersions.@each.status',
     'App.currentStackName',
-    'App.upgradeIsRunning'
+    'App.upgradeIsRunning',
+    'isCurrentStackPresent'
   ),
 
   /**
@@ -305,8 +306,6 @@ App.UpgradeVersionBoxView = Em.View.extend({
             });
           }
 
-
-
           this.addRemoveIopSelectButton(element, isDisabled);
       }
       element.set('isDisabled', isDisabled);
@@ -364,12 +363,17 @@ App.UpgradeVersionBoxView = Em.View.extend({
     return false;
   },
 
+  isCurrentStackPresent: Ember.computed('parentView.repoVersions.@each.stackVersion.state',
function () {
+    return this.get('parentView.repoVersions').someProperty('stackVersion.state', 'CURRENT');
+  }),
+
   /**
    * check if actions of NOT_REQUIRED stack version disabled
    * @returns {boolean}
    */
   isDisabledOnInit: function() {
     return  this.get('controller.requestInProgress') ||
+            !this.get('isCurrentStackPresent') ||
             !this.get('content.isCompatible') ||
             (App.get('upgradeIsRunning') && !App.get('upgradeSuspended')) ||
             this.get('parentView.repoVersions').someProperty('status', 'INSTALLING');
@@ -380,7 +384,8 @@ App.UpgradeVersionBoxView = Em.View.extend({
    * @returns {boolean}
    */
   isDisabledOnInstalled: function() {
-    return !App.isAuthorized('CLUSTER.UPGRADE_DOWNGRADE_STACK') ||
+    return !this.get('isCurrentStackPresent') ||
+      !App.isAuthorized('CLUSTER.UPGRADE_DOWNGRADE_STACK') ||
       this.get('controller.requestInProgress') ||
       this.get('parentView.repoVersions').someProperty('status', 'INSTALLING') ||
       (this.get('controller.isDowngrade') &&

http://git-wip-us.apache.org/repos/asf/ambari/blob/5eab1a56/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
index 4469222..fd4e890 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
@@ -29,6 +29,7 @@ describe('App.UpgradeVersionBoxView', function () {
     sinon.stub(App.db, 'getFilterConditions', function () {return [];});
     view = App.UpgradeVersionBoxView.create({
       initFilters: Em.K,
+      isCurrentStackPresent: true,
       controller: Em.Object.create({
         upgrade: Em.K,
         getRepoVersionInstallId: Em.K,
@@ -1038,6 +1039,7 @@ describe('App.UpgradeVersionBoxView', function () {
         upgradeSuspended: true,
         status: 'INSTALLED',
         isCompatible: true,
+        isCurrentStackPresent: true,
         expected: true
       },
       {
@@ -1046,6 +1048,7 @@ describe('App.UpgradeVersionBoxView', function () {
         upgradeSuspended: false,
         status: 'INSTALLED',
         isCompatible: true,
+        isCurrentStackPresent: true,
         expected: true
       },
       {
@@ -1054,6 +1057,7 @@ describe('App.UpgradeVersionBoxView', function () {
         upgradeSuspended: false,
         status: 'INSTALLING',
         isCompatible: true,
+        isCurrentStackPresent: true,
         expected: true
       },
       {
@@ -1062,6 +1066,7 @@ describe('App.UpgradeVersionBoxView', function () {
         upgradeSuspended: true,
         status: 'INSTALLED',
         isCompatible: false,
+        isCurrentStackPresent: true,
         expected: true
       },
       {
@@ -1070,6 +1075,7 @@ describe('App.UpgradeVersionBoxView', function () {
         upgradeSuspended: true,
         status: 'INSTALLED',
         isCompatible: true,
+        isCurrentStackPresent: true,
         expected: false
       },
       {
@@ -1078,7 +1084,17 @@ describe('App.UpgradeVersionBoxView', function () {
         upgradeSuspended: false,
         status: 'INSTALLED',
         isCompatible: true,
+        isCurrentStackPresent: true,
         expected: false
+      },
+      {
+        requestInProgress: false,
+        upgradeIsRunning: false,
+        upgradeSuspended: false,
+        status: 'INSTALLED',
+        isCompatible: true,
+        isCurrentStackPresent: false,
+        expected: true
       }
     ];
 
@@ -1091,16 +1107,18 @@ describe('App.UpgradeVersionBoxView', function () {
     });
 
     testCases.forEach(function(test) {
-      it("requestInProgress: " + test.requestInProgress +
+      it(" requestInProgress: " + test.requestInProgress +
          " upgradeIsRunning: " + test.upgradeIsRunning +
          " upgradeSuspended: " + test.upgradeSuspended +
-         " status" + test.status +
-         " isCompatible" + test.isCompatible, function() {
+         " status: " + test.status +
+         " isCompatible: " + test.isCompatible +
+         " isCurrentStackPresent: " + test.isCurrentStackPresent, function() {
         this.mock.withArgs('upgradeSuspended').returns(test.upgradeSuspended);
         this.mock.withArgs('upgradeIsRunning').returns(test.upgradeIsRunning);
         view.set('parentView.repoVersions', [Em.Object.create({
           status: test.status
         })]);
+        view.set('isCurrentStackPresent', test.isCurrentStackPresent)
         view.set('controller.requestInProgress', test.requestInProgress);
         view.set('content.isCompatible', test.isCompatible);
         expect(view.isDisabledOnInit()).to.be.equal(test.expected);
@@ -1126,6 +1144,7 @@ describe('App.UpgradeVersionBoxView', function () {
         isDowngrade: false,
         repositoryName: 'HDP-2.2',
         upgradeVersion: 'HDP-2.3',
+        isCurrentStackPresent: true,
         expected: true
       },
       {
@@ -1135,6 +1154,7 @@ describe('App.UpgradeVersionBoxView', function () {
         isDowngrade: false,
         repositoryName: 'HDP-2.2',
         upgradeVersion: 'HDP-2.3',
+        isCurrentStackPresent: true,
         expected: true
       },
       {
@@ -1144,6 +1164,7 @@ describe('App.UpgradeVersionBoxView', function () {
         isDowngrade: false,
         repositoryName: 'HDP-2.2',
         upgradeVersion: 'HDP-2.3',
+        isCurrentStackPresent: true,
         expected: true
       },
       {
@@ -1153,6 +1174,7 @@ describe('App.UpgradeVersionBoxView', function () {
         isDowngrade: true,
         repositoryName: 'HDP-2.2',
         upgradeVersion: 'HDP-2.2',
+        isCurrentStackPresent: true,
         expected: true
       },
       {
@@ -1162,6 +1184,7 @@ describe('App.UpgradeVersionBoxView', function () {
         isDowngrade: true,
         repositoryName: 'HDP-2.2',
         upgradeVersion: 'HDP-2.3',
+        isCurrentStackPresent: true,
         expected: false
       },
       {
@@ -1171,7 +1194,18 @@ describe('App.UpgradeVersionBoxView', function () {
         isDowngrade: false,
         repositoryName: 'HDP-2.2',
         upgradeVersion: 'HDP-2.2',
+        isCurrentStackPresent: true,
         expected: false
+      },
+      {
+        isAuthorized: true,
+        requestInProgress: false,
+        status: 'INSTALLED',
+        isDowngrade: false,
+        repositoryName: 'HDP-2.2',
+        upgradeVersion: 'HDP-2.2',
+        isCurrentStackPresent: false,
+        expected: true
       }
     ];
 
@@ -1181,13 +1215,15 @@ describe('App.UpgradeVersionBoxView', function () {
           "status: " + test.status +
           "isDowngrade: " + test.isDowngrade +
           "repositoryName: " + test.repositoryName +
-          "upgradeVersion: " + test.upgradeVersion, function() {
+          "upgradeVersion: " + test.upgradeVersion +
+          "isCurrentStackPresent: " + test.isCurrentStackPresent, function() {
         this.authorizedMock.returns(test.isAuthorized);
         view.set('controller.requestInProgress', test.requestInProgress);
         view.set('parentView.repoVersions', [Em.Object.create({status: test.status})]);
         view.set('controller.isDowngrade', test.isDowngrade);
         view.set('controller.currentVersion.repository_name', test.repositoryName);
         view.set('controller.upgradeVersion', test.upgradeVersion);
+        view.set('isCurrentStackPresent', test.isCurrentStackPresent);
         expect(view.isDisabledOnInstalled()).to.be.equal(test.expected);
       });
     });


Mime
View raw message