]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8969 use avatar field
authorStas Vilchik <vilchiks@gmail.com>
Thu, 23 Mar 2017 16:56:23 +0000 (17:56 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 24 Mar 2017 07:43:19 +0000 (08:43 +0100)
server/sonar-web/src/main/js/apps/issues/templates/issues-issue-filter-form.hbs
server/sonar-web/src/main/js/components/issue/templates/issue-changelog.hbs
server/sonar-web/src/main/js/components/issue/templates/issue.hbs
server/sonar-web/src/main/js/helpers/handlebars/avatarHelperNew.js [new file with mode: 0644]

index 58764e595435be04fb835cecc9d17038378c6a17..f18f6845d3a6da538ac8f4716dd8366f191f5878 100644 (file)
@@ -37,7 +37,7 @@
     {{#if assignee}}
       <a href="#" class="issue-action-option" data-property="assignees" data-value="{{assignee}}">
         {{t "assigned_to"}}
-        {{#ifShowAvatars}}<span class="spacer-left">{{avatarHelper assigneeEmail 16}}</span>{{/ifShowAvatars}}
+        {{#ifShowAvatars}}<span class="spacer-left">{{avatarHelperNew assigneeAvatar 16}}</span>{{/ifShowAvatars}}
         {{assigneeName}}
       </a>
     {{else}}
index e94ba28c14a9a308c31a35c35a6aada7afd23e61..7ba2e7c2937a88a8f2baca68e9bf3da5e39ae679 100644 (file)
@@ -19,7 +19,7 @@
         <td class="thin text-left text-top" nowrap>{{dt creationDate}}</td>
         <td class="thin text-left text-top" nowrap>
           {{#if userName}}
-            {{#ifShowAvatars}}{{avatarHelper email 16}}{{/ifShowAvatars}}
+            {{#ifShowAvatars}}{{avatarHelperNew avatar 16}}{{/ifShowAvatars}}
           {{/if}}
           {{userName}}
         </td>
index a828ecf5e3eb049e9be845bbbfc0d125a412aa9c..1af970cc4d0a2a7c4abec0682a8d9e667a43aae7 100644 (file)
@@ -80,7 +80,7 @@
               <button class="button-link issue-action issue-action-with-options js-issue-assign">
                 {{#if assignee}}
                   {{#ifShowAvatars}}
-                    <span class="text-top">{{avatarHelper assigneeEmail 16}}</span>
+                    <span class="text-top">{{avatarHelperNew assigneeAvatar 16}}</span>
                   {{/ifShowAvatars}}
                 {{/if}}
                 <span class="issue-meta-label">{{#if assignee}}{{assigneeName}}{{else}}{{t 'unassigned'}}{{/if}}</span>&nbsp;<i
@@ -89,7 +89,7 @@
             {{else}}
               {{#if assignee}}
                 {{#ifShowAvatars}}
-                  <span class="text-top">{{avatarHelper assigneeEmail 16}}</span>
+                  <span class="text-top">{{avatarHelperNew assigneeAvatar 16}}</span>
                 {{/ifShowAvatars}}
               {{/if}}
               <span class="issue-meta-label">{{#if assignee}}{{assigneeName}}{{else}}{{t 'unassigned'}}{{/if}}</span>
       {{#each comments}}
         <div class="issue-comment" data-comment-key="{{key}}">
           <div class="issue-comment-author" title="{{authorName}}">
-            {{#ifShowAvatars}}{{avatarHelper authorEmail 16}}{{else}}
+            {{#ifShowAvatars}}{{avatarHelperNew authorAvatar 16}}{{else}}
               <i class="icon-comment icon-half-transparent"></i>{{/ifShowAvatars}}&nbsp;{{authorName}}
           </div>
           <div class="issue-comment-text markdown">{{{show html htmlText}}}</div>
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/avatarHelperNew.js b/server/sonar-web/src/main/js/helpers/handlebars/avatarHelperNew.js
new file mode 100644 (file)
index 0000000..6732b09
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+import Handlebars from 'handlebars/runtime';
+
+function gravatarServer () {
+  const getStore = require('../../app/utils/getStore').default;
+  const { getSettingValue } = require('../../store/rootReducer');
+
+  const store = getStore();
+  return (getSettingValue(store.getState(), 'sonar.lf.gravatarServerUrl') || {}).value;
+}
+
+module.exports = function (emailHash, size) {
+  // double the size for high pixel density screens
+  const url = gravatarServer().replace('{EMAIL_MD5}', emailHash).replace('{SIZE}', size * 2);
+  return new Handlebars.default.SafeString(
+    `<img class="rounded" src="${url}" width="${size}" height="${size}" alt="">`
+  );
+};