]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10692 Don't break the issues page if a user is missing
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 22 May 2018 12:31:19 +0000 (14:31 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 23 May 2018 06:47:36 +0000 (08:47 +0200)
server/sonar-web/src/main/js/components/issue/components/IssueAssign.js
server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js
server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.js
server/sonar-web/src/main/js/components/ui/Avatar.js
server/sonar-web/src/main/js/components/ui/__tests__/Avatar-test.js
server/sonar-web/src/main/js/components/ui/__tests__/__snapshots__/Avatar-test.js.snap

index ba6e67dda763a8583e25a6fca47f86131e73f382..3f9ed2a47df41a3b9b089c3fe3661f6305bb1d58 100644 (file)
@@ -52,13 +52,13 @@ export default class IssueAssign extends React.PureComponent {
             <Avatar
               className="little-spacer-right"
               hash={issue.assigneeAvatar}
-              name={issue.assigneeName}
+              name={issue.assigneeName || issue.assignee}
               size={16}
             />
           </span>
         )}
         <span className="issue-meta-label">
-          {issue.assignee ? issue.assigneeName : translate('unassigned')}
+          {issue.assignee ? issue.assigneeName || issue.assignee : translate('unassigned')}
         </span>
       </span>
     );
index f6c7304428223772d92a7361ea46a338f7cabb47..462f89f30c3909d2b57c846e3596f5857dad28c1 100644 (file)
@@ -79,16 +79,17 @@ export default class IssueCommentLine extends React.PureComponent {
 
   render() {
     const { comment } = this.props;
+    const authorName = comment.authorName || comment.author;
     return (
       <div className="issue-comment">
-        <div className="issue-comment-author" title={comment.authorName}>
+        <div className="issue-comment-author" title={authorName}>
           <Avatar
             className="little-spacer-right"
             hash={comment.authorAvatar}
-            name={comment.authorName}
+            name={authorName}
             size={16}
           />
-          {comment.authorName}
+          {authorName}
         </div>
         <div
           className="issue-comment-text markdown"
index fa66812411b1b45bfa921a81a61f9eb65c092696..14f7465eb9c243e22ed71958e5e46d5ed8fc8c59 100644 (file)
@@ -104,10 +104,10 @@ export default class SimilarIssuesPopup extends React.PureComponent {
                 <Avatar
                   className="little-spacer-left little-spacer-right"
                   hash={issue.assigneeAvatar}
-                  name={issue.assigneeName}
+                  name={issue.assigneeName || issue.assignee}
                   size={16}
                 />
-                {issue.assigneeName}
+                {issue.assigneeName || issue.assignee}
               </span>
             ) : (
               translate('unassigned')
index 448fb782f4bf985d14ea0b754350764445035dd2..62e6b1b68d9a6c0d6b82a443a565a69794b88b3e 100644 (file)
@@ -52,7 +52,7 @@ class Avatar extends React.PureComponent {
     gravatarServerUrl: PropTypes.string.isRequired,
     email: PropTypes.string,
     hash: PropTypes.string,
-    name: PropTypes.string.isRequired,
+    name: PropTypes.string,
     size: PropTypes.number.isRequired,
     className: PropTypes.string
   };
@@ -91,6 +91,9 @@ class Avatar extends React.PureComponent {
 
   render() {
     if (!this.props.enableGravatar) {
+      if (!this.props.name) {
+        return null;
+      }
       return this.renderFallback();
     }
 
index 044e07240b1684d1861c1d4ba28d19d388f08a30..4b0aba8018fbbcf5cce6f84deea3314a95be6c07 100644 (file)
@@ -55,3 +55,10 @@ it('falls back to dummy avatar', () => {
   );
   expect(avatar).toMatchSnapshot();
 });
+
+it('do not fail when name is missing', () => {
+  const avatar = shallow(
+    <Avatar enableGravatar={false} gravatarServerUrl="" name={undefined} size={30} />
+  );
+  expect(avatar).toMatchSnapshot();
+});
index d51b5ecabcb23ebefb8d7eca4f3419f95571786e..6ea16cecc3fe50c6632ac2fe9653352398e27f95 100644 (file)
@@ -1,5 +1,7 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
+exports[`do not fail when name is missing 1`] = `null`;
+
 exports[`falls back to dummy avatar 1`] = `
 <div
   className="rounded"