Updated Branches: refs/heads/trunk f0682821b -> d4a0a57a8
AMBARI-3886. Config group name validation doesn't include newly added and removed goups. (akovalenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d4a0a57a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d4a0a57a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d4a0a57a Branch: refs/heads/trunk Commit: d4a0a57a85f8e61c0945e5d047c9642586c9fcd6 Parents: f068282 Author: Aleksandr Kovalenko <[email protected]> Authored: Tue Nov 26 17:24:38 2013 +0200 Committer: Aleksandr Kovalenko <[email protected]> Committed: Tue Nov 26 17:24:38 2013 +0200 ---------------------------------------------------------------------- .../controllers/main/service/info/configs.js | 9 ++-- ambari-web/app/controllers/main/service/item.js | 2 +- .../service/manage_config_groups_controller.js | 48 +++++++++++++++----- .../app/controllers/wizard/step7_controller.js | 10 ++-- ambari-web/app/utils/config.js | 7 ++- .../app/views/common/configs/services_config.js | 2 +- .../main/service/manage_config_groups_view.js | 2 +- 7 files changed, 55 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a0a57a/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 e00f0b3..ff2f310 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/ambari-web/app/controllers/main/service/info/configs.js @@ -35,7 +35,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ isApplyingChanges: false, // contain Service Config Property, when user proceed from Select Config Group dialog overrideToAdd: null, - allConfigGroupsNames: [], + usedConfigGroupNames: [], serviceConfigs: function () { return App.config.get('preDefinedServiceConfigs'); }.property('App.config.preDefinedServiceConfigs'), @@ -263,7 +263,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ // Create default configuration group var defaultConfigGroupHosts = App.Host.find().mapProperty('hostName'); var selectedConfigGroup; - var allConfigGroupsNames = ['Default']; + var usedConfigGroupNames = ['Default']; var siteToTagMap = {}; for (var site in data.Clusters.desired_configs) { if (serviceConfigsDef.sites.indexOf(site) > -1) { @@ -277,7 +277,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ if (data.config_groups.length) { data.config_groups.forEach(function (item) { item = item.ConfigGroup; - allConfigGroupsNames.push(item.group_name); if (item.tag === this.get('content.serviceName')) { var groupHosts = item.hosts.mapProperty('host_name'); var newConfigGroup = App.ConfigGroup.create({ @@ -304,9 +303,11 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ selectedConfigGroup = newConfigGroup; } configGroups.push(newConfigGroup); + } else { + usedConfigGroupNames.push(item.group_name); } }, this); - this.set('allConfigGroupsNames', allConfigGroupsNames); + this.set('usedConfigGroupNames', usedConfigGroupNames); } this.set('configGroups', configGroups); } http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a0a57a/ambari-web/app/controllers/main/service/item.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js index 76778ed..7a860dc 100644 --- a/ambari-web/app/controllers/main/service/item.js +++ b/ambari-web/app/controllers/main/service/item.js @@ -235,7 +235,7 @@ App.MainServiceItemController = Em.Controller.extend({ header: Em.I18n.t('services.service.config_groups_popup.header').format(displayName), bodyClass: App.MainServiceManageConfigGroupView.extend({ serviceName: serviceName, - allConfigGroupsNames: (controller && controller.get('allConfigGroupsNames')), + usedConfigGroupNames: (controller && controller.get('usedConfigGroupNames')), controllerBinding: (!!controller) ? 'App.router.installerManageConfigGroupsController' : 'App.router.manageConfigGroupsController' }), classNames: ['sixty-percent-width-modal', 'manage-configuration-group-popup'], http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a0a57a/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 423e975..5014267 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 @@ -36,7 +36,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({ loadedHostsToGroupMap: {}, - allConfigGroupsNames: [], + usedConfigGroupNames: [], loadConfigGroups: function (serviceName) { this.set('serviceName', serviceName); @@ -64,10 +64,9 @@ App.ManageConfigGroupsController = Em.Controller.extend({ var groupToTypeToTagMap = {}; var configGroups = []; var serviceName = this.get('serviceName'); - var allConfigGroupsNames = []; + var usedConfigGroupNames = []; data.items.forEach(function (configGroup) { configGroup = configGroup.ConfigGroup; - allConfigGroupsNames.push(configGroup.group_name); if (configGroup.tag === serviceName) { var hostNames = configGroup.hosts.mapProperty('host_name'); loadedHostsToGroupMap[configGroup.group_name] = hostNames.slice(); @@ -96,9 +95,11 @@ App.ManageConfigGroupsController = Em.Controller.extend({ } groupToTypeToTagMap[configGroup.group_name][config.type] = config.tag; }); + } else { + usedConfigGroupNames.push(configGroup.group_name); } }, this); - this.set('allConfigGroupsNames', allConfigGroupsNames); + this.set('usedConfigGroupNames', usedConfigGroupNames); unusedHosts = App.Host.find().mapProperty('hostName'); usedHosts.uniq().forEach(function (host) { unusedHosts = unusedHosts.without(host); @@ -260,6 +261,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({ return; } var content = this; + var self = this; this.renameGroupPopup = App.ModalPopup.show({ primary: Em.I18n.t('ok'), secondary: Em.I18n.t('common.cancel'), @@ -269,7 +271,20 @@ App.ManageConfigGroupsController = Em.Controller.extend({ }), configGroupName: "", content: content, + validate: function () { + var warningMessage = ''; + if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName'))) { + warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists"); + } + this.set('warningMessage', warningMessage); + }.observes('configGroupName'), + enablePrimary: function () { + return this.get('configGroupName').length > 0 && !this.get('warningMessage'); + }.property('warningMessage', 'configGroupName'), onPrimary: function () { + if (!this.get('enablePrimary')) { + return false; + } this.get('content.selectedConfigGroup').set('name', this.get('configGroupName')); this.get('content.selectedConfigGroup').set('description', this.get('configGroupDesc')); this.get('content.selectedConfigGroup.apiResponse').group_name = this.get('configGroupName'); @@ -313,9 +328,9 @@ App.ManageConfigGroupsController = Em.Controller.extend({ configGroupDesc: "", content: content, warningMessage: '', - vaildate: function () { + validate: function () { var warningMessage = ''; - if (self.get('allConfigGroupsNames').contains(this.get('configGroupName'))) { + if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName'))) { warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists"); } this.set('warningMessage', warningMessage); @@ -324,6 +339,9 @@ App.ManageConfigGroupsController = Em.Controller.extend({ return this.get('configGroupName').length > 0 && !this.get('warningMessage'); }.property('warningMessage', 'configGroupName'), onPrimary: function () { + if (!this.get('enablePrimary')) { + return false; + } this.get('content').set('configGroupName', this.get('configGroupName')); this.get('content').set('configGroupDesc', this.get('configGroupDesc')); var desiredConfig = []; @@ -463,9 +481,9 @@ App.ManageConfigGroupsController = Em.Controller.extend({ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.extend({ name: 'installerManageConfigGroupsController', - loadConfigGroups: function (serviceName, allConfigGroupsNames) { + loadConfigGroups: function (serviceName, usedConfigGroupNames) { this.set('serviceName', serviceName); - this.set('allConfigGroupsNames', allConfigGroupsNames); + this.set('usedConfigGroupNames', usedConfigGroupNames); var loadedHostsToGroupMap = this.get('loadedHostsToGroupMap'); var configGroups = this.copyConfigGroups(App.router.get('wizardStep7Controller.selectedService.configGroups')); configGroups.forEach(function (configGroup) { @@ -528,9 +546,9 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext configGroupName: self.get('selectedConfigGroup.name'), configGroupDesc: self.get('selectedConfigGroup.description'), warningMessage: '', - vaildate: function () { + validate: function () { var warningMessage = ''; - if (self.get('allConfigGroupsNames').contains(this.get('configGroupName'))) { + if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName'))) { warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists"); } this.set('warningMessage', warningMessage); @@ -539,6 +557,9 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext return this.get('configGroupName').length > 0 && !this.get('warningMessage'); }.property('warningMessage', 'configGroupName'), onPrimary: function () { + if (!this.get('enablePrimary')) { + return false; + } self.set('selectedConfigGroup.name', this.get('configGroupName')); self.set('selectedConfigGroup.description', this.get('configGroupDesc')); this.hide(); @@ -560,9 +581,9 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext configGroupName: "", configGroupDesc: "", warningMessage: '', - vaildate: function () { + validate: function () { var warningMessage = ''; - if (self.get('allConfigGroupsNames').contains(this.get('configGroupName'))) { + if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName'))) { warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists"); } this.set('warningMessage', warningMessage); @@ -571,6 +592,9 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext return this.get('configGroupName').length > 0 && !this.get('warningMessage'); }.property('warningMessage', 'configGroupName'), onPrimary: function () { + if (!this.get('enablePrimary')) { + return false; + } var defaultConfigGroup = self.get('configGroups').findProperty('isDefault'); var newConfigGroupData = App.ConfigGroup.create({ id: null, http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a0a57a/ambari-web/app/controllers/wizard/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js index c0c5617..93c91f1 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -52,12 +52,14 @@ App.WizardStep7Controller = Em.Controller.extend({ configGroups: [], selectedConfigGroup: null, - allConfigGroupsNames: function () { + usedConfigGroupNames: function () { var names = []; + var selectedServiceName = this.get('selectedService.serviceName'); this.get('stepConfigs').forEach(function (service) { - names.pushObjects(service.get('configGroups').mapProperty('name')); - }); - return names.uniq(); + if (selectedServiceName != service.get('serviceName')) { + names.pushObjects(service.get('configGroups').mapProperty('name'));} + }, this); + return names; }.property('[email protected]'), isSubmitDisabled: function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a0a57a/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index 5f9e520..6bbc82f 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -984,7 +984,7 @@ App.config = Em.Object.create({ * @param callback Callback function which is invoked when dialog * is closed, cancelled or OK is pressed. */ - launchConfigGroupSelectionCreationDialog : function(serviceId, configGroups, allConfigGroupsNames, configProperty, callback, isInstaller) { + launchConfigGroupSelectionCreationDialog : function(serviceId, configGroups, usedConfigGroupNames, configProperty, callback, isInstaller) { var self = this; var availableConfigGroups = configGroups.slice(); // delete Config Groups, that already have selected property overridden @@ -1018,6 +1018,9 @@ App.config = Em.Object.create({ return this.get('optionSelectConfigGroup') || (this.get('newConfigGroupName').length > 0 && !this.get('warningMessage')); }.property('newConfigGroupName', 'optionSelectConfigGroup', 'warningMessage'), onPrimary: function () { + if (!this.get('enablePrimary')) { + return false; + } if (this.get('optionSelectConfigGroup')) { var selectedConfigGroup = this.get('selectedConfigGroup'); this.hide(); @@ -1047,7 +1050,7 @@ App.config = Em.Object.create({ var optionSelect = this.get('optionSelectConfigGroup'); if (!optionSelect) { var nn = this.get('newConfigGroupName'); - if (nn && allConfigGroupsNames.contains(nn)) { + if (nn && usedConfigGroupNames.concat(configGroups.mapProperty('name')).contains(nn)) { msg = Em.I18n.t("config.group.selection.dialog.err.name.exists"); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a0a57a/ambari-web/app/views/common/configs/services_config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/services_config.js b/ambari-web/app/views/common/configs/services_config.js index 47b4962..89e029d 100644 --- a/ambari-web/app/views/common/configs/services_config.js +++ b/ambari-web/app/views/common/configs/services_config.js @@ -514,7 +514,7 @@ App.ServiceConfigsByCategoryView = Ember.View.extend({ if (selectedConfigGroup.get('isDefault')) { // Launch dialog to pick/create Config-group App.config.launchConfigGroupSelectionCreationDialog(this.get('service.serviceName'), - configGroups, serviceConfigController.get('allConfigGroupsNames'), serviceConfigProperty, function (selectedGroupInPopup) { + configGroups, serviceConfigController.get('usedConfigGroupNames'), serviceConfigProperty, function (selectedGroupInPopup) { console.log("launchConfigGroupSelectionCreationDialog(): Selected/Created:", selectedGroupInPopup); if (selectedGroupInPopup) { serviceConfigController.set('overrideToAdd', serviceConfigProperty); http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a0a57a/ambari-web/app/views/main/service/manage_config_groups_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/manage_config_groups_view.js b/ambari-web/app/views/main/service/manage_config_groups_view.js index 9ba4a0f..1d4af36 100644 --- a/ambari-web/app/views/main/service/manage_config_groups_view.js +++ b/ambari-web/app/views/main/service/manage_config_groups_view.js @@ -59,7 +59,7 @@ App.MainServiceManageConfigGroupView = Em.View.extend({ }.observes('controller.isLoaded', 'controller.configGroups'), didInsertElement: function () { - this.get('controller').loadConfigGroups(this.get('serviceName'), this.get('allConfigGroupsNames')); + this.get('controller').loadConfigGroups(this.get('serviceName'), this.get('usedConfigGroupNames')); $('.properties-link').tooltip(); $("[rel='button-info']").tooltip(); },
