瀏覽代碼

AMBARI-6406 Move Wizard: assign master step next button is not disabled, when host input has error. (atkach)

atkach 11 年之前
父節點
當前提交
e3de7b3b68

+ 26 - 0
ambari-web/app/controllers/main/service/reassign/step2_controller.js

@@ -82,6 +82,32 @@ App.ReassignMasterWizardStep2Controller = App.WizardStep5Controller.extend({
       }
       item.set("availableHosts", preparedAvailableHosts.sortProperty('host_name'));
     }, this);
+  },
+  /**
+   * Determines if hostName is valid for component:
+   * <ul>
+   *  <li>host should have only one component with <code>componentName</code></li>
+   * </ul>
+   * @param {string} componentName
+   * @param {string} selectedHost
+   * @returns {boolean} true - valid, false - invalid
+   * @method isHostNameValid
+   */
+  isHostNameValid: function (componentName, selectedHost) {
+    var isValid = this._super(componentName, selectedHost);
+
+    if (isValid) {
+      var reassigned = 0;
+      var existedComponents = App.HostComponent.find().filterProperty('componentName', this.get('content.reassign.component_name')).mapProperty('hostName');
+      var newComponents = this.get('servicesMasters').mapProperty('selectedHost');
+      existedComponents.forEach(function (host) {
+        if (!newComponents.contains(host)) {
+          reassigned++;
+        }
+      }, this);
+      isValid = !(reassigned !== 1);
+    }
+    return isValid;
   }
 });
 

+ 3 - 32
ambari-web/app/controllers/wizard/step5_controller.js

@@ -185,40 +185,11 @@ App.WizardStep5Controller = Em.Controller.extend({
    * @metohd getIsSubmitDisabled
    */
   getIsSubmitDisabled: function () {
-    if (!this.get('isReassignWizard')) {
-      this.set('submitDisabled', this.get('servicesMasters').someProperty('isHostNameValid', false));
-    }
-    else {
-      App.ajax.send({
-        name: 'host_components.all',
-        sender: this,
-        data: {
-          clusterName: App.get('clusterName')
-        },
-        success: 'getIsSubmitDisabledSuccessCallBack'
-      });
-    }
+    var isSubmitDisabled = this.get('servicesMasters').someProperty('isHostNameValid', false);
+    this.set('submitDisabled', isSubmitDisabled);
+    return isSubmitDisabled;
   }.observes('servicesMasters.@each.selectedHost', 'servicesMasters.@each.isHostNameValid'),
 
-  /**
-   * Success callback for getIsSubmitDisabled method
-   * Set true for Reassign Master Wizard and if more than one master component was reassigned.
-   * For installer, addHost and addService verify that provided host names for components are valid
-   * @param {object} response
-   * @method getIsSubmitDisabledSuccessCallBack
-   */
-  getIsSubmitDisabledSuccessCallBack: function (response) {
-    var reassigned = 0;
-    var arr1 = response.items.mapProperty('HostRoles').filterProperty('component_name', this.get('content.reassign.component_name')).mapProperty('host_name');
-    var arr2 = this.get('servicesMasters').mapProperty('selectedHost');
-    arr1.forEach(function (host) {
-      if (!arr2.contains(host)) {
-        reassigned++;
-      }
-    }, this);
-    this.set('submitDisabled', reassigned !== 1);
-  },
-
   /**
    * Clear controller data (hosts, masters etc)
    * @method clearStep