aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-10-09 09:50:40 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-10-09 16:48:24 +0200
commit9dbf8d1d08b839d5bbdf85e77b7ba5982e1cb41d (patch)
tree847be9935c582ad61699b5e15da6ba7d31f2e61f /server
parente2517f4266c4ec005bb21b17a71c94a2dc973148 (diff)
downloadsonarqube-9dbf8d1d08b839d5bbdf85e77b7ba5982e1cb41d.tar.gz
sonarqube-9dbf8d1d08b839d5bbdf85e77b7ba5982e1cb41d.zip
revert SONAR-6742 Stop displaying plugin actions for issues
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/components/issue/issue-view.js26
-rw-r--r--server/sonar-web/src/main/js/components/issue/models/issue.js15
-rw-r--r--server/sonar-web/src/main/js/components/issue/templates/issue-more-actions.hbs9
-rw-r--r--server/sonar-web/src/main/js/components/issue/templates/issue.hbs8
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/more-actions-view.js15
-rw-r--r--server/sonar-web/src/main/js/libs/handlebars-extensions.js18
6 files changed, 83 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/components/issue/issue-view.js b/server/sonar-web/src/main/js/components/issue/issue-view.js
index 5c91f18d23d..12ff93c00ba 100644
--- a/server/sonar-web/src/main/js/components/issue/issue-view.js
+++ b/server/sonar-web/src/main/js/components/issue/issue-view.js
@@ -10,6 +10,7 @@ import AssignFormView from './views/assign-form-view';
import CommentFormView from './views/comment-form-view';
import PlanFormView from './views/plan-form-view';
import SetSeverityFormView from './views/set-severity-form-view';
+import MoreActionsView from './views/more-actions-view';
import TagsFormView from './views/tags-form-view';
import Workspace from 'components/workspace/main';
import './templates';
@@ -34,6 +35,7 @@ export default Marionette.ItemView.extend({
'click .js-issue-assign-to-me': 'assignToMe',
'click .js-issue-plan': 'plan',
'click .js-issue-show-changelog': 'showChangeLog',
+ 'click .js-issue-more': 'showMoreActions',
'click .js-issue-rule': 'showRule',
'click .js-issue-edit-tags': 'editTags',
'click .js-issue-locations': 'showLocations'
@@ -208,6 +210,30 @@ export default Marionette.ItemView.extend({
RealWorkspace.openRule({ key: ruleKey });
},
+ showMoreActions: function (e) {
+ e.stopPropagation();
+ $('body').click();
+ this.popup = new MoreActionsView({
+ triggerEl: $(e.currentTarget),
+ bottomRight: true,
+ model: this.model,
+ detailView: this
+ });
+ this.popup.render();
+ },
+
+ action: function (action) {
+ var that = this;
+ this.disableControls();
+ return this.model.customAction(action)
+ .done(function () {
+ that.updateAfterAction(true);
+ })
+ .fail(function () {
+ that.enableControls();
+ });
+ },
+
editTags: function (e) {
e.stopPropagation();
$('body').click();
diff --git a/server/sonar-web/src/main/js/components/issue/models/issue.js b/server/sonar-web/src/main/js/components/issue/models/issue.js
index c619361c399..5d509e77acb 100644
--- a/server/sonar-web/src/main/js/components/issue/models/issue.js
+++ b/server/sonar-web/src/main/js/components/issue/models/issue.js
@@ -214,6 +214,21 @@ export default Backbone.Model.extend({
});
},
+
+ /**
+ * Do a custom (plugin) action
+ * @param {String} actionKey Action Key
+ * @param {Object|null} options Options for jQuery ajax
+ * @returns {jqXHR}
+ */
+ customAction: function (actionKey, options) {
+ var opts = _.extend({
+ url: this.urlRoot() + '/do_action',
+ data: { issue: this.id, actionKey: actionKey }
+ }, options);
+ return this._action(opts);
+ },
+
getLinearLocations: function () {
var textRange = this.get('textRange');
if (!textRange) {
diff --git a/server/sonar-web/src/main/js/components/issue/templates/issue-more-actions.hbs b/server/sonar-web/src/main/js/components/issue/templates/issue-more-actions.hbs
new file mode 100644
index 00000000000..f4e842242b5
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/issue/templates/issue-more-actions.hbs
@@ -0,0 +1,9 @@
+<ul class="menu">
+ {{#pluginActions actions}}
+ <li>
+ <a class="issue-action js-issue-action" href="#" data-action="{{this}}">{{t "issue.action" this "formlink"}}</a>
+ </li>
+ {{/pluginActions}}
+</ul>
+
+<div class="bubble-popup-arrow"></div>
diff --git a/server/sonar-web/src/main/js/components/issue/templates/issue.hbs b/server/sonar-web/src/main/js/components/issue/templates/issue.hbs
index 61a03ecb248..33ca4c1f18e 100644
--- a/server/sonar-web/src/main/js/components/issue/templates/issue.hbs
+++ b/server/sonar-web/src/main/js/components/issue/templates/issue.hbs
@@ -111,6 +111,14 @@
class="issue-meta-label">{{t 'issue.comment.formlink' }}</span></button>
</li>
{{/inArray}}
+
+ {{#ifHasExtraActions actions}}
+ <li class="issue-meta">
+ <button class="button-link issue-action issue-action-with-options js-issue-more">
+ <span class="issue-meta-label">{{t 'more'}}</span>&nbsp;<i class="icon-dropdown"></i>
+ </button>
+ </li>
+ {{/ifHasExtraActions}}
</ul>
{{#inArray actions "assign_to_me"}}
diff --git a/server/sonar-web/src/main/js/components/issue/views/more-actions-view.js b/server/sonar-web/src/main/js/components/issue/views/more-actions-view.js
index 4fa157c1533..70db7c1b2e4 100644
--- a/server/sonar-web/src/main/js/components/issue/views/more-actions-view.js
+++ b/server/sonar-web/src/main/js/components/issue/views/more-actions-view.js
@@ -1,18 +1,17 @@
import $ from 'jquery';
-import PopupView from 'components/common/popup';
+import ActionOptionsView from 'components/common/action-options-view';
import '../templates';
-export default PopupView.extend({
+export default ActionOptionsView.extend({
template: Templates['issue-more-actions'],
- events: function () {
- return {
- 'click .js-issue-action': 'action'
- };
+ selectOption: function (e) {
+ var action = $(e.currentTarget).data('action');
+ this.submit(action);
+ return ActionOptionsView.prototype.selectOption.apply(this, arguments);
},
- action: function (e) {
- var actionKey = $(e.currentTarget).data('action');
+ submit: function (actionKey) {
return this.options.detailView.action(actionKey);
}
});
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]);