2015-10-08 12:27:09 -04:00
|
|
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
2015-06-14 23:53:32 -08:00
|
|
|
// See License.txt for license information.
|
2015-11-19 21:12:56 -05:00
|
|
|
import UserStore from '../stores/user_store.jsx';
|
|
|
|
|
import * as Utils from '../utils/utils.jsx';
|
2015-06-14 23:53:32 -08:00
|
|
|
|
2015-08-31 09:35:31 -07:00
|
|
|
export default class Mention extends React.Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
this.handleClick = this.handleClick.bind(this);
|
|
|
|
|
|
|
|
|
|
this.state = null;
|
|
|
|
|
}
|
|
|
|
|
handleClick() {
|
2015-06-14 23:53:32 -08:00
|
|
|
this.props.handleClick(this.props.username);
|
2015-08-31 09:35:31 -07:00
|
|
|
}
|
|
|
|
|
render() {
|
2015-06-30 08:42:08 -04:00
|
|
|
var icon;
|
2015-07-13 09:22:42 -07:00
|
|
|
var timestamp = UserStore.getCurrentUser().update_at;
|
2015-08-31 09:35:31 -07:00
|
|
|
if (this.props.id === 'allmention' || this.props.id === 'channelmention') {
|
|
|
|
|
icon = <span><i className='mention-img fa fa-users fa-2x'></i></span>;
|
2015-10-05 09:58:42 -04:00
|
|
|
} else if (this.props.id == null) {
|
|
|
|
|
icon = <span><i className='mention-img fa fa-users fa-2x'></i></span>;
|
|
|
|
|
} else {
|
2015-09-03 10:49:36 -04:00
|
|
|
icon = (
|
|
|
|
|
<span>
|
|
|
|
|
<img
|
|
|
|
|
className='mention-img'
|
2015-10-20 14:49:42 -07:00
|
|
|
src={'/api/v1/users/' + this.props.id + '/image?time=' + timestamp + '&' + Utils.getSessionIndex()}
|
2015-09-03 10:49:36 -04:00
|
|
|
/>
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2015-06-30 08:42:08 -04:00
|
|
|
}
|
2015-06-14 23:53:32 -08:00
|
|
|
return (
|
2015-08-31 09:35:31 -07:00
|
|
|
<div
|
|
|
|
|
className={'mentions-name ' + this.props.isFocused}
|
|
|
|
|
id={this.props.id + '_mentions'}
|
|
|
|
|
onClick={this.handleClick}
|
|
|
|
|
onMouseEnter={this.props.handleMouseEnter}
|
|
|
|
|
>
|
|
|
|
|
<div className='pull-left'>{icon}</div>
|
|
|
|
|
<div className='pull-left mention-align'><span>@{this.props.username}</span><span className='mention-fullname'>{this.props.secondary_text}</span></div>
|
2015-06-14 23:53:32 -08:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2015-08-31 09:35:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Mention.defaultProps = {
|
|
|
|
|
username: '',
|
|
|
|
|
id: '',
|
|
|
|
|
isFocused: '',
|
|
|
|
|
secondary_text: ''
|
|
|
|
|
};
|
|
|
|
|
Mention.propTypes = {
|
|
|
|
|
handleClick: React.PropTypes.func.isRequired,
|
|
|
|
|
handleMouseEnter: React.PropTypes.func.isRequired,
|
|
|
|
|
username: React.PropTypes.string,
|
|
|
|
|
id: React.PropTypes.string,
|
|
|
|
|
isFocused: React.PropTypes.string,
|
|
|
|
|
secondary_text: React.PropTypes.string
|
|
|
|
|
};
|