You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2017/07/19 11:20:16 UTC

ambari git commit: AMBARI-21514 Remove IOP select button not visible after HDP 2.6.2 is registered. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 837b0bdff -> 7542bc391


AMBARI-21514 Remove IOP select button not visible after HDP 2.6.2 is registered. (atkach)


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

Branch: refs/heads/branch-2.5
Commit: 7542bc3918204e896d3b64bbac8ed7186939d515
Parents: 837b0bd
Author: Andrii Tkach <at...@apache.org>
Authored: Wed Jul 19 13:59:45 2017 +0300
Committer: Andrii Tkach <at...@apache.org>
Committed: Wed Jul 19 13:59:45 2017 +0300

----------------------------------------------------------------------
 .../stack_upgrade/upgrade_version_box_view.js   | 31 ++++++++++----
 .../upgrade_version_column_view.js              | 38 -----------------
 .../upgrade_version_box_view_test.js            | 43 ++++++++++++++++++++
 3 files changed, 66 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7542bc39/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 956339f..bbd1415 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
@@ -117,7 +117,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
     },
     'INIT': {
       isButton: true,
-      text: Em.I18n.t('admin.stackVersions.version.installNow'),
+      text: Em.I18n.t('common.install'),
       action: 'installRepoVersionConfirmation'
     },
     'LOADING': {
@@ -173,6 +173,10 @@ App.UpgradeVersionBoxView = Em.View.extend({
     else if (status === 'INIT') {
       requestInProgressRepoId && requestInProgressRepoId == this.get('content.id') ? element.setProperties(statePropertiesMap['LOADING']) : element.setProperties(statePropertiesMap[status]);
       element.set('isDisabled', this.isDisabledOnInit());
+      if (this.addRemoveIopSelectButton(element, this.isDisabledOnInit())) {
+        element.set('isButtonGroup', true);
+        element.set('isButton', false);
+      }
     }
     else if ((status === 'INSTALLED' && !this.get('isUpgrading')) ||
              (['INSTALL_FAILED', 'OUT_OF_SYNC'].contains(status))) {
@@ -195,13 +199,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
             action: 'installRepoVersionConfirmation',
             isDisabled: isDisabled
           });
-          if (App.get('currentStackName') === 'BigInsights' && !App.get('upgradeIsRunning')) {
-            element.get('buttons').pushObject({
-              text: Em.I18n.t('admin.stackVersions.removeIopSelect'),
-              action: 'removeIopSelect',
-              isDisabled: isDisabled
-            });
-          }
+          this.addRemoveIopSelectButton(element, isDisabled);
         }
         element.set('isDisabled', isDisabled);
       }
@@ -254,6 +252,23 @@ App.UpgradeVersionBoxView = Em.View.extend({
   ),
 
   /**
+   * @param {Em.Object} element
+   * @param {boolean} isDisabled
+   * @returns {boolean}
+   */
+  addRemoveIopSelectButton: function(element, isDisabled) {
+    if (App.get('currentStackName') === 'BigInsights' && !App.get('upgradeIsRunning')) {
+      element.get('buttons').pushObject({
+        text: Em.I18n.t('admin.stackVersions.removeIopSelect'),
+        action: 'removeIopSelect',
+        isDisabled: isDisabled
+      });
+      return true;
+    }
+    return false;
+  },
+
+  /**
    * check if actions of INIT stack version disabled
    * @returns {boolean}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/7542bc39/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_column_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_column_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_column_view.js
index f6f86db..66e424e 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_column_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_column_view.js
@@ -64,44 +64,6 @@ App.UpgradeVersionColumnView = App.UpgradeVersionBoxView.extend({
   }.property(),
 
   /**
-   * map of properties which correspond to particular state of Upgrade version
-   * @type {object}
-   */
-  statePropertiesMap: {
-    'CURRENT': {
-      isLabel: true,
-      text: Em.I18n.t('common.current'),
-      class: 'label label-success'
-    },
-    'INIT': {
-      isButton: true,
-      text: Em.I18n.t('common.install'),
-      action: 'installRepoVersionConfirmation'
-    },
-    'LOADING': {
-      isSpinner: true,
-      class: 'spinner'
-    },
-    'INSTALLING': {
-      iconClass: 'icon-cog',
-      isLink: true,
-      text: Em.I18n.t('hosts.host.stackVersions.status.installing'),
-      action: 'showProgressPopup'
-    },
-    'INSTALLED': {
-      iconClass: 'icon-ok',
-      isLink: true,
-      text: Em.I18n.t('common.installed'),
-      action: null
-    },
-    'SUSPENDED': {
-      isButton: true,
-      text: Em.I18n.t('admin.stackUpgrade.dialog.resume'),
-      action: 'resumeUpgrade'
-    }
-  },
-
-  /**
    * on click handler for "show details" link
    */
   openVersionBoxPopup: function (event) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7542bc39/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 971b1f3..b928b02 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
@@ -1137,4 +1137,47 @@ describe('App.UpgradeVersionBoxView', function () {
       });
     });
   });
+
+  describe('#addRemoveIopSelectButton', function() {
+    beforeEach(function() {
+      this.mock = sinon.stub(App, 'get');
+    });
+    afterEach(function() {
+      this.mock.restore();
+    });
+
+    it('should add remove Iop Select button', function() {
+      this.mock.withArgs('currentStackName').returns('BigInsights');
+      this.mock.withArgs('upgradeIsRunning').returns(false);
+      var element = Em.Object.create({
+        buttons: []
+      });
+      view.addRemoveIopSelectButton(element, true);
+      expect(element.get('buttons')[0]).to.be.eql({
+        text: Em.I18n.t('admin.stackVersions.removeIopSelect'),
+        action: 'removeIopSelect',
+        isDisabled: true
+      });
+    });
+
+    it('should not add remove Iop Select button when upgrade is running', function() {
+      this.mock.withArgs('currentStackName').returns('BigInsights-1');
+      this.mock.withArgs('upgradeIsRunning').returns(true);
+      var element = Em.Object.create({
+        buttons: []
+      });
+      view.addRemoveIopSelectButton(element, true);
+      expect(element.get('buttons')).to.be.empty;
+    });
+
+    it('should not add remove Iop Select button when stack not BigInsights', function() {
+      this.mock.withArgs('currentStackName').returns('HDP');
+      this.mock.withArgs('upgradeIsRunning').returns(false);
+      var element = Em.Object.create({
+        buttons: []
+      });
+      view.addRemoveIopSelectButton(element, true);
+      expect(element.get('buttons')).to.be.empty;
+    });
+  });
 });