aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/Author.js
blob: 237a79569fd77c65e867ee22c095cbf648ff9d93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gql from 'graphql-tag';
import Tooltip from '@material-ui/core/Tooltip/Tooltip';
import MAvatar from '@material-ui/core/Avatar';
import React from 'react';

const Author = ({ author, ...props }) => {
  if (!author.email) {
    return <span {...props}>{author.displayName}</span>;
  }

  return (
    <Tooltip title={author.email}>
      <span {...props}>{author.displayName}</span>
    </Tooltip>
  );
};

Author.fragment = gql`
  fragment authored on Authored {
    author {
      name
      email
      displayName
      avatarUrl
    }
  }
`;

export const Avatar = ({ author, ...props }) => {
  if (author.avatarUrl) {
    return <MAvatar src={author.avatarUrl} {...props} />;
  }

  return <MAvatar {...props}>{author.displayName[0]}</MAvatar>;
};

export default Author;