diff options
Diffstat (limited to 'webapp/components/rhs_comment.jsx')
-rw-r--r-- | webapp/components/rhs_comment.jsx | 63 |
1 files changed, 12 insertions, 51 deletions
diff --git a/webapp/components/rhs_comment.jsx b/webapp/components/rhs_comment.jsx index 5097e0573..a771803b8 100644 --- a/webapp/components/rhs_comment.jsx +++ b/webapp/components/rhs_comment.jsx @@ -3,22 +3,18 @@ import UserProfile from './user_profile.jsx'; import FileAttachmentList from './file_attachment_list.jsx'; +import PendingPostActions from './pending_post_actions.jsx'; -import PostStore from 'stores/post_store.jsx'; -import ChannelStore from 'stores/channel_store.jsx'; import TeamStore from 'stores/team_store.jsx'; import UserStore from 'stores/user_store.jsx'; -import * as GlobalActions from 'action_creators/global_actions.jsx'; -import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; +import * as GlobalActions from 'actions/global_actions.jsx'; import * as TextFormatting from 'utils/text_formatting.jsx'; import * as Utils from 'utils/utils.jsx'; import Client from 'utils/web_client.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; import Constants from 'utils/constants.jsx'; -const ActionTypes = Constants.ActionTypes; import {FormattedMessage, FormattedDate} from 'react-intl'; @@ -30,41 +26,10 @@ export default class RhsComment extends React.Component { constructor(props) { super(props); - this.retryComment = this.retryComment.bind(this); this.handlePermalink = this.handlePermalink.bind(this); this.state = {}; } - retryComment(e) { - e.preventDefault(); - - var post = this.props.post; - Client.createPost(post, - (data) => { - AsyncClient.getPosts(post.channel_id); - - var channel = ChannelStore.get(post.channel_id); - var member = ChannelStore.getMember(post.channel_id); - member.msg_count = channel.total_msg_count; - member.last_viewed_at = (new Date()).getTime(); - ChannelStore.setChannelMember(member); - - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_POST, - post: data - }); - }, - () => { - post.state = Constants.POST_FAILED; - PostStore.updatePendingPost(post); - this.forceUpdate(); - } - ); - - post.state = Constants.POST_LOADING; - PostStore.updatePendingPost(post); - this.forceUpdate(); - } handlePermalink(e) { e.preventDefault(); GlobalActions.showGetPostLinkModal(this.props.post); @@ -85,6 +50,7 @@ export default class RhsComment extends React.Component { const isOwner = this.props.currentUser.id === post.user_id; var isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); + const isSystemMessage = post.type && post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX); var dropdownContents = []; @@ -107,7 +73,7 @@ export default class RhsComment extends React.Component { ); } - if (isOwner) { + if (isOwner && !isSystemMessage) { dropdownContents.push( <li role='presentation' @@ -185,6 +151,11 @@ export default class RhsComment extends React.Component { var timestamp = this.props.currentUser.update_at; + let botIndicator; + + if (post.props && post.props.from_webhook) { + botIndicator = <li className='col col__name bot-indicator'>{Constants.BOT_NAME}</li>; + } let loading; let postClass = ''; let message = ( @@ -197,18 +168,7 @@ export default class RhsComment extends React.Component { if (post.state === Constants.POST_FAILED) { postClass += ' post-fail'; - loading = ( - <a - className='theme post-retry pull-right' - href='#' - onClick={this.retryComment} - > - <FormattedMessage - id='rhs_comment.retry' - defaultMessage='Retry' - /> - </a> - ); + loading = <PendingPostActions post={this.props.post}/>; } else if (post.state === Constants.POST_LOADING) { postClass += ' post-waiting'; loading = ( @@ -251,9 +211,10 @@ export default class RhsComment extends React.Component { </div> <div> <ul className='post__header'> - <li className='col__name'> + <li className='col col__name'> <strong><UserProfile user={this.props.user}/></strong> </li> + {botIndicator} <li className='col'> <time className='post__time'> <FormattedDate |