You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2015/12/01 02:41:32 UTC

ambari git commit: Revert "AMBARI-14095. Upgrade: second click shows diff results"

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 f6fde22cd -> 4606cd3bf


Revert "AMBARI-14095. Upgrade: second click shows diff results"

This reverts commit ee88e19f540a24353f2a9b6744cb1dfe07ebef13.


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

Branch: refs/heads/branch-2.1
Commit: 4606cd3bf0bd2e1281b47395434470085561fa3d
Parents: f6fde22
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Mon Nov 30 17:41:03 2015 -0800
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Mon Nov 30 17:41:03 2015 -0800

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 -
 .../app/controllers/main/admin/kerberos.js      |   8 +-
 .../main/admin/stack_and_upgrade_controller.js  |  42 +--
 .../modal_popups/cluster_check_dialog.hbs       |  24 +-
 .../common/modal_popups/cluster_check_popup.js  | 103 +++++--
 .../admin/stack_and_upgrade_controller_test.js  |   2 +-
 .../modal_popups/cluster_check_popup_test.js    | 271 -------------------
 7 files changed, 99 insertions(+), 352 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4606cd3b/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 677df72..6393381 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -205,7 +205,6 @@ var files = ['test/init_model_test',
   'test/views/common/widget/graph_widget_view_test',
   'test/views/common/widget/number_widget_view_test',
   'test/views/common/widget/gauge_widget_view_test',
-  'test/views/common/modal_popups/cluster_check_popup_test',
   'test/views/common/modal_popups/hosts_table_list_popup_test',
   'test/views/common/modal_popups/dependent_configs_list_popup_test',
   'test/views/main/admin_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/4606cd3b/ambari-web/app/controllers/main/admin/kerberos.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos.js b/ambari-web/app/controllers/main/admin/kerberos.js
index d4adfdc..f9ecc4a 100644
--- a/ambari-web/app/controllers/main/admin/kerberos.js
+++ b/ambari-web/app/controllers/main/admin/kerberos.js
@@ -221,16 +221,10 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
   runSecurityCheckSuccess: function (data, opt, params) {
     //TODO correct check
     if (data.items.someProperty('UpgradeChecks.status', "FAIL")) {
-      var hasFails = data.items.someProperty('UpgradeChecks.status', 'FAIL');
       var header = Em.I18n.t('popup.clusterCheck.Security.header').format(params.label);
       var title = Em.I18n.t('popup.clusterCheck.Security.title');
       var alert = Em.I18n.t('popup.clusterCheck.Security.alert');
-      App.showClusterCheckPopup(data, {
-        header: header,
-        failTitle: title,
-        failAlert: alert,
-        noCallbackCondition: hasFails
-      });
+      App.showClusterCheckPopup(data, header, title, alert);
     } else {
       this.startKerberosWizard();
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4606cd3b/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 7c9c252..2eeec4b 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
@@ -727,10 +727,8 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
             configsMergeWarning = data.items.findProperty('UpgradeChecks.id', "CONFIG_MERGE"),
             configs = [];
           if (configsMergeWarning && Em.get(configsMergeWarning, 'UpgradeChecks.status') === 'WARNING') {
-            var popupData = {
-                items: data.items.rejectProperty('UpgradeChecks.id', 'CONFIG_MERGE')
-              },
-              configsMergeCheckData = Em.get(configsMergeWarning, 'UpgradeChecks.failed_detail');
+            data.items = data.items.rejectProperty('UpgradeChecks.id', 'CONFIG_MERGE');
+            var configsMergeCheckData = Em.get(configsMergeWarning, 'UpgradeChecks.failed_detail');
             if (configsMergeCheckData) {
               configs = configsMergeCheckData.map(function (item) {
                 var isDeprecated = Em.isNone(item.new_stack_value),
@@ -747,21 +745,12 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
               });
             }
           }
-          App.showClusterCheckPopup(popupData, {
-            header: header,
-            failTitle: failTitle,
-            failAlert: failAlert,
-            warningTitle: warningTitle,
-            warningAlert: warningAlert,
-            primary: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.preCheck.rerun'),
-            secondary: Em.I18n.t('common.cancel'),
-            callback: function () {
-              self.runPreUpgradeCheckOnly.call(self, {
-                value: version.get('repositoryVersion'),
-                label: version.get('displayName'),
-                type: event.context.get('type')
-              });
-            }
+          App.showPreUpgradeCheckPopup(data, header, failTitle, failAlert, warningTitle, warningAlert, function () {
+            self.runPreUpgradeCheckOnly.call(self, {
+              value: version.get('repositoryVersion'),
+              label: version.get('displayName'),
+              type: event.context.get('type')
+            });
           }, configs, version.get('displayName'));
         }
       }),
@@ -976,8 +965,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     var self = this;
     if (data.items.someProperty('UpgradeChecks.status', 'FAIL') || data.items.someProperty('UpgradeChecks.status', 'WARNING')) {
       this.set('requestInProgress', false);
-      var hasFails = data.items.someProperty('UpgradeChecks.status', 'FAIL'),
-        header = Em.I18n.t('popup.clusterCheck.Upgrade.header').format(params.label),
+      var header = Em.I18n.t('popup.clusterCheck.Upgrade.header').format(params.label),
         failTitle = Em.I18n.t('popup.clusterCheck.Upgrade.fail.title'),
         failAlert = new Em.Handlebars.SafeString(Em.I18n.t('popup.clusterCheck.Upgrade.fail.alert')),
         warningTitle = Em.I18n.t('popup.clusterCheck.Upgrade.warning.title'),
@@ -1003,16 +991,8 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
           });
         }
       }
-      App.showClusterCheckPopup(data, {
-        header: header,
-        failTitle: failTitle,
-        failAlert: failAlert,
-        warningTitle: warningTitle,
-        warningAlert: warningAlert,
-        noCallbackCondition: hasFails,
-        callback: function () {
-          self.upgrade(params);
-        }
+      App.showClusterCheckPopup(data, header, failTitle, failAlert, warningTitle, warningAlert, function () {
+        self.upgrade(params);
       }, configs, params.label);
     } else {
       this.upgrade(params);

http://git-wip-us.apache.org/repos/asf/ambari/blob/4606cd3b/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs b/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs
index 8fd2746..8767d70 100644
--- a/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs
+++ b/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs
@@ -20,14 +20,10 @@
     <i class="icon-ok"></i>&nbsp;<span>{{t admin.stackVersions.version.upgrade.upgradeOptions.preCheck.allPassed.msg}}</span>
   {{/if}}
   {{#if view.fails.length}}
-    {{#if view.failTitle}}
-      <h4>{{view.failTitle}}</h4>
-    {{/if}}
-    {{#if view.failAlert}}
-      <div class="alert alert-warning">
-        {{view.failAlert}}
-      </div>
-    {{/if}}
+    <h4>{{view.failTitle}}</h4>
+    <div class="alert alert-warning">
+      {{view.failAlert}}
+    </div>
     <div class="limited-height-2">
       {{#each item in view.fails}}
         <i class="icon-remove"></i>&nbsp;<span>{{item.UpgradeChecks.check}}</span>
@@ -36,14 +32,10 @@
     </div>
   {{/if}}
   {{#if view.warnings.length}}
-    {{#if view.warningTitle}}
-      <h4>{{view.warningTitle}}</h4>
-    {{/if}}
-    {{#if view.warningAlert}}
-      <div class="alert alert-warning">
-        {{view.warningAlert}}
-      </div>
-    {{/if}}
+    <h4>{{view.warningTitle}}</h4>
+    <div class="alert alert-warning">
+      {{view.warningAlert}}
+    </div>
     <div class="limited-height-2">
       {{#each item in view.warnings}}
         <i class="icon-warning-sign"></i>&nbsp;<span>{{item.UpgradeChecks.check}}</span>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4606cd3b/ambari-web/app/views/common/modal_popups/cluster_check_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popups/cluster_check_popup.js b/ambari-web/app/views/common/modal_popups/cluster_check_popup.js
index d173d1a..b3f0c4c 100644
--- a/ambari-web/app/views/common/modal_popups/cluster_check_popup.js
+++ b/ambari-web/app/views/common/modal_popups/cluster_check_popup.js
@@ -22,33 +22,30 @@ var App = require('app');
  * popup to display requirements that are not met
  * for current action
  * @param data
- * @param popup
+ * @param header
+ * @param failTitle
+ * @param failAlert
+ * @param warningTitle
+ * @param warningAlert
+ * @param callback
  * @param configs
  * @param upgradeVersion
  * @returns {*|void}
  */
-App.showClusterCheckPopup = function (data, popup, configs, upgradeVersion) {
+App.showClusterCheckPopup = function (data, header, failTitle, failAlert, warningTitle, warningAlert, callback, configs, upgradeVersion) {
   var fails = data.items.filterProperty('UpgradeChecks.status', 'FAIL'),
     warnings = data.items.filterProperty('UpgradeChecks.status', 'WARNING'),
     hasConfigsMergeConflicts = !!(configs && configs.length),
-    primary,
-    secondary,
-    popupBody;
-  popup = popup || {};
-  primary = Em.isNone(popup.primary) ?
-    (fails.length ? Em.I18n.t('common.dismiss') : Em.I18n.t('common.proceedAnyway')) : popup.primary;
-  secondary = Em.isNone(popup.secondary) ? (fails.length ? false : Em.I18n.t('common.cancel')) : popup.secondary;
-  popupBody = {
-    failTitle: popup.failTitle,
-    failAlert: popup.failAlert,
-    warningTitle: popup.warningTitle,
-    warningAlert: popup.warningAlert,
-    templateName: require('templates/common/modal_popups/cluster_check_dialog'),
-    fails: fails,
-    warnings: warnings,
-    hasConfigsMergeConflicts: hasConfigsMergeConflicts,
-    isAllPassed: !fails.length && !warnings.length && !hasConfigsMergeConflicts
-  };
+    popupBody = {
+      failTitle: failTitle,
+      failAlert: failAlert,
+      warningTitle: warningTitle,
+      warningAlert: warningAlert,
+      templateName: require('templates/common/modal_popups/cluster_check_dialog'),
+      fails: fails,
+      warnings: warnings,
+      hasConfigsMergeConflicts: hasConfigsMergeConflicts
+    };
   if (hasConfigsMergeConflicts) {
     popupBody.configsMergeTable = Em.View.extend({
       templateName: require('templates/main/admin/stack_upgrade/upgrade_configs_merge_table'),
@@ -61,15 +58,71 @@ App.showClusterCheckPopup = function (data, popup, configs, upgradeVersion) {
     });
   }
   return App.ModalPopup.show({
-    primary: primary,
-    secondary: secondary,
-    header: popup.header,
+    primary: fails.length ? Em.I18n.t('common.dismiss') : Em.I18n.t('common.proceedAnyway'),
+    secondary: fails.length ? false : Em.I18n.t('common.cancel'),
+    header: header,
+    classNames: ['cluster-check-popup'],
+    bodyClass: Em.View.extend(popupBody),
+    onPrimary: function () {
+      if (!fails.length && callback) {
+        callback();
+      }
+      this._super();
+    }
+  });
+};
+
+
+/**
+ * popup to display requirements that are not met
+ * for current action
+ * @param data
+ * @param header
+ * @param failTitle
+ * @param failAlert
+ * @param warningTitle
+ * @param warningAlert
+ * @param callback
+ * @param configs
+ * @param upgradeVersion
+ * @returns {*|void}
+ */
+App.showPreUpgradeCheckPopup = function (data, header, failTitle, failAlert, warningTitle, warningAlert, callback, configs, upgradeVersion) {
+  var fails = data.items.filterProperty('UpgradeChecks.status', 'FAIL'),
+    warnings = data.items.filterProperty('UpgradeChecks.status', 'WARNING'),
+    hasConfigsMergeConflicts = !!(configs && configs.length),
+    popupBody = {
+      failTitle: failTitle,
+      failAlert: failAlert,
+      warningTitle: warningTitle,
+      warningAlert: warningAlert,
+      templateName: require('templates/common/modal_popups/cluster_check_dialog'),
+      fails: fails,
+      warnings: warnings,
+      hasConfigsMergeConflicts: hasConfigsMergeConflicts,
+      isAllPassed: !fails.length && !warnings.length && !hasConfigsMergeConflicts.length
+    };
+  if (hasConfigsMergeConflicts) {
+    popupBody.configsMergeTable = Em.View.extend({
+      templateName: require('templates/main/admin/stack_upgrade/upgrade_configs_merge_table'),
+      configs: configs,
+      didInsertElement: function () {
+        App.tooltip($('.recommended-value'), {
+          title: upgradeVersion
+        });
+      }
+    });
+  }
+  return App.ModalPopup.show({
+    primary: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.preCheck.rerun'),
+    secondary: Em.I18n.t('common.cancel'),
+    header: header,
     classNames: ['cluster-check-popup'],
     bodyClass: Em.View.extend(popupBody),
     onPrimary: function () {
       this._super();
-      if (!popup.noCallbackCondition && popup.callback) {
-        popup.callback();
+      if (callback) {
+        callback();
       }
     }
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/4606cd3b/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 0575d26..ff2e39e 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
@@ -454,7 +454,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
         expect(controller.upgrade.callCount).to.equal(item.upgradeCalledCount);
         expect(App.showClusterCheckPopup.callCount).to.equal(item.showClusterCheckPopupCalledCount);
         if (item.check.id == 'CONFIG_MERGE') {
-          expect(App.showClusterCheckPopup.firstCall.args[2]).to.eql(item.configs);
+          expect(App.showClusterCheckPopup.firstCall.args[7]).to.eql(item.configs);
         }
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/4606cd3b/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js b/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
deleted file mode 100644
index 5678847..0000000
--- a/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
+++ /dev/null
@@ -1,271 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-require('views/common/modal_popups/cluster_check_popup');
-
-describe('App.showClusterCheckPopup', function () {
-
-  var isCallbackExecuted,
-    callback = function () {
-      isCallbackExecuted = true;
-    },
-    cases = [
-      {
-        inputData: {
-          data: {
-            items: [
-              {
-                UpgradeChecks: {
-                  id: 'p0',
-                  status: 'PASS'
-                }
-              },
-              {
-                UpgradeChecks: {
-                  id: 'p1',
-                  status: 'PASS'
-                }
-              }
-            ]
-          }
-        },
-        result: {
-          primary: Em.I18n.t('common.proceedAnyway'),
-          secondary: Em.I18n.t('common.cancel'),
-          header: '&nbsp;'
-        },
-        bodyResult: {
-          failTitle: undefined,
-          failAlert: undefined,
-          warningTitle: undefined,
-          warningAlert: undefined,
-          fails: [],
-          warnings: [],
-          hasConfigsMergeConflicts: false,
-          isAllPassed: true
-        },
-        isCallbackExecuted: false,
-        title: 'no fails, no warnings, no popup customization'
-      },
-      {
-        inputData: {
-          data: {
-            items: [
-              {
-                UpgradeChecks: {
-                  id: 'w0',
-                  status: 'WARNING'
-                }
-              },
-              {
-                UpgradeChecks: {
-                  id: 'w1',
-                  status: 'WARNING'
-                }
-              }
-            ]
-          },
-          popup: {
-            header: 'checks',
-            failTitle: 'fail',
-            failAlert: 'something has failed',
-            warningTitle: 'warning',
-            warningAlert: 'something is not good',
-            callback: callback
-          }
-        },
-        result: {
-          primary: Em.I18n.t('common.proceedAnyway'),
-          secondary: Em.I18n.t('common.cancel'),
-          header: 'checks'
-        },
-        bodyResult: {
-          failTitle: 'fail',
-          failAlert: 'something has failed',
-          warningTitle: 'warning',
-          warningAlert: 'something is not good',
-          fails: [],
-          warnings: [
-            {
-              UpgradeChecks: {
-                id: 'w0',
-                status: 'WARNING'
-              }
-            },
-            {
-              UpgradeChecks: {
-                id: 'w1',
-                status: 'WARNING'
-              }
-            }
-          ],
-          hasConfigsMergeConflicts: false,
-          isAllPassed: false
-        },
-        isCallbackExecuted: true,
-        title: 'no fails, default buttons, callback executed'
-      },
-      {
-        inputData: {
-          data: {
-            items: [
-              {
-                UpgradeChecks: {
-                  id: 'f0',
-                  status: 'FAIL'
-                }
-              },
-              {
-                UpgradeChecks: {
-                  id: 'f1',
-                  status: 'FAIL'
-                }
-              }
-            ]
-          },
-          popup: {
-            callback: callback,
-            noCallbackCondition: true
-          }
-        },
-        result: {
-          primary: Em.I18n.t('common.dismiss'),
-          secondary: false,
-          header: '&nbsp;'
-        },
-        bodyResult: {
-          failTitle: undefined,
-          failAlert: undefined,
-          warningTitle: undefined,
-          warningAlert: undefined,
-          fails: [
-            {
-              UpgradeChecks: {
-                id: 'f0',
-                status: 'FAIL'
-              }
-            },
-            {
-              UpgradeChecks: {
-                id: 'f1',
-                status: 'FAIL'
-              }
-            }
-          ],
-          warnings: [],
-          hasConfigsMergeConflicts: false,
-          isAllPassed: false
-        },
-        isCallbackExecuted: false,
-        title: 'fails detected, default buttons, callback not executed'
-      },
-      {
-        inputData: {
-          data: {
-            items: [
-              {
-                UpgradeChecks: {
-                  id: 'p0',
-                  status: 'PASS'
-                }
-              },
-              {
-                UpgradeChecks: {
-                  id: 'p1',
-                  status: 'PASS'
-                }
-              }
-            ]
-          },
-          popup: {
-            primary: 'ok',
-            secondary: 'cancel'
-          },
-          configs: [
-            {
-              name: 'c0'
-            },
-            {
-              name: 'c1'
-            }
-          ],
-          upgradeVersion: 'HDP-2.3.0.0'
-        },
-        result: {
-          primary: 'ok',
-          secondary: 'cancel',
-          header: '&nbsp;'
-        },
-        bodyResult: {
-          failTitle: undefined,
-          failAlert: undefined,
-          warningTitle: undefined,
-          warningAlert: undefined,
-          fails: [],
-          warnings: [],
-          hasConfigsMergeConflicts: true,
-          isAllPassed: false
-        },
-        configsResult: [
-          {
-            name: 'c0'
-          },
-          {
-            name: 'c1'
-          }
-        ],
-        isCallbackExecuted: false,
-        title: 'configs merge conflicts detected, custom buttons'
-      }
-    ];
-
-  beforeEach(function () {
-    isCallbackExecuted = false;
-    sinon.stub(App, 'tooltip', Em.K);
-  });
-
-  afterEach(function () {
-    App.tooltip.restore();
-  });
-
-  cases.forEach(function (item) {
-    it(item.title, function () {
-      var popup = App.showClusterCheckPopup(item.inputData.data, item.inputData.popup, item.inputData.configs, item.inputData.upgradeVersion),
-        popupBody = popup.bodyClass.create();
-      popup.onPrimary();
-      Em.keys(item.result).forEach(function (key) {
-        expect(popup[key]).to.equal(item.result[key]);
-      });
-      Em.keys(item.bodyResult).forEach(function (key) {
-        expect(popupBody[key]).to.eql(item.bodyResult[key]);
-      });
-      expect(isCallbackExecuted).to.equal(item.isCallbackExecuted);
-      if (item.bodyResult.hasConfigsMergeConflicts) {
-        var configsMergeTable = popupBody.configsMergeTable.create();
-        configsMergeTable.didInsertElement();
-        expect(configsMergeTable.configs).to.eql(item.configsResult);
-        expect(App.tooltip.calledOnce).to.be.true;
-        expect(App.tooltip.firstCall.args[1].title).to.equal(item.inputData.upgradeVersion);
-      } else {
-        expect(App.tooltip.calledOnce).to.be.false;
-      }
-    });
-  });
-
-});
\ No newline at end of file