From 681ee7b5f288c84150856bcd9a35f0e7ced28b0d Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 22 May 2015 15:35:28 +0200 Subject: [PATCH] SONAR-6579 add support of gravatars --- server/sonar-web/Gruntfile.coffee | 1 + .../coffee/apps/issues/models/issues.coffee | 21 +- .../issue/collections/issues.coffee | 5 + .../components/issue/templates/issue.hbs | 17 +- .../main/js/apps/nav/global-navbar-view.js | 1 + .../apps/nav/templates/nav-global-navbar.hbs | 2 +- .../apps/users/templates/users-list-item.hbs | 6 + .../common/handlebars-extensions.js | 15 + .../source-viewer/templates/source-viewer.hbs | 6 +- .../sonar-web/src/main/js/libs/application.js | 14 + .../src/main/js/libs/third-party/md5.js | 274 ++++++++++++++++++ .../src/main/less/components/source.less | 7 - .../WEB-INF/app/views/layouts/_head.html.erb | 14 +- .../src/test/views/layouts/main.jade | 11 + .../core/config/CorePropertyDefinitions.java | 15 + 15 files changed, 373 insertions(+), 36 deletions(-) create mode 100644 server/sonar-web/src/main/js/libs/third-party/md5.js diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee index 82a5708b8f9..3f33fd9dc95 100644 --- a/server/sonar-web/Gruntfile.coffee +++ b/server/sonar-web/Gruntfile.coffee @@ -66,6 +66,7 @@ module.exports = (grunt) -> '<%= BUILD_PATH %>/js/libs/third-party/numeral-languages.js' '<%= BUILD_PATH %>/js/libs/third-party/bootstrap/tooltip.js' '<%= BUILD_PATH %>/js/libs/third-party/bootstrap/dropdown.js' + '<%= BUILD_PATH %>/js/libs/third-party/md5.js' '<%= BUILD_PATH %>/js/libs/select2-jquery-ui-fix.js' '<%= BUILD_PATH %>/js/libs/widgets/base.js' diff --git a/server/sonar-web/src/main/coffee/apps/issues/models/issues.coffee b/server/sonar-web/src/main/coffee/apps/issues/models/issues.coffee index 08926040335..d98b2632120 100644 --- a/server/sonar-web/src/main/coffee/apps/issues/models/issues.coffee +++ b/server/sonar-web/src/main/coffee/apps/issues/models/issues.coffee @@ -43,6 +43,7 @@ define [ project = find r.projects, issue.project subProject = find r.components, issue.subProject rule = find r.rules, issue.rule + assignee = find r.users, issue.assignee, 'login' _.extend issue, index: index @@ -67,25 +68,9 @@ define [ _.extend issue, ruleName: rule.name - if _.isArray(issue.sources) && issue.sources.length > 0 - source = '' - issue.sources.forEach (line) -> - source = line[1] if line[0] == issue.line - _.extend issue, source: source - - - if _.isArray(issue.scm) && issue.scm.length > 0 - scmAuthor = '' - scmDate = '' - - issue.scm.forEach (line) -> - if line[0] == issue.line - scmAuthor = line[1] - scmDate = line[2] - + if assignee _.extend issue, - scmAuthor: scmAuthor - scmDate: scmDate + assigneeEmail: assignee.email issue diff --git a/server/sonar-web/src/main/coffee/components/issue/collections/issues.coffee b/server/sonar-web/src/main/coffee/components/issue/collections/issues.coffee index ddce4332d2e..208a06ffb3b 100644 --- a/server/sonar-web/src/main/coffee/components/issue/collections/issues.coffee +++ b/server/sonar-web/src/main/coffee/components/issue/collections/issues.coffee @@ -47,6 +47,7 @@ define [ component = find r.components, issue.component project = find r.projects, issue.project rule = find r.rules, issue.rule + assignee = find r.users, issue.assignee, 'login' if component _.extend issue, @@ -62,4 +63,8 @@ define [ _.extend issue, ruleName: rule.name + if assignee + _.extend issue, + assigneeEmail: assignee.email + issue diff --git a/server/sonar-web/src/main/coffee/components/issue/templates/issue.hbs b/server/sonar-web/src/main/coffee/components/issue/templates/issue.hbs index dc47a49ddb9..b27f6b53c81 100644 --- a/server/sonar-web/src/main/coffee/components/issue/templates/issue.hbs +++ b/server/sonar-web/src/main/coffee/components/issue/templates/issue.hbs @@ -56,13 +56,20 @@
{{#inArray actions "assign"}} - {{#if assignee}}{{default assigneeName assignee}}{{else}}{{t 'unassigned'}}{{/if}}  + {{#if assignee}} + {{#ifShowAvatars}} + {{avatarHelper assigneeEmail 16}} + {{/ifShowAvatars}} + {{/if}} + {{#if assignee}}{{default assigneeName assignee}}{{else}}{{t 'unassigned'}}{{/if}}  {{else}} - {{#if assignee}}{{default assigneeName assignee}}{{else}}{{t 'unassigned'}}{{/if}} + {{#if assignee}} + {{#ifShowAvatars}} + {{avatarHelper assigneeEmail 16}} + {{/ifShowAvatars}} + {{/if}} + {{#if assignee}}{{default assigneeName assignee}}{{else}}{{t 'unassigned'}}{{/if}} {{/inArray}}
diff --git a/server/sonar-web/src/main/js/apps/nav/global-navbar-view.js b/server/sonar-web/src/main/js/apps/nav/global-navbar-view.js index 9ee43d9fdfe..5a0915e7b20 100644 --- a/server/sonar-web/src/main/js/apps/nav/global-navbar-view.js +++ b/server/sonar-web/src/main/js/apps/nav/global-navbar-view.js @@ -85,6 +85,7 @@ define([ return _.extend(Marionette.Layout.prototype.serializeData.apply(this, arguments), { user: window.SS.user, userName: window.SS.userName, + userEmail: window.SS.userEmail, isUserAdmin: window.SS.isUserAdmin, canManageGlobalDashboards: !!window.SS.user, diff --git a/server/sonar-web/src/main/js/apps/nav/templates/nav-global-navbar.hbs b/server/sonar-web/src/main/js/apps/nav/templates/nav-global-navbar.hbs index fcaf9cc2672..11284eee4a9 100644 --- a/server/sonar-web/src/main/js/apps/nav/templates/nav-global-navbar.hbs +++ b/server/sonar-web/src/main/js/apps/nav/templates/nav-global-navbar.hbs @@ -71,7 +71,7 @@ {{#if user}}