Repository: ambari
Updated Branches:
  refs/heads/trunk 281875354 -> e6dcdf633


AMBARI-20338. Alert Definition Name with brackets marked as invalid 
(onechiporenko)


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

Branch: refs/heads/trunk
Commit: e6dcdf633f3949f8a59203185c8fb65874932e67
Parents: 2818753
Author: Oleg Nechiporenko <[email protected]>
Authored: Tue Mar 7 12:24:31 2017 +0200
Committer: Oleg Nechiporenko <[email protected]>
Committed: Tue Mar 7 13:01:38 2017 +0200

----------------------------------------------------------------------
 ambari-web/app/messages.js              |  2 +-
 ambari-web/app/utils/validator.js       |  2 +-
 ambari-web/test/utils/validator_test.js | 21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e6dcdf63/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 44bf13e..a0bc119 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1152,7 +1152,7 @@ Em.I18n.translations = {
   'alerts.definition.name': 'Alert Definition Name',
   'alerts.saveChanges': 'You have unsaved changes',
 
-  'alert.definition.name.invalid': 'Invalid input. Only alphanumerics, 
underscores, hyphens, percentage and spaces are allowed.',
+  'alert.definition.name.invalid': 'Invalid input. Only alphanumerics, 
underscores, hyphens, percentage, brackets and spaces are allowed. Value should 
be less than 255 symbols.',
   'alerts.definition.details.enable': 'Enable',
   'alerts.definition.details.disable': 'Disable',
   'alerts.definition.details.enableDisable': 'Enable / Disable',

http://git-wip-us.apache.org/repos/asf/ambari/blob/e6dcdf63/ambari-web/app/utils/validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/validator.js 
b/ambari-web/app/utils/validator.js
index 5173702..c069724 100644
--- a/ambari-web/app/utils/validator.js
+++ b/ambari-web/app/utils/validator.js
@@ -323,7 +323,7 @@ module.exports = {
    * @returns {boolean}
    */
   isValidAlertName: function(value) {
-    var alertNameRegex = /^[\s0-9a-z_\-%]+$/i;
+    var alertNameRegex = /^[\s0-9a-z_\-%\(\)]+$/i;
     return alertNameRegex.test(value);
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e6dcdf63/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 8565b3d..aada441 100644
--- a/ambari-web/test/utils/validator_test.js
+++ b/ambari-web/test/utils/validator_test.js
@@ -523,4 +523,25 @@ describe('validator', function () {
 
   });
 
+  describe('#isValidAlertName', function () {
+
+    [
+      {v: '', e: false},
+      {v: 'a', e: true},
+      {v: 'a b', e: true},
+      {v: '/', e: false},
+      {v: '/>1', e: false},
+      {v: 'a 1%', e: true},
+      {v: 'a (b)', e: true}
+    ].forEach(function (test) {
+
+      it(test.m || test.v, function () {
+        expect(validator.isValidAlertName(test.v)).to.be.equal(test.e);
+      })
+
+    });
+
+
+  });
+
 });

Reply via email to