You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/03/05 15:30:08 UTC

ambari git commit: AMBARI-9941. Skip group mod text changes after failure (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.0 45b8a093c -> 34d004c86


AMBARI-9941. Skip group mod text changes after failure (onechiporenko)


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

Branch: refs/heads/branch-2.0.0
Commit: 34d004c8622496295c3240cbb2b8c85860855514
Parents: 45b8a09
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Mar 5 15:21:36 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Mar 5 15:21:36 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/utils/config.js       |  21 +++-
 ambari-web/test/utils/config_test.js | 198 ++++++++++++++++++++++++++++++
 2 files changed, 215 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/34d004c8/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 8acf51a..009fb24 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1235,16 +1235,21 @@ App.config = Em.Object.create({
    */
   addUserProperty: function (stored, isAdvanced, advancedConfigs) {
     var
-      skipChangeOfDisplayType = ['ignore_groupsusers_create'],
-      originalDispType = advancedConfigs.findProperty('name', stored.name) ? advancedConfigs.findProperty('name', stored.name).displayType : stored.displayType;
+      skipAttributeChanges = {
+        displayType: ['ignore_groupsusers_create'],
+        displayName: ['ignore_groupsusers_create', 'smokeuser', 'user_group', 'mapred_user', 'zk_user']
+      },
       configData = {
         id: stored.id,
         name: stored.name,
-        displayName: App.format.normalizeName(stored.name),
+        displayName: skipAttributeChanges.displayName.contains(stored.name) ?
+          this.getOriginalConfigAttribute(stored, 'displayName', advancedConfigs) : App.format.normalizeName(stored.name),
         serviceName: stored.serviceName,
         value: stored.value,
         defaultValue: stored.defaultValue,
-        displayType: skipChangeOfDisplayType.contains(stored.name) ? originalDispType : (stringUtils.isSingleLine(stored.value) ? 'advanced' : 'multiLine'),
+        displayType: skipAttributeChanges.displayType.contains(stored.name) ?
+          this.getOriginalConfigAttribute(stored, 'displayType', advancedConfigs) :
+          (stringUtils.isSingleLine(stored.value) ? 'advanced' : 'multiLine'),
         filename: stored.filename,
         isUserProperty: stored.isUserProperty === true,
         hasInitialValue: !!stored.hasInitialValue,
@@ -1258,11 +1263,19 @@ App.config = Em.Object.create({
         showLabel: stored.showLabel !== false,
         category: stored.category
       };
+    if (stored.category == 'Users and Groups') {
+      configData.index = this.getOriginalConfigAttribute(stored, 'index', advancedConfigs);
+    }
 
     App.get('config').calculateConfigProperties(configData, isAdvanced, advancedConfigs);
     return configData;
   },
 
+  getOriginalConfigAttribute: function (stored, key, advancedConfigs) {
+    return advancedConfigs.findProperty('name', stored.name) ?
+      advancedConfigs.findProperty('name', stored.name)[key] : stored[key];
+  },
+
   complexConfigsTemplate: [
     {
       "id": "site property",

http://git-wip-us.apache.org/repos/asf/ambari/blob/34d004c8/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js
index cbc3ee1..97ff712 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -988,4 +988,202 @@ describe('App.config', function () {
 
   });
 
+  describe('#addUserProperty', function () {
+
+    var cases = [
+        {
+          stored: {
+            id: 0,
+            name: 'prop_name0',
+            serviceName: 's0',
+            value: 'v0',
+            defaultValue: 'dv0',
+            filename: 'fn0.xml',
+            overrides: null,
+            isVisible: false,
+            isFinal: true,
+            defaultIsFinal: false,
+            supportsFinal: true,
+            category: 'c0'
+          },
+          expected: {
+            id: 0,
+            name: 'prop_name0',
+            displayName: 'Prop Name0',
+            serviceName: 's0',
+            value: 'v0',
+            defaultValue: 'dv0',
+            displayType: 'advanced',
+            filename: 'fn0.xml',
+            isUserProperty: false,
+            hasInitialValue: false,
+            isOverridable: true,
+            overrides: null,
+            isRequired: false,
+            isVisible: false,
+            isFinal: true,
+            defaultIsFinal: false,
+            supportsFinal: true,
+            showLabel: true,
+            category: 'c0'
+          },
+          title: 'default case'
+        },
+        {
+          stored: {
+            name: 'n1',
+            value: 'multi\nline',
+            filename: 'fn1.xml',
+            isUserProperty: true,
+            hasInitialValue: true,
+            showLabel: false
+          },
+          expected: {
+            displayType: 'multiLine',
+            isUserProperty: true,
+            hasInitialValue: true,
+            showLabel: false
+          },
+          title: 'multiline user property with initial value, label not to be shown'
+        },
+        {
+          stored: {
+            name: 'n2',
+            filename: 'fn2.xml'
+          },
+          expected: {
+            isUserProperty: false,
+            showLabel: true
+          },
+          title: 'isUserProperty and showLabel not set'
+        },
+        {
+          stored: {
+            name: 'ignore_groupsusers_create',
+            category: 'Users and Groups',
+            filename: 'fn3.xml'
+          },
+          expected: {
+            displayName: 'dn0',
+            displayType: 'checkbox',
+            index: 0
+          }
+        },
+        {
+          stored: {
+            name: 'smokeuser',
+            category: 'Users and Groups',
+            filename: 'fn4.xml'
+          },
+          expected: {
+            displayName: 'dn1',
+            index: 1
+          }
+        },
+        {
+          stored: {
+            name: 'user_group',
+            category: 'Users and Groups',
+            filename: 'fn5.xml'
+          },
+          expected: {
+            displayName: 'dn1',
+            index: 2
+          }
+        },
+        {
+          stored: {
+            name: 'mapred_user',
+            category: 'Users and Groups',
+            filename: 'fn6.xml'
+          },
+          expected: {
+            displayName: 'dn1',
+            index: 3
+          }
+        },
+        {
+          stored: {
+            name: 'zk_user',
+            category: 'Users and Groups',
+            filename: 'fn7.xml'
+          },
+          expected: {
+            displayName: 'dn1',
+            index: 4
+          }
+        }
+      ],
+      advancedConfigs = [
+        {
+          name: 'ignore_groupsusers_create',
+          displayName: 'dn0',
+          displayType: 'checkbox',
+          index: 0
+        },
+        {
+          name: 'smokeuser',
+          displayName: 'dn1',
+          index: 1
+        },
+        {
+          name: 'user_group',
+          displayName: 'dn1',
+          index: 2
+        },
+        {
+          name: 'mapred_user',
+          displayName: 'dn1',
+          index: 3
+        },
+        {
+          name: 'zk_user',
+          displayName: 'dn1',
+          index: 4
+        }
+      ];
+
+    cases.forEach(function (item) {
+      it(item.title || item.stored.name, function () {
+        var configData = App.config.addUserProperty(item.stored, true, advancedConfigs);
+        Em.keys(item.expected).forEach(function (key) {
+          expect(configData[key]).to.equal(item.expected[key]);
+        });
+      });
+    });
+
+  });
+
+  describe('#getOriginalConfigAttribute', function () {
+
+    var stored = {
+        name: 'p',
+        displayName: 'dn'
+      },
+      cases = [
+        {
+          advancedConfigs: [
+            {
+              name: 'p',
+              displayName: 'dn0'
+            }
+          ],
+          expected: 'dn0',
+          title: 'should take attribute from advancedConfigs'
+        },
+        {
+          advancedConfigs: [],
+          expected: 'dn',
+          title: 'property is absent in advancedConfigs'
+        }
+      ];
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        expect(App.config.getOriginalConfigAttribute(stored, 'displayName', item.advancedConfigs)).to.equal(item.expected);
+      });
+    });
+
+  });
+
 });