diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-15 17:12:19 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-15 17:13:31 +0200 |
commit | 3c445bc471c8ca2b11df44015bbe7b8997a61ccc (patch) | |
tree | 7ae7f1dc557c344ce9a0a01e6bb526508360af18 /server/sonar-web | |
parent | cf8127c1b33fd0c066b0ec3ad9c970865fd1ffec (diff) | |
download | sonarqube-3c445bc471c8ca2b11df44015bbe7b8997a61ccc.tar.gz sonarqube-3c445bc471c8ca2b11df44015bbe7b8997a61ccc.zip |
SONAR-6654 When a user flags an issue as "False Positive" or "Won't Fix", encourage him/her to provide a comment
Diffstat (limited to 'server/sonar-web')
7 files changed, 113 insertions, 14 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 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 @@ <div class="issue-comment-form-text"> - <textarea rows="2">{{show raw markdown}}</textarea> + <textarea rows="2" {{#if options.fromTransition}}placeholder="Please tell why?"{{/if}}>{{show raw markdown}}</textarea> </div> <div class="issue-comment-form-footer"> diff --git a/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js b/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js index 52cd3917a2c..ef07d6e717b 100644 --- a/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js @@ -78,6 +78,13 @@ define([ that.enableForm(); that.options.detailView.enableControls(); }); + }, + + serializeData: function () { + var options = _.defaults(this.options.additionalOptions, { fromTransition: false }); + return _.extend(PopupView.prototype.serializeData.apply(this, arguments), { + options: options + }); } }); diff --git a/server/sonar-web/src/test/json/issues-spec/show-fp-new.json b/server/sonar-web/src/test/json/issues-spec/show-fp-new.json new file mode 100644 index 00000000000..68715405a38 --- /dev/null +++ b/server/sonar-web/src/test/json/issues-spec/show-fp-new.json @@ -0,0 +1,69 @@ +{ + "issue": { + "key": "91e89abf-fb8e-4b6a-8d9c-2cf0ee01242e", + "rule": "javascript:S1067", + "severity": "MAJOR", + "component": "backbone:backbone.js", + "componentId": 1073, + "project": "backbone", + "subProject": "backbone", + "line": 12, + "textRange": { + "startLine": 12, + "endLine": 12, + "startOffset": 0, + "endOffset": 70 + }, + "flows": [], + "resolution": "FALSE-POSITIVE", + "status": "RESOLVED", + "message": "Reduce the number of conditional operators (5) used in the expression (maximum allowed 3).", + "author": "yeatesgraeme@gmail.com", + "tags": [ + "brain-overload" + ], + "transitions": [ + "reopen" + ], + "actions": [ + "comment" + ], + "comments": [], + "creationDate": "2015-08-10T14:37:54+0200", + "updateDate": "2015-09-15T17:09:30+0200" + }, + "components": [ + { + "id": 1073, + "key": "backbone:backbone.js", + "uuid": "51097e69-d229-4471-87c9-c5b86e0e48a7", + "enabled": true, + "qualifier": "FIL", + "name": "backbone.js", + "longName": "backbone.js", + "path": "backbone.js", + "projectId": 1071, + "subProjectId": 1071 + }, + { + "id": 1071, + "key": "backbone", + "uuid": "10c394cc-c37c-4cf0-97b9-360165c47270", + "enabled": true, + "qualifier": "TRK", + "name": "backbone", + "longName": "backbone" + } + ], + "rules": [ + { + "key": "javascript:S1067", + "name": "Expressions should not be too complex", + "lang": "js", + "status": "READY", + "langName": "JavaScript" + } + ], + "users": [], + "actionPlans": [] +} diff --git a/server/sonar-web/test/medium/issues.spec.js b/server/sonar-web/test/medium/issues.spec.js index 767ddee9fc2..5b967215d7d 100644 --- a/server/sonar-web/test/medium/issues.spec.js +++ b/server/sonar-web/test/medium/issues.spec.js @@ -243,6 +243,21 @@ define(function (require) { .checkElementCount('[data-property="rules"] .js-facet', 13) .checkElementInclude('[data-property="rules"] .js-facet:nth-child(1)', 'Objects should be compared with'); }); + + bdd.it('should open comment form after FP or WF transition', function () { + return this.remote + .open('#resolved=false') + .mockFromString('/api/l10n/index', '{}') + .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json') + .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json') + .mockFromFile('/api/issues/search', 'issues-spec/search.json') + .mockFromFile('/api/issues/do_transition', 'issues-spec/show-fp-new.json') + .startApp('issues') + .checkElementExist('.issue.selected') + .clickElement('.issue.selected .js-issue-transition') + .clickElement('.js-issue-transition[data-value="falsepositive"]') + .checkElementExist('.js-issue-comment-submit'); + }); }); }); diff --git a/server/sonar-web/test/unit/issue.spec.js b/server/sonar-web/test/unit/issue.spec.js index 96e4bf0a8d9..d8ce9edcf4f 100644 --- a/server/sonar-web/test/unit/issue.spec.js +++ b/server/sonar-web/test/unit/issue.spec.js @@ -114,13 +114,6 @@ define(function (require) { assert.equal(stub.firstCall.args[0].url, '/api/issues/set_severity'); assert.deepEqual(stub.firstCall.args[0].data, { issue: 'issue-key', severity: 'BLOCKER' }); }); - - bdd.it('should do a transition', function () { - new Issue({ key: 'issue-key' }).transition('RESOLVED'); - assert.isTrue(stub.calledOnce); - assert.equal(stub.firstCall.args[0].url, '/api/issues/do_transition'); - assert.deepEqual(stub.firstCall.args[0].data, { issue: 'issue-key', transition: 'RESOLVED' }); - }); }); bdd.describe('#getLinearLocations', function () { |