Browse Source

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

Zhe (Joe) Wang 9 years ago
parent
commit
d86fbe8372

+ 4 - 2
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);
     }

+ 1 - 1
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.',

+ 3 - 1
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)
 });
 
 

+ 4 - 0
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'),

+ 2 - 5
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}}

+ 2 - 2
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);
   },
 

+ 21 - 1
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'],

+ 16 - 4
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"

+ 1 - 1
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},

+ 1 - 1
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);