Ver Fonte

AMBARI-5085 Add feature that allows disable buttons of popup. (atkach)

atkach há 11 anos atrás
pai
commit
69786453ce

+ 12 - 8
ambari-web/app/controllers/main/host/details.js

@@ -181,13 +181,16 @@ App.MainHostDetailsController = Em.Controller.extend({
       bodyClass: Ember.View.extend({
         templateName: require('templates/main/host/details/deleteComponentPopup')
       }),
-      enablePrimary: false,
+      isChecked: false,
+      disablePrimary: function () {
+        return !this.get('isChecked');
+      }.property('isChecked'),
       lastComponent: function() {
         if (isLastComponent) {
-          this.set('enablePrimary',false);
+          this.set('isChecked', false);
           return true;
         } else {
-          this.set('enablePrimary',true);
+          this.set('isChecked', true);
           return false;
         }
       }.property(),
@@ -201,7 +204,6 @@ App.MainHostDetailsController = Em.Controller.extend({
         return Em.I18n.t('hosts.host.deleteComponent.popup.msg1').format(displayName);
       }.property(),
       onPrimary: function () {
-        if (!this.get('enablePrimary')) return;
         self._doDeleteHostComponent(component);
         self.set('redrawComponents', true);
         this.hide();
@@ -1154,14 +1156,17 @@ App.MainHostDetailsController = Em.Controller.extend({
       }.property(),
       lastComponent: function() {
          if (lastComponents && lastComponents.length) {
-           this.set('enablePrimary',false);
+           this.set('isChecked', false);
            return true;
          } else {
-           this.set('enablePrimary',true);
+           this.set('isChecked', true);
            return false;
          }
       }.property(),
-      enablePrimary: false,
+      disablePrimary: function () {
+        return !this.get('isChecked');
+      }.property('isChecked'),
+      isChecked: false,
       lastComponentError:  Em.View.extend({
         template: Ember.Handlebars.compile(Em.I18n.t('hosts.delete.popup.body.msg4').format(lastComponents))
       }),
@@ -1175,7 +1180,6 @@ App.MainHostDetailsController = Em.Controller.extend({
         templateName: require('templates/main/host/details/doDeleteHostPopup')
       }),
       onPrimary: function() {
-        if (!this.get('enablePrimary')) return;
         self.set('fromDeleteHost', true);
         var allComponents = self.get('content.hostComponents');
         var deleteError = null;

+ 2 - 5
ambari-web/app/controllers/main/mirroring/edit_dataset_controller.js

@@ -100,13 +100,10 @@ App.MainMirroringEditDataSetController = Ember.Controller.extend({
       saveDisabled: function () {
         return self.get('saveDisabled');
       }.property('App.router.' + self.get('name') + '.saveDisabled'),
-      enablePrimary: function () {
-        return !this.get('saveDisabled');
+      disablePrimary: function () {
+        return this.get('saveDisabled');
       }.property('saveDisabled'),
       onPrimary: function () {
-        if (this.get('saveDisabled')) {
-          return false;
-        }
         // Apply form validation for first click
         if (!this.get('primaryWasClicked')) {
           this.toggleProperty('primaryWasClicked');

+ 3 - 5
ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js

@@ -76,10 +76,8 @@ App.MainMirroringManageClustersController = Em.ArrayController.extend({
       primary: Em.I18n.t('common.save'),
       secondary: Em.I18n.t('common.cancel'),
       onPrimary: function () {
-        if (this.get('enablePrimary')) {
-          this.set('enablePrimary', false);
-          self.createNewCluster();
-        }
+        this.set('disablePrimary', true);
+        self.createNewCluster();
       },
       willInsertElement: function () {
         var clusterName = App.get('clusterName');
@@ -149,7 +147,7 @@ App.MainMirroringManageClustersController = Em.ArrayController.extend({
   },
 
   onCreateClusterError: function () {
-    this.set('newClusterPopup.enablePrimary', true);
+    this.set('newClusterPopup.disablePrimary', false);
     App.showAlertPopup(Em.I18n.t('common.error'), Em.I18n.t('mirroring.manageClusters.error') + ': ' + arguments[2]);
   },
 

+ 1 - 4
ambari-web/app/controllers/main/service/info/configs.js

@@ -1730,9 +1730,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       classNames: ['sixty-percent-width-modal', 'manage-configuration-group-popup'],
       primary: Em.I18n.t('common.save'),
       onPrimary: function() {
-        if (!this.get('enablePrimary')) {
-          return false;
-        }
         var modifiedConfigGroups = this.get('subViewController.hostsModifiedConfigGroups');
         // Save modified config-groups
         if (!!controller) {
@@ -1834,7 +1831,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
 
       updateButtons: function(){
         var modified = this.get('subViewController.isHostsModified');
-        this.set('enablePrimary', modified);
+        this.set('disablePrimary', !modified);
       }.observes('subViewController.isHostsModified'),
       secondary : Em.I18n.t('common.cancel'),
       didInsertElement: function () {}

+ 4 - 10
ambari-web/app/controllers/main/service/manage_config_groups_controller.js

@@ -313,13 +313,10 @@ App.ManageConfigGroupsController = Em.Controller.extend({
         }
         this.set('warningMessage', warningMessage);
       }.observes('configGroupName', 'configGroupDesc'),
-      enablePrimary: function () {
-        return this.get('configGroupName').trim().length > 0 && !this.get('warningMessage');
+      disablePrimary: function () {
+        return !(this.get('configGroupName').trim().length > 0 && !this.get('warningMessage'));
       }.property('warningMessage', 'configGroupName', 'configGroupDesc'),
       onPrimary: function () {
-        if (!this.get('enablePrimary')) {
-          return;
-        }
         self.set('selectedConfigGroup.name', this.get('configGroupName'));
         self.set('selectedConfigGroup.description', this.get('configGroupDesc'));
         self.get('selectedConfigGroup.properties').forEach(function(property){
@@ -357,13 +354,10 @@ App.ManageConfigGroupsController = Em.Controller.extend({
         }
         this.set('warningMessage', warningMessage);
       }.observes('configGroupName'),
-      enablePrimary: function () {
-        return this.get('configGroupName').trim().length > 0 && !this.get('warningMessage');
+      disablePrimary: function () {
+        return !(this.get('configGroupName').trim().length > 0 && !this.get('warningMessage'));
       }.property('warningMessage', 'configGroupName'),
       onPrimary: function () {
-        if (!this.get('enablePrimary')) {
-          return false;
-        }
         var defaultConfigGroup = self.get('configGroups').findProperty('isDefault');
         var properties = [];
         var newConfigGroupData = App.ConfigGroup.create({

+ 2 - 2
ambari-web/app/templates/common/modal_popup.hbs

@@ -52,10 +52,10 @@
           {{t app.settings.notShowBgOperations}}</label>
         {{/if}}
         {{#if view.secondary}}
-          <a {{bindAttr class="view.enableSecondary::disabled :btn"}} {{action onSecondary target="view"}}>{{view.secondary}}</a>
+          <button class="btn" {{bindAttr disabled="view.disableSecondary"}} {{action onSecondary target="view"}}>{{view.secondary}}</button>
         {{/if}}
         {{#if view.primary}}
-          <a {{bindAttr class="view.enablePrimary::disabled :btn view.primaryClass"}} {{action onPrimary target="view"}}>{{view.primary}}</a>
+          <button {{bindAttr disabled="view.disablePrimary" class=":btn view.primaryClass"}} {{action onPrimary target="view"}}>{{view.primary}}</button>
         {{/if}}
       </div>
     {{/if}}

+ 1 - 1
ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs

@@ -19,7 +19,7 @@
 {{deleteComponentMsg}}<br /><br />
 {{#if lastComponent}}
     <div class="alert-error row-fluid">
-        <div class='tinyspan tinyoffset'>{{view Ember.Checkbox checkedBinding="enablePrimary"}}</div>
+        <div class='tinyspan tinyoffset'>{{view Ember.Checkbox checkedBinding="isChecked"}}</div>
         <div class='span10'>{{view lastComponentError}}</div>
     </div>
 {{/if}}

+ 1 - 1
ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs

@@ -28,7 +28,7 @@
 <p><i class="icon-warning-sign"></i> {{{deletePopupBody}}}</p>
 {{#if lastComponent}}
     <div class="alert-error row-fluid">
-        <div class='tinyspan tinyoffset'>{{view Ember.Checkbox checkedBinding="enablePrimary"}}</div>
+        <div class='tinyspan tinyoffset'>{{view Ember.Checkbox checkedBinding="isChecked"}}</div>
         <div class='span10'>{{view lastComponentError}}</div>
     </div>
 {{/if}}

+ 1 - 4
ambari-web/app/utils/batch_scheduled_requests.js

@@ -266,9 +266,6 @@ module.exports = {
       primary : Em.I18n.t('rollingrestart.dialog.primary'),
       onPrimary : function() {
         var dialog = this;
-        if (!dialog.get('enablePrimary')) {
-          return;
-        }
         var restartComponents = this.get('innerView.restartHostComponents');
         var batchSize = this.get('innerView.batchSize');
         var waitTime = this.get('innerView.interBatchWaitTimeSeconds');
@@ -280,7 +277,7 @@ module.exports = {
       },
       updateButtons : function() {
         var errors = this.get('innerView.errors');
-        this.set('enablePrimary', !(errors != null && errors.length > 0))
+        this.set('disablePrimary', (errors != null && errors.length > 0))
       }.observes('innerView.errors')
     });
   },

+ 16 - 19
ambari-web/app/utils/config.js

@@ -1135,13 +1135,10 @@ App.config = Em.Object.create({
       availableConfigGroups: availableConfigGroups,
       selectedConfigGroup: selectedConfigGroup,
       newConfigGroupName: '',
-      enablePrimary: function () {
-        return this.get('optionSelectConfigGroup') || (this.get('newConfigGroupName').trim().length > 0 && !this.get('isWarning'));
+      disablePrimary: function () {
+        return !(this.get('optionSelectConfigGroup') || (this.get('newConfigGroupName').trim().length > 0 && !this.get('isWarning')));
       }.property('newConfigGroupName', 'optionSelectConfigGroup', 'warningMessage'),
       onPrimary: function () {
-        if (!this.get('enablePrimary')) {
-          return false;
-        }
         if (this.get('optionSelectConfigGroup')) {
           var selectedConfigGroup = this.get('selectedConfigGroup');
           this.hide();
@@ -1244,23 +1241,23 @@ App.config = Em.Object.create({
       header: Em.I18n.t('config.group.host.switch.dialog.title'),
       configGroups: configGroups,
       selectedConfigGroup: selectedGroup,
-      enablePrimary: function () {
-        return this.get('selectedConfigGroup.name') !== selectedGroup.get('name');
+      disablePrimary: function () {
+        return !(this.get('selectedConfigGroup.name') !== selectedGroup.get('name'));
       }.property('selectedConfigGroup'),
       onPrimary: function () {
-        if (this.get('enablePrimary')) {
-          var newGroup = this.get('selectedConfigGroup');
-          selectedGroup.get('hosts').removeObject(hostName);
-          if (!selectedGroup.get('isDefault')) {
-            self.updateConfigurationGroup(selectedGroup, function(){}, function(){});
-          }
-          newGroup.get('hosts').pushObject(hostName);
-          callback(newGroup);
-          if (!newGroup.get('isDefault')) {
-            self.updateConfigurationGroup(newGroup, function(){}, function(){});
-          }
-          this.hide();
+        var newGroup = this.get('selectedConfigGroup');
+        selectedGroup.get('hosts').removeObject(hostName);
+        if (!selectedGroup.get('isDefault')) {
+          self.updateConfigurationGroup(selectedGroup, function () {
+          }, function () {});
+        }
+        newGroup.get('hosts').pushObject(hostName);
+        callback(newGroup);
+        if (!newGroup.get('isDefault')) {
+          self.updateConfigurationGroup(newGroup, function () {
+          }, function () {});
         }
+        this.hide();
       },
       bodyClass: Ember.View.extend({
         templateName: require('templates/utils/config_launch_switch_config_group_of_host')

+ 6 - 6
ambari-web/app/views/common/modal_popup.js

@@ -29,8 +29,8 @@ App.ModalPopup = Ember.View.extend({
   primary: Em.I18n.t('ok'),
   secondary: Em.I18n.t('common.cancel'),
   autoHeight: true,
-  enablePrimary: true,
-  enableSecondary: true,
+  disablePrimary: false,
+  disableSecondary: false,
   primaryClass: 'btn-success',
   onPrimary: function () {
     this.hide();
@@ -160,8 +160,8 @@ App.showConfirmationFeedBackPopup = function (primary, secondary) {
     query: Em.Object.create({status: "INIT"}),
     onPrimary: function () {
       this.set('query.status', "INIT");
-      this.set('enablePrimary', false);
-      this.set('enableSecondary', false);
+      this.set('disablePrimary', true);
+      this.set('disableSecondary', true);
       this.set('statusMessage', Em.I18n.t('popup.confirmationFeedBack.sending'));
       primary(this.get('query'));
     },
@@ -172,8 +172,8 @@ App.showConfirmationFeedBackPopup = function (primary, secondary) {
       } else if(this.get('query.status') === "FAIL") {
         this.set('primaryClass', 'btn-primary');
         this.set('primary', Em.I18n.t('common.retry'));
-        this.set('enablePrimary', true);
-        this.set('enableSecondary', true);
+        this.set('disablePrimary', false);
+        this.set('disableSecondary', false);
         this.set('statusMessage', Em.I18n.t('popup.confirmationFeedBack.query.fail'));
       }
     }.observes('query.status'),

+ 6 - 2
ambari-web/test/installer/step6_test.js

@@ -127,28 +127,32 @@ describe('App.WizardStep6Controller', function () {
     var test_config = [
       {
         title: 'DataNode',
+        name: 'DATANODE',
         state: false
       },
       {
         title: 'DataNode',
+        name: 'DATANODE',
         state: true
       },
       {
         title: 'TaskTracker',
+        name: 'TASKTRACKER',
         state: false
       },
       {
         title: 'TaskTracker',
+        name: 'TASKTRACKER',
         state: true
       }
     ];
 
     test_config.forEach(function(test) {
       it((test.state?'Select':'Deselect') + ' all ' + test.title, function() {
-        controller.setAllNodes(test.title, test.state);
+        controller.setAllNodes(test.name, test.state);
         var hosts = controller.get('hosts');
         hosts.forEach(function(host) {
-          var cb = host.get('checkboxes').filterProperty('isInstalled', false).findProperty('title', test.title);
+          var cb = host.get('checkboxes').filterProperty('isInstalled', false).findProperty('component', test.name);
           if (cb) {
             expect(cb.get('checked')).to.equal(test.state);
           }