// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import $ from 'jquery'; import UserProfile from './user_profile.jsx'; import TeamStore from 'stores/team_store.jsx'; import UserStore from 'stores/user_store.jsx'; import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; import * as GlobalActions from 'actions/global_actions.jsx'; import {unflagPost, getFlaggedPosts} from 'actions/post_actions.jsx'; import * as TextFormatting from 'utils/text_formatting.jsx'; import * as Utils from 'utils/utils.jsx'; import * as PostUtils from 'utils/post_utils.jsx'; import Constants from 'utils/constants.jsx'; import {Tooltip, OverlayTrigger} from 'react-bootstrap'; const ActionTypes = Constants.ActionTypes; import React from 'react'; import {FormattedMessage, FormattedDate} from 'react-intl'; import {browserHistory} from 'react-router/es6'; export default class SearchResultsItem extends React.Component { constructor(props) { super(props); this.handleFocusRHSClick = this.handleFocusRHSClick.bind(this); this.shrinkSidebar = this.shrinkSidebar.bind(this); this.unflagPost = this.unflagPost.bind(this); } hideSidebar() { $('.sidebar--right').removeClass('move--left'); } shrinkSidebar() { setTimeout(() => { this.props.shrink(); }); } handleFocusRHSClick(e) { e.preventDefault(); GlobalActions.emitPostFocusRightHandSideFromSearch(this.props.post, this.props.isMentionSearch); } unflagPost(e) { e.preventDefault(); unflagPost(this.props.post.id, () => getFlaggedPosts() ); } render() { let channelName = null; const channel = this.props.channel; const timestamp = UserStore.getCurrentUser().update_at; const user = this.props.user || {}; const post = this.props.post; const flagIcon = Constants.FLAG_ICON_SVG; if (channel) { channelName = channel.display_name; if (channel.type === 'D') { channelName = ( ); } } const formattingOptions = { searchTerm: this.props.term, mentionHighlight: this.props.isMentionSearch }; let overrideUsername; let disableProfilePopover = false; if (post.props && post.props.from_webhook && post.props.override_username && global.window.mm_config.EnablePostUsernameOverride === 'true') { overrideUsername = post.props.override_username; disableProfilePopover = true; } let botIndicator; if (post.props && post.props.from_webhook) { botIndicator =
  • {Constants.BOT_NAME}
  • ; } let flag; let flagVisible = ''; let flagTooltip = ( ); if (this.props.isFlagged) { flagVisible = 'visible'; flagTooltip = ( ); flag = ( ); } return (

    {channelName}
    ); } } SearchResultsItem.propTypes = { post: React.PropTypes.object, user: React.PropTypes.object, channel: React.PropTypes.object, isMentionSearch: React.PropTypes.bool, term: React.PropTypes.string, useMilitaryTime: React.PropTypes.bool.isRequired, shrink: React.PropTypes.function, isFlagged: React.PropTypes.bool };