AMBARI-7236. UI changes for "rename host group deletes configs". (akovalenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d3bfd49d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d3bfd49d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d3bfd49d

Branch: refs/heads/branch-alerts-dev
Commit: d3bfd49d4c8e15cadce01e9c7abdc33a5fe8f4bc
Parents: 22b1df0
Author: Aleksandr Kovalenko <akovale...@hortonworks.com>
Authored: Wed Sep 10 13:28:04 2014 +0300
Committer: Aleksandr Kovalenko <akovale...@hortonworks.com>
Committed: Wed Sep 10 13:28:04 2014 +0300

----------------------------------------------------------------------
 .../main/service/manage_config_groups_controller.js  | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d3bfd49d/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 53a11d7..76b7005 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
@@ -484,27 +484,30 @@ App.ManageConfigGroupsController = Em.Controller.extend({
     var groupsToCreate = [];
     var groups = this.get('configGroups');
     var originalGroups = this.get('originalConfigGroups');
-    var originalGroupsNames = 
originalGroups.mapProperty('name').without(originalGroups.findProperty('isDefault').get('name'));
+    // remove default group
+    originalGroups = 
originalGroups.without(originalGroups.findProperty('isDefault'));
+    var originalGroupsIds = originalGroups.mapProperty('id');
     groups.forEach(function (group) {
       if (!group.get('isDefault')) {
-        var originalGroup = originalGroups.findProperty('name', 
group.get('name'));
+        var originalGroup = originalGroups.findProperty('id', group.get('id'));
         if (originalGroup) {
           if (!(JSON.stringify(group.get('hosts').slice().sort()) === 
JSON.stringify(originalGroup.get('hosts').sort()))) {
             groupsToClearHosts.push(group.set('id', originalGroup.get('id')));
             if (group.get('hosts').length) {
               groupsToSetHosts.push(group.set('id', originalGroup.get('id')));
             }
-          } else if (group.get('description') !== 
originalGroup.get('description')) {
+          // should update name or description
+          } else if (group.get('description') !== 
originalGroup.get('description') || group.get('name') !== 
originalGroup.get('name') ) {
             groupsToSetHosts.push(group.set('id', originalGroup.get('id')));
           }
-          originalGroupsNames = originalGroupsNames.without(group.get('name'));
+          originalGroupsIds = originalGroupsIds.without(group.get('id'));
         } else {
           groupsToCreate.push(group);
         }
       }
     });
-    originalGroupsNames.forEach(function (groupName) {
-      groupsToDelete.push(originalGroups.findProperty('name', groupName));
+    originalGroupsIds.forEach(function (id) {
+      groupsToDelete.push(originalGroups.findProperty('id', id));
     }, this);
     return {
       toClearHosts: groupsToClearHosts,

Reply via email to