ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-13883 Upgrade: when out of sync, should default to Install Packages button. (atkach)
Date Fri, 13 Nov 2015 14:12:09 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 55808ea11 -> ae3ce8b98


AMBARI-13883 Upgrade: when out of sync, should default to Install Packages button. (atkach)


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

Branch: refs/heads/branch-2.1
Commit: ae3ce8b9898875fcaa1d5a08b75f9b002c1a4edb
Parents: 55808ea
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Fri Nov 13 15:56:49 2015 +0200
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Fri Nov 13 16:12:01 2015 +0200

----------------------------------------------------------------------
 .../stack_upgrade/upgrade_version_box_view.js   | 84 +++++++++++++-------
 .../upgrade_version_box_view_test.js            | 16 ++--
 2 files changed, 65 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce8b9/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 fea01f4..1be4290 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
@@ -102,12 +102,47 @@ App.UpgradeVersionBoxView = Em.View.extend({
   content: null,
 
   /**
+   * 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('admin.stackVersions.version.installNow'),
+      action: 'installRepoVersionConfirmation'
+    },
+    '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'
+    }
+  },
+
+  /**
    * object that describes how content should be displayed
    * @type {Em.Object}
    * TODO remove <code>isUpgrading</code> condition when transition of version
states in API fixed
    */
   stateElement: function () {
     var currentVersion = this.get('controller.currentVersion');
+    var statePropertiesMap = this.get('statePropertiesMap');
     var status = this.get('content.status');
     var element = Em.Object.create({
       status: status,
@@ -121,42 +156,39 @@ App.UpgradeVersionBoxView = Em.View.extend({
     var isAborted = App.get('upgradeState') === 'ABORTED';
     var isSuspended = App.router.get('mainAdminStackAndUpgradeController.isSuspended');
 
-    if (status === 'CURRENT') {
-      element.set('isLabel', true);
-      element.set('text', Em.I18n.t('common.current'));
-      element.set('class', 'label label-success');
+    if (['INSTALLING', 'CURRENT'].contains(status)) {
+      element.setProperties(statePropertiesMap[status]);
     }
     else if (status === 'INIT') {
-      element.set('isButton', true);
-      element.set('text', Em.I18n.t('admin.stackVersions.version.installNow'));
-      element.set('action', 'installRepoVersionConfirmation');
+      element.setProperties(statePropertiesMap[status]);
       element.set('isDisabled', !App.isAccessible('ADMIN') || this.get('controller.requestInProgress')
|| isInstalling);
     }
-    else if (status === 'INSTALLING') {
-      element.set('iconClass', 'icon-cog');
-      element.set('isLink', true);
-      element.set('text', Em.I18n.t('hosts.host.stackVersions.status.installing'));
-      element.set('action', 'showProgressPopup');
-    }
     else if ((status === 'INSTALLED' && !this.get('isUpgrading')) ||
              (['INSTALL_FAILED', 'OUT_OF_SYNC'].contains(status))) {
       if (stringUtils.compareVersions(this.get('content.repositoryVersion'), Em.get(currentVersion,
'repository_version')) === 1) {
         var isDisabled = !App.isAccessible('ADMIN') || this.get('controller.requestInProgress')
|| isInstalling;
         element.set('isButtonGroup', true);
-        element.set('text', Em.I18n.t('admin.stackVersions.version.performUpgrade'));
-        element.set('action', 'confirmUpgrade');
-        element.get('buttons').pushObject({
-          text: Em.I18n.t('admin.stackVersions.version.reinstall'),
-          action: 'installRepoVersionConfirmation',
-          isDisabled: isDisabled
-        });
+        if (status === 'OUT_OF_SYNC') {
+          element.set('text', Em.I18n.t('admin.stackVersions.version.reinstall'));
+          element.set('action', 'installRepoVersionConfirmation');
+          element.get('buttons').pushObject({
+            text: Em.I18n.t('admin.stackVersions.version.performUpgrade'),
+            action: 'confirmUpgrade',
+            isDisabled: isDisabled
+          });
+        } else {
+          element.set('text', Em.I18n.t('admin.stackVersions.version.performUpgrade'));
+          element.set('action', 'confirmUpgrade');
+          element.get('buttons').pushObject({
+            text: Em.I18n.t('admin.stackVersions.version.reinstall'),
+            action: 'installRepoVersionConfirmation',
+            isDisabled: isDisabled
+          });
+        }
         element.set('isDisabled', isDisabled);
       }
       else {
-        element.set('iconClass', 'icon-ok');
-        element.set('isLink', true);
-        element.set('text', Em.I18n.t('common.installed'));
-        element.set('action', null);
+        element.setProperties(statePropertiesMap['INSTALLED']);
       }
     }
     else if ((['UPGRADING', 'UPGRADE_FAILED', 'UPGRADED'].contains(status) || this.get('isUpgrading'))
&& !isAborted) {
@@ -183,9 +215,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
     }
     else if (isAborted) {
       if (isSuspended) {
-        element.set('isButton', true);
-        element.set('text', Em.I18n.t('admin.stackUpgrade.dialog.resume'));
-        element.set('action', 'resumeUpgrade');
+        element.setProperties(statePropertiesMap['SUSPENDED']);
         element.set('isDisabled', this.get('controller.requestInProgress'));
       } else {
         element.set('isButton', true);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce8b9/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 a638687..9bf8a71 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
@@ -477,12 +477,12 @@ describe('App.UpgradeVersionBoxView', function () {
           status: 'OUT_OF_SYNC',
           isButtonGroup: true,
           buttons: [{
-            text: Em.I18n.t('admin.stackVersions.version.reinstall'),
-            action: 'installRepoVersionConfirmation',
+            text: Em.I18n.t('admin.stackVersions.version.performUpgrade'),
+            action: 'confirmUpgrade',
             isDisabled: false
           }],
-          text: Em.I18n.t('admin.stackVersions.version.performUpgrade'),
-          action: 'confirmUpgrade',
+          text: Em.I18n.t('admin.stackVersions.version.reinstall'),
+          action: 'installRepoVersionConfirmation',
           isDisabled: false
         },
         title: 'OUT_OF_SYNC state, admin access, no requests in progress, no installation'
@@ -510,12 +510,12 @@ describe('App.UpgradeVersionBoxView', function () {
           status: 'OUT_OF_SYNC',
           isButtonGroup: true,
           buttons: [{
-            text: Em.I18n.t('admin.stackVersions.version.reinstall'),
-            action: 'installRepoVersionConfirmation',
+            text: Em.I18n.t('admin.stackVersions.version.performUpgrade'),
+            action: 'confirmUpgrade',
             isDisabled: true
           }],
-          text: Em.I18n.t('admin.stackVersions.version.performUpgrade'),
-          action: 'confirmUpgrade',
+          text: Em.I18n.t('admin.stackVersions.version.reinstall'),
+          action: 'installRepoVersionConfirmation',
           isDisabled: true
         },
         title: 'OUT_OF_SYNC state, admin access, request in progress, no installation'


Mime
View raw message