Repository: ambari Updated Branches: refs/heads/trunk c3fb6ca29 -> 69786453c
AMBARI-5085 Add feature that allows disable buttons of popup. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/69786453 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/69786453 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/69786453 Branch: refs/heads/trunk Commit: 69786453cec5e927b488c4e11ddedf4266bd942f Parents: c3fb6ca Author: atkach <[email protected]> Authored: Fri Mar 14 17:11:34 2014 +0200 Committer: atkach <[email protected]> Committed: Fri Mar 14 17:11:34 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 20 ++++++----- .../main/mirroring/edit_dataset_controller.js | 7 ++-- .../mirroring/manage_clusters_controller.js | 8 ++--- .../controllers/main/service/info/configs.js | 5 +-- .../service/manage_config_groups_controller.js | 14 +++----- ambari-web/app/templates/common/modal_popup.hbs | 4 +-- .../main/host/details/deleteComponentPopup.hbs | 2 +- .../main/host/details/doDeleteHostPopup.hbs | 2 +- .../app/utils/batch_scheduled_requests.js | 5 +-- ambari-web/app/utils/config.js | 35 +++++++++----------- ambari-web/app/views/common/modal_popup.js | 12 +++---- ambari-web/test/installer/step6_test.js | 8 +++-- 12 files changed, 55 insertions(+), 67 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/controllers/main/host/details.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js index 631a770..69bc329 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/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; http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/controllers/main/mirroring/edit_dataset_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/mirroring/edit_dataset_controller.js b/ambari-web/app/controllers/main/mirroring/edit_dataset_controller.js index 54c0637..224583b 100644 --- a/ambari-web/app/controllers/main/mirroring/edit_dataset_controller.js +++ b/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'); http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js b/ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js index efcfa78..02ce1ed 100644 --- a/ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js +++ b/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]); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/controllers/main/service/info/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js index aa04475..26a7f6e 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/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 () {} http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/controllers/main/service/manage_config_groups_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js index 58e5d1d..bcd7e15 100644 --- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js +++ b/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({ http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/templates/common/modal_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popup.hbs b/ambari-web/app/templates/common/modal_popup.hbs index a3c1b2c..65a95d7 100644 --- a/ambari-web/app/templates/common/modal_popup.hbs +++ b/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}} http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs b/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs index 235b49f..5459223 100644 --- a/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs +++ b/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}} http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs b/ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs index 1e11a65..124409e 100644 --- a/ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs +++ b/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}} http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/utils/batch_scheduled_requests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/batch_scheduled_requests.js b/ambari-web/app/utils/batch_scheduled_requests.js index da7de43..f32a2dc 100644 --- a/ambari-web/app/utils/batch_scheduled_requests.js +++ b/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') }); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index 60fe9a2..aeb57f8 100644 --- a/ambari-web/app/utils/config.js +++ b/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') http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/app/views/common/modal_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js index 3724ab7..f8ff00f 100644 --- a/ambari-web/app/views/common/modal_popup.js +++ b/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'), http://git-wip-us.apache.org/repos/asf/ambari/blob/69786453/ambari-web/test/installer/step6_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/installer/step6_test.js b/ambari-web/test/installer/step6_test.js index 8ebc0e5..8bba557 100644 --- a/ambari-web/test/installer/step6_test.js +++ b/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); }
