]> 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:23:43 +0000 (14:23 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 24 May 2018 18:20:47 +0000 (20:20 +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.tsx
server/sonar-web/src/main/js/components/ui/__tests__/Avatar-test.tsx

index 783fdec65b03e6d409f1f0ec13e5d6c1b86b4544..ffb8dd35c179928d7fa413f65e75afb2604b4495 100644 (file)
@@ -58,13 +58,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 3a0910f65525710971d4fdf422228e4db49b4c6f..cce84863a06eb336f17756007b71ffc0e138aa4b 100644 (file)
@@ -89,10 +89,10 @@ export default class IssueCommentLine extends React.PureComponent {
           <Avatar
             className="little-spacer-right"
             hash={comment.authorAvatar}
-            name={comment.authorName}
+            name={comment.authorName || comment.author}
             size={16}
           />
-          {comment.authorName}
+          {comment.authorName || comment.author}
         </div>
         <div
           className="issue-comment-text markdown"
index 77273cd9f39f49ad46b1769841ace53dd79f879e..e1b7315c2662f5b1f90c2d8468395a1a4110e9de 100644 (file)
@@ -100,10 +100,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 0c87c36625170d70075601c249dc9cb9005d39a8..7657c13419c79e08f1bd7707f755786214aa624f 100644 (file)
@@ -28,12 +28,15 @@ interface Props {
   enableGravatar: boolean;
   gravatarServerUrl: string;
   hash?: string;
-  name: string;
+  name?: string;
   size: number;
 }
 
 function Avatar(props: Props) {
   if (!props.enableGravatar || !props.hash) {
+    if (!props.name) {
+      return null;
+    }
     return <GenericAvatar className={props.className} name={props.name} size={props.size} />;
   }
 
@@ -43,11 +46,11 @@ function Avatar(props: Props) {
 
   return (
     <img
+      alt={props.name}
       className={classNames(props.className, 'rounded')}
+      height={props.size}
       src={url}
       width={props.size}
-      height={props.size}
-      alt={props.name}
     />
   );
 }
index ad6d7c5bd3dae6bcb74b4763c73d78ddac2617a2..295f89e215a06bb0132895f5d07c7af9d2250777 100644 (file)
@@ -42,3 +42,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.getElement()).toBeNull();
+});