forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile_picture.jsx
80 lines (74 loc) · 2.58 KB
/
profile_picture.jsx
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import PropTypes from 'prop-types';
import React from 'react';
import {OverlayTrigger} from 'react-bootstrap';
import ProfilePopover from 'components/profile_popover';
import StatusIcon from 'components/status_icon';
export default class ProfilePicture extends React.PureComponent {
static defaultProps = {
width: '36',
height: '36',
isRHS: false,
hasMention: false,
};
static propTypes = {
src: PropTypes.string.isRequired,
status: PropTypes.string,
width: PropTypes.string,
height: PropTypes.string,
userId: PropTypes.string,
username: PropTypes.string,
isBusy: PropTypes.bool,
isRHS: PropTypes.bool,
hasMention: PropTypes.bool,
};
hideProfilePopover = () => {
this.refs.overlay.hide();
}
render() {
if (this.props.userId) {
return (
<OverlayTrigger
ref='overlay'
trigger='click'
placement='right'
rootClose={true}
overlay={
<ProfilePopover
userId={this.props.userId}
src={this.props.src}
isBusy={this.props.isBusy}
hide={this.hideProfilePopover}
isRHS={this.props.isRHS}
hasMention={this.props.hasMention}
/>
}
>
<span className='status-wrapper'>
<img
className='more-modal__image rounded'
alt={`${this.props.username || 'user'} profile image`}
width={this.props.width}
height={this.props.width}
src={this.props.src}
/>
<StatusIcon status={this.props.status}/>
</span>
</OverlayTrigger>
);
}
return (
<span className='status-wrapper'>
<img
className='more-modal__image rounded'
alt=''
width={this.props.width}
height={this.props.width}
src={this.props.src}
/>
<StatusIcon status={this.props.status}/>
</span>
);
}
}