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 UserProfile from './user_profile.jsx';
|
|
|
|
|
import PostInfo from './post_info.jsx';
|
2015-12-04 02:07:47 +01:00
|
|
|
import * as Utils from '../utils/utils.jsx';
|
|
|
|
|
|
|
|
|
|
import Constants from '../utils/constants.jsx';
|
2015-06-14 23:53:32 -08:00
|
|
|
|
2015-09-01 09:23:58 -04:00
|
|
|
export default class PostHeader extends React.Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {};
|
|
|
|
|
}
|
|
|
|
|
render() {
|
2016-02-23 11:09:59 -05:00
|
|
|
const post = this.props.post;
|
|
|
|
|
const user = this.props.user;
|
2015-06-14 23:53:32 -08:00
|
|
|
|
2016-02-23 11:09:59 -05:00
|
|
|
let userProfile = <UserProfile user={user}/>;
|
2015-10-05 08:46:23 -04:00
|
|
|
let botIndicator;
|
|
|
|
|
|
|
|
|
|
if (post.props && post.props.from_webhook) {
|
2015-10-16 09:10:54 -07:00
|
|
|
if (post.props.override_username && global.window.mm_config.EnablePostUsernameOverride === 'true') {
|
2015-10-05 08:46:23 -04:00
|
|
|
userProfile = (
|
|
|
|
|
<UserProfile
|
2016-02-23 11:09:59 -05:00
|
|
|
user={user}
|
2015-10-05 08:46:23 -04:00
|
|
|
overwriteName={post.props.override_username}
|
|
|
|
|
disablePopover={true}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-19 01:11:06 +05:00
|
|
|
botIndicator = <li className='col col__name bot-indicator'>{'BOT'}</li>;
|
2015-12-04 02:07:47 +01:00
|
|
|
} else if (Utils.isSystemMessage(post)) {
|
|
|
|
|
userProfile = (
|
|
|
|
|
<UserProfile
|
2016-02-23 11:09:59 -05:00
|
|
|
user={{}}
|
2015-12-07 18:37:21 +01:00
|
|
|
overwriteName={Constants.SYSTEM_MESSAGE_PROFILE_NAME}
|
2015-12-04 02:07:47 +01:00
|
|
|
overwriteImage={Constants.SYSTEM_MESSAGE_PROFILE_IMAGE}
|
|
|
|
|
disablePopover={true}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2015-10-02 11:08:00 -04:00
|
|
|
}
|
|
|
|
|
|
2015-06-14 23:53:32 -08:00
|
|
|
return (
|
2015-11-19 01:11:06 +05:00
|
|
|
<ul className='post__header'>
|
|
|
|
|
<li className='col col__name'>{userProfile}</li>
|
2015-10-05 08:46:23 -04:00
|
|
|
{botIndicator}
|
2015-11-19 01:11:06 +05:00
|
|
|
<li className='col'>
|
2015-09-01 09:23:58 -04:00
|
|
|
<PostInfo
|
|
|
|
|
post={post}
|
|
|
|
|
commentCount={this.props.commentCount}
|
|
|
|
|
handleCommentClick={this.props.handleCommentClick}
|
|
|
|
|
allowReply='true'
|
|
|
|
|
isLastComment={this.props.isLastComment}
|
2016-02-01 14:30:16 -08:00
|
|
|
sameUser={this.props.sameUser}
|
2015-09-01 09:23:58 -04:00
|
|
|
/>
|
2015-06-14 23:53:32 -08:00
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
);
|
|
|
|
|
}
|
2015-09-01 09:23:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PostHeader.defaultProps = {
|
|
|
|
|
post: null,
|
|
|
|
|
commentCount: 0,
|
2016-02-01 14:30:16 -08:00
|
|
|
isLastComment: false,
|
|
|
|
|
sameUser: false
|
2015-09-01 09:23:58 -04:00
|
|
|
};
|
|
|
|
|
PostHeader.propTypes = {
|
|
|
|
|
post: React.PropTypes.object,
|
2016-02-23 11:09:59 -05:00
|
|
|
user: React.PropTypes.object,
|
2015-09-01 09:23:58 -04:00
|
|
|
commentCount: React.PropTypes.number,
|
|
|
|
|
isLastComment: React.PropTypes.bool,
|
2016-02-01 14:30:16 -08:00
|
|
|
handleCommentClick: React.PropTypes.func,
|
|
|
|
|
sameUser: React.PropTypes.bool
|
2015-09-01 09:23:58 -04:00
|
|
|
};
|