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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import UserProfile from 'components/user_profile.jsx';
import PostInfo from './post_info.jsx';
import {FormattedMessage} from 'react-intl';
import * as PostUtils from 'utils/post_utils.jsx';
import Constants from 'utils/constants.jsx';
import PropTypes from 'prop-types';
import React from 'react';
export default class PostHeader extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
const post = this.props.post;
const isSystemMessage = PostUtils.isSystemMessage(post);
let userProfile = (
<UserProfile
user={this.props.user}
displayNameType={this.props.displayNameType}
status={this.props.status}
isBusy={this.props.isBusy}
/>
);
let botIndicator;
let colon;
if (post.props && post.props.from_webhook) {
if (post.props.override_username && global.window.mm_config.EnablePostUsernameOverride === 'true') {
userProfile = (
<UserProfile
user={this.props.user}
overwriteName={post.props.override_username}
disablePopover={true}
/>
);
} else {
userProfile = (
<UserProfile
user={this.props.user}
displayNameType={this.props.displayNameType}
disablePopover={true}
/>
);
}
botIndicator = <div className='bot-indicator'>{Constants.BOT_NAME}</div>;
} else if (isSystemMessage) {
userProfile = (
<UserProfile
user={{}}
overwriteName={
<FormattedMessage
id='post_info.system'
defaultMessage='System'
/>
}
overwriteImage={Constants.SYSTEM_MESSAGE_PROFILE_IMAGE}
disablePopover={true}
/>
);
}
if (this.props.compactDisplay) {
colon = (<strong className='colon'>{':'}</strong>);
}
return (
<div className='post__header'>
<div className='col col__name'>{userProfile}{colon}</div>
{botIndicator}
<div className='col'>
<PostInfo
post={post}
lastPostCount={this.props.lastPostCount}
commentCount={this.props.commentCount}
handleCommentClick={this.props.handleCommentClick}
handleDropdownOpened={this.props.handleDropdownOpened}
isLastComment={this.props.isLastComment}
sameUser={this.props.sameUser}
currentUser={this.props.currentUser}
compactDisplay={this.props.compactDisplay}
useMilitaryTime={this.props.useMilitaryTime}
isFlagged={this.props.isFlagged}
getPostList={this.props.getPostList}
/>
</div>
</div>
);
}
}
PostHeader.defaultProps = {
post: null,
commentCount: 0,
isLastComment: false,
sameUser: false
};
PostHeader.propTypes = {
post: PropTypes.object.isRequired,
user: PropTypes.object,
currentUser: PropTypes.object.isRequired,
lastPostCount: PropTypes.number,
commentCount: PropTypes.number.isRequired,
isLastComment: PropTypes.bool.isRequired,
handleCommentClick: PropTypes.func.isRequired,
handleDropdownOpened: PropTypes.func.isRequired,
sameUser: PropTypes.bool.isRequired,
compactDisplay: PropTypes.bool,
displayNameType: PropTypes.string,
useMilitaryTime: PropTypes.bool.isRequired,
isFlagged: PropTypes.bool.isRequired,
status: PropTypes.string,
isBusy: PropTypes.bool,
getPostList: PropTypes.func.isRequired
};
|