blob: 219aa7093a7cc5cbd9820b4fec994f8b6c77e3e7 (
plain)
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
126
127
128
129
130
131
132
133
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import UserStore from 'stores/user_store.jsx';
import UserProfile from './user_profile.jsx';
import * as GlobalActions from 'action_creators/global_actions.jsx';
import * as TextFormatting from 'utils/text_formatting.jsx';
import * as Utils from 'utils/utils.jsx';
import Constants from 'utils/constants.jsx';
import {FormattedMessage, FormattedDate} from 'react-intl';
import React from 'react';
import {Link} from 'react-router';
export default class SearchResultsItem extends React.Component {
constructor(props) {
super(props);
this.handleFocusRHSClick = this.handleFocusRHSClick.bind(this);
}
handleFocusRHSClick(e) {
e.preventDefault();
GlobalActions.emitPostFocusRightHandSideFromSearch(this.props.post, this.props.isMentionSearch);
}
render() {
let channelName = null;
const channel = this.props.channel;
const timestamp = UserStore.getCurrentUser().update_at;
const user = this.props.user || {};
if (channel) {
channelName = channel.display_name;
if (channel.type === 'D') {
channelName = (
<FormattedMessage
id='search_item.direct'
defaultMessage='Direct Message'
/>
);
}
}
const formattingOptions = {
searchTerm: this.props.term,
mentionHighlight: this.props.isMentionSearch
};
return (
<div className='search-item__container'>
<div className='date-separator'>
<hr className='separator__hr'/>
<div className='separator__text'>
<FormattedDate
value={this.props.post.create_at}
day='numeric'
month='long'
year='numeric'
/>
</div>
</div>
<div
className='post'
>
<div className='search-channel__name'>{channelName}</div>
<div className='post__content'>
<div className='post__img'>
<img
src={'/api/v1/users/' + this.props.post.user_id + '/image?time=' + timestamp}
height='36'
width='36'
/>
</div>
<div>
<ul className='post__header'>
<li className='col__name'><strong><UserProfile user={user}/></strong></li>
<li className='col'>
<time className='search-item-time'>
<FormattedDate
value={this.props.post.create_at}
hour12={true}
hour='2-digit'
minute='2-digit'
/>
</time>
</li>
<li>
<Link
to={Utils.getTeamURLFromAddressBar() + '/pl/' + this.props.post.id}
className='search-item__jump'
>
<FormattedMessage
id='search_item.jump'
defaultMessage='Jump'
/>
</Link>
</li>
<li>
<a
href='#'
className='comment-icon__container search-item__comment'
onClick={this.handleFocusRHSClick}
>
<span
className='comment-icon'
dangerouslySetInnerHTML={{__html: Constants.REPLY_ICON}}
/>
</a>
</li>
</ul>
<div className='search-item-snippet'>
<span
onClick={TextFormatting.handleClick}
dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.props.post.message, formattingOptions)}}
/>
</div>
</div>
</div>
</div>
</div>
);
}
}
SearchResultsItem.propTypes = {
post: React.PropTypes.object,
user: React.PropTypes.object,
channel: React.PropTypes.object,
isMentionSearch: React.PropTypes.bool,
term: React.PropTypes.string
};
|