From 2b4920d26b7a72f47a4c44689f71fa77621a6260 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 19 Aug 2015 11:13:04 +0200 Subject: fix displaying of issue comments --- server/sonar-web/src/main/js/apps/issues/models/issues.js | 15 +++++++++++++++ .../src/main/js/components/issue/collections/issues.js | 15 +++++++++++++++ .../src/main/js/components/issue/models/issue.js | 15 +++++++++++++++ .../src/main/js/components/issue/templates/issue.hbs | 6 +++--- 4 files changed, 48 insertions(+), 3 deletions(-) (limited to 'server/sonar-web') diff --git a/server/sonar-web/src/main/js/apps/issues/models/issues.js b/server/sonar-web/src/main/js/apps/issues/models/issues.js index cc617bd6eca..aca2e2ac2bf 100644 --- a/server/sonar-web/src/main/js/apps/issues/models/issues.js +++ b/server/sonar-web/src/main/js/apps/issues/models/issues.js @@ -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; }); diff --git a/server/sonar-web/src/main/js/components/issue/collections/issues.js b/server/sonar-web/src/main/js/components/issue/collections/issues.js index e3cdca48a9e..f40f9a30246 100644 --- a/server/sonar-web/src/main/js/components/issue/collections/issues.js +++ b/server/sonar-web/src/main/js/components/issue/collections/issues.js @@ -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; }); 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 c29abed0973..62f74ceb507 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 @@ -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 = []; 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 7b12f2db96e..61a03ecb248 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 @@ -142,9 +142,9 @@
{{#each comments}}
-
- {{#ifShowAvatars}}{{avatarHelper email 16}}{{else}} - {{/ifShowAvatars}} {{userName}} +
+ {{#ifShowAvatars}}{{avatarHelper authorEmail 16}}{{else}} + {{/ifShowAvatars}} {{authorName}}
{{{show html htmlText}}}
({{fromNow createdAt}})
-- cgit v1.2.3