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 2016/12/29 15:17:33 UTC
ambari git commit: AMBARI-19287. Adding custom property should trim
white spaces in the prefix and suffix of the key names (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/branch-2.5 acedae5fe -> 95ac5be31
AMBARI-19287. Adding custom property should trim white spaces in the prefix and suffix of the key names (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/95ac5be3
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/95ac5be3
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/95ac5be3
Branch: refs/heads/branch-2.5
Commit: 95ac5be3183b42c91a788aa73dd4cd3b953240c2
Parents: acedae5
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Dec 29 14:13:23 2016 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Dec 29 17:16:49 2016 +0200
----------------------------------------------------------------------
ambari-web/app/utils/validator.js | 4 +++-
.../views/common/configs/service_configs_by_category_view.js | 7 +++----
ambari-web/test/utils/validator_test.js | 5 ++++-
3 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/95ac5be3/ambari-web/app/utils/validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/validator.js b/ambari-web/app/utils/validator.js
index 7b08d37..774215b 100644
--- a/ambari-web/app/utils/validator.js
+++ b/ambari-web/app/utils/validator.js
@@ -180,11 +180,13 @@ module.exports = {
/**
* validate key of configurations
+ * allow spaces as prefix and suffix
+ *
* @param value
* @return {Boolean}
*/
isValidConfigKey: function(value) {
- var configKeyRegex = /^[0-9a-z_\-\.\*]+$/i;
+ var configKeyRegex = /^\s*[0-9a-z_\-\.\*]+\s*$/i;
return configKeyRegex.test(value);
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/95ac5be3/ambari-web/app/views/common/configs/service_configs_by_category_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_configs_by_category_view.js b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
index 6305cfe..c38b672 100644
--- a/ambari-web/app/views/common/configs/service_configs_by_category_view.js
+++ b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
@@ -489,8 +489,8 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
showFilterLink: false,
errorMessage: '',
observeAddPropertyValue: function () {
- var name = this.get('name');
- if (name.trim() != '') {
+ var name = this.get('name').trim();
+ if (name !== '') {
if (validator.isValidConfigKey(name)) {
if (!self.isDuplicatedConfigKey(name)) { //no duplication within the same confType
var files = self.isDuplicatedConfigKeyinConfigs(name);
@@ -561,7 +561,7 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
* For the first entrance use this if (serviceConfigObj.name.trim() != '')
*/
if (!serviceConfigObj.isKeyError) {
- propertyObj.name = serviceConfigObj.get('name');
+ propertyObj.name = serviceConfigObj.get('name').trim();
propertyObj.value = serviceConfigObj.get('value');
propertyObj.propertyType = serviceConfigObj.get('propertyType');
self.createProperty(propertyObj);
@@ -730,7 +730,6 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
*/
doRestoreDefaultValue: function (event) {
var serviceConfigProperty = event.contexts[0];
- var value = serviceConfigProperty.get('value');
var savedValue = serviceConfigProperty.get('savedValue');
var supportsFinal = serviceConfigProperty.get('supportsFinal');
var savedIsFinal = serviceConfigProperty.get('savedIsFinal');
http://git-wip-us.apache.org/repos/asf/ambari/blob/95ac5be3/ambari-web/test/utils/validator_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/validator_test.js b/ambari-web/test/utils/validator_test.js
index f542c7a..f0167da 100644
--- a/ambari-web/test/utils/validator_test.js
+++ b/ambari-web/test/utils/validator_test.js
@@ -371,7 +371,10 @@ describe('validator', function () {
{m:'"-abc-" - valid',i:'-abc-',e:true},
{m:'"abc 123" - invalid',i:'abc 123',e:false},
{m:'"a"b" - invalid',i:'a"b',e:false},
- {m:'"a\'b" - invalid',i:'a\'b',e:false}
+ {m:'"a\'b" - invalid',i:'a\'b',e:false},
+ {m:'" a " - valid', i: ' a ', e: true},
+ {m:'" a" - valid', i: ' a', e: true},
+ {m:'"a " - valid', i: 'a ', e: true}
];
tests.forEach(function(test) {
it(test.m + ' ', function () {