ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-9941. Skip group mod text changes after failure (onechiporenko)
Date Thu, 05 Mar 2015 14:30:29 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f149fd15c -> 4a54f0304


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/4a54f030
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4a54f030
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4a54f030

Branch: refs/heads/trunk
Commit: 4a54f03048e827bc7affb2262e44ae6d14cfd74c
Parents: f149fd1
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Thu Mar 5 15:20:06 2015 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Thu Mar 5 15:20:06 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/4a54f030/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/4a54f030/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);
+      });
+    });
+
+  });
+
 });


Mime
View raw message