Browse Source

AMBARI-4106 Should not allow blank config group name. (ababiichuk)

aBabiichuk 11 years ago
parent
commit
7ff8e74c51

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

@@ -575,7 +575,7 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
         if (originalGroup.get('description') !== this.get('configGroupDesc') && !this.get('isDescriptionDirty')) {
         if (originalGroup.get('description') !== this.get('configGroupDesc') && !this.get('isDescriptionDirty')) {
           this.set('isDescriptionDirty', true);
           this.set('isDescriptionDirty', true);
         }
         }
-        if (originalGroup.get('name') === this.get('configGroupName')) {
+        if (originalGroup.get('name').trim() === this.get('configGroupName').trim()) {
           if (this.get('isDescriptionDirty')) {
           if (this.get('isDescriptionDirty')) {
             warningMessage = '';
             warningMessage = '';
           } else {
           } else {
@@ -589,7 +589,7 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
         this.set('warningMessage', warningMessage);
         this.set('warningMessage', warningMessage);
       }.observes('configGroupName', 'configGroupDesc'),
       }.observes('configGroupName', 'configGroupDesc'),
       enablePrimary: function () {
       enablePrimary: function () {
-        return this.get('configGroupName').length > 0 && !this.get('warningMessage');
+        return this.get('configGroupName').trim().length > 0 && !this.get('warningMessage');
       }.property('warningMessage', 'configGroupName', 'configGroupDesc'),
       }.property('warningMessage', 'configGroupName', 'configGroupDesc'),
       onPrimary: function () {
       onPrimary: function () {
         if (!this.get('enablePrimary')) {
         if (!this.get('enablePrimary')) {
@@ -623,13 +623,13 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
       warningMessage: '',
       warningMessage: '',
       validate: function () {
       validate: function () {
         var warningMessage = '';
         var warningMessage = '';
-        if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName'))) {
+        if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName').trim())) {
           warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
           warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
         }
         }
         this.set('warningMessage', warningMessage);
         this.set('warningMessage', warningMessage);
       }.observes('configGroupName'),
       }.observes('configGroupName'),
       enablePrimary: function () {
       enablePrimary: function () {
-        return this.get('configGroupName').length > 0 && !this.get('warningMessage');
+        return this.get('configGroupName').trim().length > 0 && !this.get('warningMessage');
       }.property('warningMessage', 'configGroupName'),
       }.property('warningMessage', 'configGroupName'),
       onPrimary: function () {
       onPrimary: function () {
         if (!this.get('enablePrimary')) {
         if (!this.get('enablePrimary')) {
@@ -639,7 +639,7 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
         var properties = [];
         var properties = [];
         var newConfigGroupData = App.ConfigGroup.create({
         var newConfigGroupData = App.ConfigGroup.create({
           id: null,
           id: null,
-          name: this.get('configGroupName'),
+          name: this.get('configGroupName').trim(),
           description: this.get('configGroupDesc'),
           description: this.get('configGroupDesc'),
           isDefault: false,
           isDefault: false,
           parentConfigGroup: defaultConfigGroup,
           parentConfigGroup: defaultConfigGroup,