From 12896bd23eeba79884245c1c29fdc568cf21a7fa Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Mar 2016 08:50:46 -0400 Subject: Converting to Webpack. Stage 1. --- webapp/components/rhs_root_post.jsx | 290 ++++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 webapp/components/rhs_root_post.jsx (limited to 'webapp/components/rhs_root_post.jsx') diff --git a/webapp/components/rhs_root_post.jsx b/webapp/components/rhs_root_post.jsx new file mode 100644 index 000000000..a2c7ee7f8 --- /dev/null +++ b/webapp/components/rhs_root_post.jsx @@ -0,0 +1,290 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import ReactDOM from 'react-dom'; +import ChannelStore from 'stores/channel_store.jsx'; +import UserProfile from './user_profile.jsx'; +import UserStore from 'stores/user_store.jsx'; +import * as TextFormatting from 'utils/text_formatting.jsx'; +import * as Utils from 'utils/utils.jsx'; +import * as Emoji from 'utils/emoticons.jsx'; +import FileAttachmentList from './file_attachment_list.jsx'; +import twemoji from 'twemoji'; +import PostBodyAdditionalContent from './post_body_additional_content.jsx'; +import * as GlobalActions from 'action_creators/global_actions.jsx'; + +import Constants from 'utils/constants.jsx'; + +import {FormattedMessage, FormattedDate} from 'react-intl'; + +import React from 'react'; + +export default class RhsRootPost extends React.Component { + constructor(props) { + super(props); + + this.parseEmojis = this.parseEmojis.bind(this); + this.handlePermalink = this.handlePermalink.bind(this); + + this.state = {}; + } + parseEmojis() { + twemoji.parse(ReactDOM.findDOMNode(this), { + className: 'emoji twemoji', + base: '', + folder: Emoji.getImagePathForEmoticon() + }); + } + handlePermalink(e) { + e.preventDefault(); + GlobalActions.showGetPostLinkModal(this.props.post); + } + componentDidMount() { + this.parseEmojis(); + } + shouldComponentUpdate(nextProps) { + if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) { + return true; + } + + return false; + } + componentDidUpdate() { + this.parseEmojis(); + } + render() { + const post = this.props.post; + const user = this.props.user; + var isOwner = user.id === post.user_id; + var isAdmin = Utils.isAdmin(user.roles); + var timestamp = UserStore.getProfile(post.user_id).update_at; + var channel = ChannelStore.get(post.channel_id); + + var type = 'Post'; + if (post.root_id.length > 0) { + type = 'Comment'; + } + + var userCss = ''; + if (UserStore.getCurrentId() === post.user_id) { + userCss = 'current--user'; + } + + var systemMessageClass = ''; + if (Utils.isSystemMessage(post)) { + systemMessageClass = 'post--system'; + } + + var channelName; + if (channel) { + if (channel.type === 'D') { + channelName = ( + + ); + } else { + channelName = channel.display_name; + } + } + + var dropdownContents = []; + + if (!Utils.isMobile()) { + dropdownContents.push( +
  • + + + +
  • + ); + } + + if (isOwner) { + dropdownContents.push( +
  • + + + +
  • + ); + } + + if (isOwner || isAdmin) { + dropdownContents.push( +
  • + GlobalActions.showDeletePostModal(post, this.props.commentCount)} + > + + +
  • + ); + } + + var rootOptions = ''; + if (dropdownContents.length > 0) { + rootOptions = ( +
    +