From 3c445bc471c8ca2b11df44015bbe7b8997a61ccc Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 15 Sep 2015 17:12:19 +0200 Subject: SONAR-6654 When a user flags an issue as "False Positive" or "Won't Fix", encourage him/her to provide a comment --- .../src/main/js/components/issue/issue-view.js | 22 +++++-- .../src/main/js/components/issue/models/issue.js | 5 +- .../js/components/issue/templates/comment-form.hbs | 2 +- .../js/components/issue/views/comment-form-view.js | 7 +++ .../src/test/json/issues-spec/show-fp-new.json | 69 ++++++++++++++++++++++ server/sonar-web/test/medium/issues.spec.js | 15 +++++ server/sonar-web/test/unit/issue.spec.js | 7 --- 7 files changed, 113 insertions(+), 14 deletions(-) create mode 100644 server/sonar-web/src/test/json/issues-spec/show-fp-new.json (limited to 'server/sonar-web') 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 614a8cb40fc..e5b8bf95d7e 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 @@ -22,12 +22,13 @@ define([ template: Templates.issue, modelEvents: { - 'change': 'render' + 'change': 'render', + 'transition': 'onTransition' }, events: function () { return { - 'click .js-issue-comment': 'comment', + 'click .js-issue-comment': 'onComment', 'click .js-issue-comment-edit': 'editComment', 'click .js-issue-comment-delete': 'deleteComment', 'click .js-issue-transition': 'transition', @@ -93,14 +94,19 @@ define([ } }, - comment: function (e) { + onComment: function (e) { e.stopPropagation(); + this.comment(); + }, + + comment: function (options) { $('body').click(); this.popup = new CommentFormView({ - triggerEl: $(e.currentTarget), + triggerEl: this.$('.js-issue-comment'), bottom: true, issue: this.model, - detailView: this + detailView: this, + additionalOptions: options }); this.popup.render(); }, @@ -222,6 +228,12 @@ define([ this.model.trigger('locations', this.model); }, + onTransition: function (transition) { + if (transition === 'falsepositive' || transition === 'wontfix') { + this.comment({ fromTransition: true }); + } + }, + serializeData: function () { var issueKey = encodeURIComponent(this.model.get('key')); return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { 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 3187af2f864..2e664aa7790 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 @@ -189,11 +189,14 @@ define(function () { * @returns {jqXHR} */ transition: function (transition, options) { + var that = this; var opts = _.extend({ url: this.urlRoot() + '/do_transition', data: { issue: this.id, transition: transition } }, options); - return this._action(opts); + return this._action(opts).done(function () { + that.trigger('transition', transition); + }); }, getLinearLocations: function () { diff --git a/server/sonar-web/src/main/js/components/issue/templates/comment-form.hbs b/server/sonar-web/src/main/js/components/issue/templates/comment-form.hbs index 9bd51396d0b..1ceccfa5bdc 100644 --- a/server/sonar-web/src/main/js/components/issue/templates/comment-form.hbs +++ b/server/sonar-web/src/main/js/components/issue/templates/comment-form.hbs @@ -1,5 +1,5 @@
- +