ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [62/67] [abbrv] ambari git commit: AMBARI-20607. Provide helper for adding data-qa attributes (akovalenko)
Date Wed, 29 Mar 2017 13:58:10 GMT
AMBARI-20607. Provide helper for adding data-qa attributes (akovalenko)


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

Branch: refs/heads/branch-dev-logsearch
Commit: ea3aa22aec0ff875d2127da86701e8caccd78be0
Parents: 742fdff
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Wed Mar 29 00:09:16 2017 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Wed Mar 29 00:09:16 2017 +0300

----------------------------------------------------------------------
 ambari-web/app/utils/ember_reopen.js |  4 +++-
 ambari-web/app/utils/helper.js       | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ea3aa22a/ambari-web/app/utils/ember_reopen.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ember_reopen.js b/ambari-web/app/utils/ember_reopen.js
index ff55b30..5f7c61b 100644
--- a/ambari-web/app/utils/ember_reopen.js
+++ b/ambari-web/app/utils/ember_reopen.js
@@ -225,7 +225,9 @@ Em.View.reopen({
     } else {
       console.debug('Calling setProperties on destroyed view');
     }
-  }
+  },
+
+  attributeBindings: ['data-qa']
 });
 
 Ember._HandlebarsBoundView.reopen({

http://git-wip-us.apache.org/repos/asf/ambari/blob/ea3aa22a/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index f6f2532..6c706b8 100644
--- a/ambari-web/app/utils/helper.js
+++ b/ambari-web/app/utils/helper.js
@@ -363,6 +363,26 @@ Em.Handlebars.registerHelper('highlight', function (property, words,
fn) {
 /**
  * Usage:
  *
+ * <div {{QAAttr "someText"}}></div>
+ * <div {{QAAttr "{someProperty}"}}></div>
+ * <div {{QAAttr "someText-and-{someProperty}"}}></div>
+ *
+ */
+Em.Handlebars.registerHelper('QAAttr', function(text, data) {
+  var self = this;
+  var textToReplace = text.match(/\{(.*?)\}/g);
+  if (textToReplace) {
+    textToReplace.forEach(function (t) {
+      var value = Em.Handlebars.getPath(self, t.slice(1, t.length-1), data);
+      text = text.replace(t, value);
+    });
+  }
+  return new Em.Handlebars.SafeString('data-qa="' + text + '"');
+});
+
+/**
+ * Usage:
+ *
  * <pre>
  *   {{#isAuthorized "SERVICE.TOGGLE_ALERTS"}}
  *     {{! some truly code }}


Mime
View raw message