aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/shared/avatar.jsx
blob: 2f596bf3a0d3c1dbaeb10c7754954a94f3533e6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import React from 'react';

export default React.createClass({
  propTypes: {
    email: React.PropTypes.string,
    size: React.PropTypes.number.isRequired
  },

  render() {
    const shouldShowAvatar = window.SS && window.SS.lf && window.SS.lf.enableGravatar;
    if (!shouldShowAvatar) {
      return null;
    }
    const emailHash = window.md5(this.props.email || '').trim();
    const url = ('' + window.SS.lf.gravatarServerUrl)
            .replace('{EMAIL_MD5}', emailHash)
            .replace('{SIZE}', this.props.size * 2);
    return <img className="rounded" src={url} width={this.props.size} height={this.props.size} alt={this.props.email}/>;
  }
});