]> source.dussan.org Git - sonarqube.git/commitdiff
fix displaying of issue comments
authorStas Vilchik <vilchiks@gmail.com>
Wed, 19 Aug 2015 09:13:04 +0000 (11:13 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Wed, 19 Aug 2015 09:22:30 +0000 (11:22 +0200)
server/sonar-web/src/main/js/apps/issues/models/issues.js
server/sonar-web/src/main/js/components/issue/collections/issues.js
server/sonar-web/src/main/js/components/issue/models/issue.js
server/sonar-web/src/main/js/components/issue/templates/issue.hbs

index cc617bd6eca3277358738f30bee33f22b068407d..aca2e2ac2bfd5cc57c4800bc160fac525611b137 100644 (file)
@@ -25,6 +25,20 @@ define([
       return issue;
     },
 
+    _injectCommentsRelational: function (issue, users) {
+      if (issue.comments) {
+        var that = this;
+        var newComments = issue.comments.map(function (comment) {
+          var newComment = _.extend({}, comment, { author: comment.login });
+          delete newComment.login;
+          newComment = that._injectRelational(newComment, users, 'author', 'login');
+          return newComment;
+        });
+        issue = _.extend({}, issue, { comments: newComments });
+      }
+      return issue;
+    },
+
     _prepareClosed: function (issue) {
       if (issue.status === 'CLOSED') {
         issue.secondaryLocations = [];
@@ -45,6 +59,7 @@ define([
         issue = that._injectRelational(issue, r.users, 'assignee', 'login');
         issue = that._injectRelational(issue, r.users, 'reporter', 'login');
         issue = that._injectRelational(issue, r.actionPlans, 'actionPlan', 'key');
+        issue = that._injectCommentsRelational(issue, r.users);
         issue = that._prepareClosed(issue);
         return issue;
       });
index e3cdca48a9e0ae1dff178df3f9e56ec195ee9076..f40f9a302465b8436b1fd2fb4fe1bd76b3d1082f 100644 (file)
@@ -25,6 +25,20 @@ define([
       return issue;
     },
 
+    _injectCommentsRelational: function (issue, users) {
+      if (issue.comments) {
+        var that = this;
+        var newComments = issue.comments.map(function (comment) {
+          var newComment = _.extend({}, comment, { author: comment.login });
+          delete newComment.login;
+          newComment = that._injectRelational(newComment, users, 'author', 'login');
+          return newComment;
+        });
+        issue = _.extend({}, issue, { comments: newComments });
+      }
+      return issue;
+    },
+
     _prepareClosed: function (issue) {
       if (issue.status === 'CLOSED') {
         issue.secondaryLocations = [];
@@ -52,6 +66,7 @@ define([
         issue = that._injectRelational(issue, r.users, 'assignee', 'login');
         issue = that._injectRelational(issue, r.users, 'reporter', 'login');
         issue = that._injectRelational(issue, r.actionPlans, 'actionPlan', 'key');
+        issue = that._injectCommentsRelational(issue, r.users);
         issue = that._prepareClosed(issue);
         return issue;
       });
index c29abed09734c79a5fa43f2dd1a5ad65f04f40c8..62f74ceb507ba41d1ab9f5539e99af850ce34919 100644 (file)
@@ -28,6 +28,7 @@ define(function () {
         issue = this._injectRelational(issue, r.users, 'assignee', 'login');
         issue = this._injectRelational(issue, r.users, 'reporter', 'login');
         issue = this._injectRelational(issue, r.actionPlans, 'actionPlan', 'key');
+        issue = this._injectCommentsRelational(issue, r.users);
         issue = this._prepareClosed(issue);
         return issue;
       } else {
@@ -51,6 +52,20 @@ define(function () {
       return issue;
     },
 
+    _injectCommentsRelational: function (issue, users) {
+      if (issue.comments) {
+        var that = this;
+        var newComments = issue.comments.map(function (comment) {
+          var newComment = _.extend({}, comment, { author: comment.login });
+          delete newComment.login;
+          newComment = that._injectRelational(newComment, users, 'author', 'login');
+          return newComment;
+        });
+        issue = _.extend({}, issue, { comments: newComments });
+      }
+      return issue;
+    },
+
     _prepareClosed: function (issue) {
       if (issue.status === 'CLOSED') {
         issue.secondaryLocations = [];
index 7b12f2db96ebc35cd897441d20b1e0d30a5761b3..61a03ecb248a057c314f001f640be0371110382c 100644 (file)
     <div class="issue-comments">
       {{#each comments}}
         <div class="issue-comment" data-comment-key="{{key}}">
-          <div class="issue-comment-author" title="{{userName}}">
-            {{#ifShowAvatars}}{{avatarHelper email 16}}{{else}}
-              <i class="icon-comment icon-half-transparent"></i>{{/ifShowAvatars}}&nbsp;{{userName}}
+          <div class="issue-comment-author" title="{{authorName}}">
+            {{#ifShowAvatars}}{{avatarHelper authorEmail 16}}{{else}}
+              <i class="icon-comment icon-half-transparent"></i>{{/ifShowAvatars}}&nbsp;{{authorName}}
           </div>
           <div class="issue-comment-text markdown">{{{show html htmlText}}}</div>
           <div class="issue-comment-age">({{fromNow createdAt}})</div>