// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; import Constants from 'utils/constants.jsx'; import {Tooltip, OverlayTrigger} from 'react-bootstrap'; import * as GlobalActions from 'actions/global_actions.jsx'; import {getFlaggedPosts, getPinnedPosts} from 'actions/post_actions.jsx'; import {FormattedMessage} from 'react-intl'; const ActionTypes = Constants.ActionTypes; import PropTypes from 'prop-types'; import React from 'react'; export default class RhsHeaderPost extends React.Component { constructor(props) { super(props); this.handleClose = this.handleClose.bind(this); this.toggleSize = this.toggleSize.bind(this); this.handleBack = this.handleBack.bind(this); this.state = {}; } handleClose(e) { e.preventDefault(); GlobalActions.emitCloseRightHandSide(); this.props.shrink(); } toggleSize(e) { e.preventDefault(); this.props.toggleSize(); } handleBack(e) { e.preventDefault(); if (this.props.fromSearch || this.props.isWebrtc) { AppDispatcher.handleServerAction({ type: ActionTypes.RECEIVED_SEARCH_TERM, term: this.props.fromSearch, do_search: true, is_mention_search: this.props.isMentionSearch }); AppDispatcher.handleServerAction({ type: ActionTypes.RECEIVED_POST_SELECTED, postId: null }); } else if (this.props.fromFlaggedPosts) { getFlaggedPosts(); } else if (this.props.fromPinnedPosts) { getPinnedPosts(); } } render() { let back; const closeSidebarTooltip = ( ); let backToResultsTooltip; if (this.props.fromSearch) { backToResultsTooltip = ( ); } else if (this.props.fromFlaggedPosts) { backToResultsTooltip = ( ); } else if (this.props.isWebrtc) { backToResultsTooltip = ( ); } else if (this.props.fromPinnedPosts) { backToResultsTooltip = ( ); } const expandSidebarTooltip = ( ); const shrinkSidebarTooltip = ( ); if (this.props.fromSearch || this.props.fromFlaggedPosts || this.props.isWebrtc || this.props.fromPinnedPosts) { back = ( ); } return (
{back}
); } } RhsHeaderPost.defaultProps = { isMentionSearch: false, fromSearch: '' }; RhsHeaderPost.propTypes = { isMentionSearch: PropTypes.bool, isWebrtc: PropTypes.bool, fromSearch: PropTypes.string, fromFlaggedPosts: PropTypes.bool, fromPinnedPosts: PropTypes.bool, toggleSize: PropTypes.func, shrink: PropTypes.func };