You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by zh...@apache.org on 2016/06/08 18:06:17 UTC

ambari git commit: AMBARI-17101 Select Stack Page : "Next" button disabled for blank repo fields (zhewang)

Repository: ambari
Updated Branches:
  refs/heads/trunk 1c8bfce48 -> e241afcf8


AMBARI-17101 Select Stack Page : "Next" button disabled for blank repo fields (zhewang)


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

Branch: refs/heads/trunk
Commit: e241afcf8697cb5beff243031381cee2b910fc8a
Parents: 1c8bfce
Author: Zhe (Joe) Wang <zh...@apache.org>
Authored: Wed Jun 8 11:06:10 2016 -0700
Committer: Zhe (Joe) Wang <zh...@apache.org>
Committed: Wed Jun 8 11:06:23 2016 -0700

----------------------------------------------------------------------
 ambari-web/app/controllers/installer.js         |  6 ++++--
 ambari-web/app/messages.js                      |  2 +-
 ambari-web/app/models/operating_system.js       |  4 +++-
 ambari-web/app/models/repository.js             |  4 ++++
 ambari-web/app/templates/wizard/step1.hbs       |  7 ++-----
 ambari-web/app/utils/validator.js               |  4 ++--
 ambari-web/app/views/wizard/step1_view.js       | 22 +++++++++++++++++++-
 ambari-web/test/controllers/installer_test.js   | 20 ++++++++++++++----
 ambari-web/test/utils/validator_test.js         |  2 +-
 ambari-web/test/views/wizard/step1_view_test.js |  2 +-
 10 files changed, 55 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index 251daad..037e555 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -818,10 +818,10 @@ App.InstallerController = App.WizardController.extend({
     var stackVersion = nameVersionCombo.split('-')[1];
     var dfd = $.Deferred();
     if (selectedStack && selectedStack.get('operatingSystems')) {
-      this.set('validationCnt', selectedStack.get('repositories').filterProperty('isSelected').length);
+      this.set('validationCnt', selectedStack.get('repositories').filterProperty('isSelected').filterProperty('isEmpty', false).length);
       var verifyBaseUrl = !wizardStep1Controller.get('skipValidationChecked') && !wizardStep1Controller.get('selectedStack.useRedhatSatellite');
       selectedStack.get('operatingSystems').forEach(function (os) {
-        if (os.get('isSelected')) {
+        if (os.get('isSelected') && !os.get('isEmpty')) {
           os.get('repositories').forEach(function (repo) {
             repo.setProperties({
               errorTitle: '',
@@ -850,6 +850,8 @@ App.InstallerController = App.WizardController.extend({
               error: 'checkRepoURLErrorCallback'
             });
           }, this);
+        } else if (os.get('isSelected') && os.get('isEmpty')) {
+          os.set('isSelected', false);
         }
       }, this);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 2ea1560..e8c8fea 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -607,7 +607,7 @@ Em.I18n.translations = {
     'you are responsible for configuring the repository channel in Satellite/Spacewalk and confirming the repositories for the selected <b>stack version</b> are available on the hosts in the cluster. ' +
     'Refer to the Ambari documentation for more information.',
   'installer.step1.addOs.disabled.tooltip':'All Operating Systems have been added',
-  'installer.step1.attentionNeeded':'<b>Attention:</b> Repository Base URLs are REQUIRED before you can proceed.',
+  'installer.step1.attentionNeeded':'<b>Attention:</b> Repository Base URLs of at least one OS are REQUIRED before you can proceed. Please make sure they are in correct format with its protocol.',
   'installer.step1.invalidURLAttention': '<b>Attention:</b> Please make sure all repository URLs are valid before proceeding.',
   'installer.step1.checkAtLeastOneAttention': '<b>Attention:</b> Please check at least one repository.',
   'installer.step1.retryRepoUrls': 'Click <b>here</b> to retry.',

http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/app/models/operating_system.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/operating_system.js b/ambari-web/app/models/operating_system.js
index 31f8922..c2588fe 100644
--- a/ambari-web/app/models/operating_system.js
+++ b/ambari-web/app/models/operating_system.js
@@ -27,7 +27,9 @@ App.OperatingSystem = DS.Model.extend({
   repositories: DS.hasMany('App.Repository'),
   stack: DS.belongsTo('App.Stack'),
   isSelected: DS.attr('boolean', {defaultValue: true}),
-  isDeselected: Em.computed.not('isSelected')
+  isDeselected: Em.computed.not('isSelected'),
+
+  isEmpty: Em.computed.someBy('repositories', 'isEmpty', true)
 });
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/app/models/repository.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/repository.js b/ambari-web/app/models/repository.js
index 6fc5731..0b7ee69 100644
--- a/ambari-web/app/models/repository.js
+++ b/ambari-web/app/models/repository.js
@@ -43,6 +43,10 @@ App.Repository = DS.Model.extend({
     return !validator.isValidBaseUrl(this.get('baseUrl'));
   }.property('baseUrl'),
 
+  isEmpty: function() {
+    return this.get('baseUrl') == '';
+  }.property('baseUrl'),
+
   invalidError: function() {
     return this.get('validation') === App.Repository.validation.INVALID;
   }.property('validation'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/app/templates/wizard/step1.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/step1.hbs b/ambari-web/app/templates/wizard/step1.hbs
index 4eaef8e..59ff21b 100644
--- a/ambari-web/app/templates/wizard/step1.hbs
+++ b/ambari-web/app/templates/wizard/step1.hbs
@@ -99,8 +99,8 @@
       <div class="accordion-body version-contents-body">
         <div class="accordion-inner">
           <div class="alert alert-info" role="alert">{{t installer.step1.useLocalRepo.infoForm.alert.baseUrl}}</div>
-          {{#if view.hasValidationErrors}}
-            <div class="alert alert-warning" role="alert">{{t installer.step1.useLocalRepo.infoForm.alert.warning}}</div>
+          {{#if view.showWarning}}
+            <div class="alert">{{t installer.step1.attentionNeeded}}</div>
           {{/if}}
 
           {{! OSes and Repositories }}
@@ -204,9 +204,6 @@
     </div>
   </form>
   {{/if}}
-  {{#if view.invalidFormatUrlExist}}
-    <div class="alert">{{t installer.step1.attentionNeeded}}</div>
-  {{/if}}
   {{#if view.invalidUrlExist}}
     <div class="alert">
       {{t installer.step1.invalidURLAttention}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/app/utils/validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/validator.js b/ambari-web/app/utils/validator.js
index d29a6bb..6929fa2 100644
--- a/ambari-web/app/utils/validator.js
+++ b/ambari-web/app/utils/validator.js
@@ -289,8 +289,8 @@ module.exports = {
    * @returns {boolean}
    */
   isValidBaseUrl: function (value) {
-    var remotePattern = /^(?:(?:https?|ftp):\/{2})(?:\S+(?::\S*)?@)?(?:(?:(?:[\w\-.]))*)(?::[0-9]+)?(?:\/\S*)?$/,
-      localPattern = /^file:\/{2,3}([a-zA-Z][:|]\/){0,1}[\w~!*'();@&=\/\\\-+$,?%#.\[\]]+$/;
+    var remotePattern = /^$|^(?:(?:https?|ftp):\/{2})(?:\S+(?::\S*)?@)?(?:(?:(?:[\w\-.]))*)(?::[0-9]+)?(?:\/\S*)?$/,
+      localPattern = /^$|^file:\/{2,3}([a-zA-Z][:|]\/){0,1}[\w~!*'();@&=\/\\\-+$,?%#.\[\]]+$/;
     return remotePattern.test(value) || localPattern.test(value);
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/app/views/wizard/step1_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step1_view.js b/ambari-web/app/views/wizard/step1_view.js
index efdae76..c3a5aac 100644
--- a/ambari-web/app/views/wizard/step1_view.js
+++ b/ambari-web/app/views/wizard/step1_view.js
@@ -69,7 +69,14 @@ App.WizardStep1View = Em.View.extend({
    *
    * @type {bool}
    */
-  isSubmitDisabled: Em.computed.or('invalidFormatUrlExist', 'isNoOsChecked', 'controller.content.isCheckInProgress', 'App.router.btnClickInProgress'),
+  isSubmitDisabled: Em.computed.or('invalidFormatUrlExist', 'isNoOsChecked', 'isNoOsFilled', 'controller.content.isCheckInProgress', 'App.router.btnClickInProgress'),
+
+  /**
+   * Show warning message flag
+   *
+   * @type {bool}
+   */
+  showWarning: Em.computed.or('invalidFormatUrlExist', 'isNoOsChecked', 'isNoOsFilled'),
 
   /**
    * Onclick handler for recheck repos urls. Used in Advanced Repository Options.
@@ -179,6 +186,19 @@ App.WizardStep1View = Em.View.extend({
    */
   isNoOsChecked: Em.computed.everyBy('controller.selectedStack.operatingSystems', 'isSelected', false),
 
+  /**
+   * If all OSes are empty
+   * @type {bool}
+   */
+  isNoOsFilled: function () {
+    if (this.get('controller.selectedStack.useRedhatSatellite')) {
+      return false;
+    }
+    var operatingSystems = this.get('controller.selectedStack.operatingSystems');
+    var selectedOS = operatingSystems.filterProperty('isSelected', true);
+    return selectedOS.everyProperty('isEmpty', true);
+  }.property('controller.selectedStack.operatingSystems.@each.isSelected', 'controller.selectedStack.operatingSystems.@each.isEmpty', 'controller.selectedStack.useRedhatSatellite'),
+
   popoverView: Em.View.extend({
     tagName: 'i',
     classNameBindings: ['repository.validation'],

http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/test/controllers/installer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js
index e799467..881d6ae 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -79,14 +79,17 @@ describe('App.InstallerController', function () {
         stackNameVersion: 'nn-cc',
         repositories: Em.A([
           Em.Object.create({
-            isSelected: true
+            isSelected: true,
+            isEmpty: false
           })
         ]),
         operatingSystems: Em.A([
           Em.Object.create({
             isSelected: true,
+            isEmpty: false,
             repositories: Em.A([
               Em.Object.create({
+                isEmpty: false,
                 errorTitle: '1',
                 errorContent: '1',
                 validation: ''
@@ -115,14 +118,17 @@ describe('App.InstallerController', function () {
           "stackNameVersion": 'nn-cc',
           "repositories": [
             {
-              "isSelected": true
+              "isSelected": true,
+              "isEmpty": false
             }
           ],
           "operatingSystems": [
             {
               "isSelected": true,
+              "isEmpty": false,
               "repositories": [
                 {
+                  "isEmpty": false,
                   "errorTitle": "",
                   "errorContent": "",
                   "validation": "icon-repeat"
@@ -151,16 +157,19 @@ describe('App.InstallerController', function () {
         repositories: Em.A([
           Em.Object.create({
             repoId: 11,
-            isSelected: true
+            isSelected: true,
+            isEmpty: false
           })
         ]),
         operatingSystems: Em.A([
           Em.Object.create({
             isSelected: true,
+            isEmpty: false,
             id: 1,
             repositories: Em.A([
               Em.Object.create({
                 repoId: 11,
+                isEmpty: false,
                 errorTitle: '1',
                 errorContent: '1',
                 validation: ''
@@ -196,16 +205,19 @@ describe('App.InstallerController', function () {
           "repositories": [
             {
               "repoId": 11,
-              "isSelected": true
+              "isSelected": true,
+              "isEmpty": false
             }
           ],
           "operatingSystems": [
             {
               "isSelected": true,
+              "isEmpty": false,
               "id": 1,
               "repositories": [
                 {
                   "repoId": 11,
+                  "isEmpty": false,
                   "errorTitle": "1",
                   "errorContent": "1",
                   "validation": "icon-ok"

http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/test/utils/validator_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/validator_test.js b/ambari-web/test/utils/validator_test.js
index f70d1ba..f07539d 100644
--- a/ambari-web/test/utils/validator_test.js
+++ b/ambari-web/test/utils/validator_test.js
@@ -465,7 +465,7 @@ describe('validator', function () {
 
   describe('#isValidBaseUrl()', function() {
     var tests = [
-      {m: '"" - invalid', i: '', e: false},
+      {m: '"" - valid', i: '', e: true},
       {m: '"http://" - valid', i: 'http://', e: true},
       {m: '"https://" - valid', i: 'https://', e: true},
       {m: '"ftp://" - valid', i: 'ftp://', e: true},

http://git-wip-us.apache.org/repos/asf/ambari/blob/e241afcf/ambari-web/test/views/wizard/step1_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step1_view_test.js b/ambari-web/test/views/wizard/step1_view_test.js
index 3621aa9..1eceab1 100644
--- a/ambari-web/test/views/wizard/step1_view_test.js
+++ b/ambari-web/test/views/wizard/step1_view_test.js
@@ -33,7 +33,7 @@ describe('App.WizardStep1View', function () {
 
   App.TestAliases.testAsComputedEveryBy(getView(), 'isNoOsChecked', 'controller.selectedStack.operatingSystems', 'isSelected', false);
 
-  App.TestAliases.testAsComputedOr(getView(), 'isSubmitDisabled', ['invalidFormatUrlExist', 'isNoOsChecked', 'controller.content.isCheckInProgress', 'App.router.btnClickInProgress']);
+  App.TestAliases.testAsComputedOr(getView(), 'isSubmitDisabled', ['invalidFormatUrlExist', 'isNoOsChecked', 'isNoOsFilled', 'controller.content.isCheckInProgress', 'App.router.btnClickInProgress']);
 
   App.TestAliases.testAsComputedSomeBy(getView(), 'invalidUrlExist', 'allRepositories', 'validation', App.Repository.validation.INVALID);