aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/libs/handlebars-extensions.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/libs/handlebars-extensions.js')
-rw-r--r--server/sonar-web/src/main/js/libs/handlebars-extensions.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/libs/handlebars-extensions.js b/server/sonar-web/src/main/js/libs/handlebars-extensions.js
index 9ea3c5bc7f1..adac1db2b0a 100644
--- a/server/sonar-web/src/main/js/libs/handlebars-extensions.js
+++ b/server/sonar-web/src/main/js/libs/handlebars-extensions.js
@@ -1,4 +1,6 @@
(function () {
+ var defaultActions = ['comment', 'assign', 'assign_to_me', 'plan', 'set_severity', 'set_tags'];
+
Handlebars.registerHelper('log', function () {
/* eslint no-console: 0 */
var args = Array.prototype.slice.call(arguments, 0, -1);
@@ -354,6 +356,22 @@
return numeral(number).format(format);
});
+ Handlebars.registerHelper('pluginActions', function (actions, options) {
+ var pluginActions = _.difference(actions, defaultActions);
+ return pluginActions.reduce(function (prev, current) {
+ return prev + options.fn(current);
+ }, '');
+ });
+
+ Handlebars.registerHelper('ifHasExtraActions', function (actions, options) {
+ var actionsLeft = _.difference(actions, defaultActions);
+ if (actionsLeft.length > 0) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
+ });
+
Handlebars.registerHelper('withFirst', function (list, options) {
if (list && list.length > 0) {
return options.fn(list[0]);