From 63c122bc028198704485e00cc47c7ba2218e9708 Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Fri, 7 Apr 2017 14:21:58 -0400
Subject: PLT-6201/PLT-6220 Don't show pin or reaction options for system
 messages (#6010)

* PLT-6220 Removed ability to react to system messages

* PLT-6201 Removed ability to pin system messages
---
 webapp/components/rhs_root_post.jsx | 97 ++++++++++++++++++-------------------
 1 file changed, 48 insertions(+), 49 deletions(-)

(limited to 'webapp/components/rhs_root_post.jsx')

diff --git a/webapp/components/rhs_root_post.jsx b/webapp/components/rhs_root_post.jsx
index b298853d8..9a9f83f0c 100644
--- a/webapp/components/rhs_root_post.jsx
+++ b/webapp/components/rhs_root_post.jsx
@@ -182,18 +182,15 @@ export default class RhsRootPost extends React.Component {
         const mattermostLogo = Constants.MATTERMOST_ICON_SVG;
         var timestamp = user ? user.last_picture_update : 0;
         var channel = ChannelStore.get(post.channel_id);
-        let canReact = false;
         const flagIcon = Constants.FLAG_ICON_SVG;
-        if (post.state !== Constants.POST_FAILED &&
-            post.state !== Constants.POST_LOADING &&
-            !Utils.isPostEphemeral(post) &&
-            Utils.isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.EMOJI_PICKER_PREVIEW)) {
-            canReact = true;
-        }
 
         this.canDelete = PostUtils.canDeletePost(post);
         this.canEdit = PostUtils.canEditPost(post, this.editDisableAction);
 
+        const isEphemeral = Utils.isPostEphemeral(post);
+        const isPending = post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING;
+        const isSystemMessage = PostUtils.isSystemMessage(post);
+
         var type = 'Post';
         if (post.root_id.length > 0) {
             type = 'Comment';
@@ -205,7 +202,7 @@ export default class RhsRootPost extends React.Component {
         }
 
         var systemMessageClass = '';
-        if (PostUtils.isSystemMessage(post)) {
+        if (isSystemMessage) {
             systemMessageClass = 'post--system';
         }
 
@@ -226,7 +223,7 @@ export default class RhsRootPost extends React.Component {
         let react;
         let reactOverlay;
 
-        if (canReact) {
+        if (!isEphemeral && !isPending && !isSystemMessage && Utils.isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.EMOJI_PICKER_PREVIEW)) {
             react = (
                 <span>
                     <a
@@ -298,57 +295,59 @@ export default class RhsRootPost extends React.Component {
             }
         }
 
-        dropdownContents.push(
-            <li
-                key='rhs-root-permalink'
-                role='presentation'
-            >
-                <a
-                    href='#'
-                    onClick={this.handlePermalink}
-                >
-                    <FormattedMessage
-                        id='rhs_root.permalink'
-                        defaultMessage='Permalink'
-                    />
-                </a>
-            </li>
-        );
-
-        if (post.is_pinned) {
+        if (!isSystemMessage) {
             dropdownContents.push(
                 <li
-                    key='rhs-root-unpin'
+                    key='rhs-root-permalink'
                     role='presentation'
                 >
                     <a
                         href='#'
-                        onClick={this.unpinPost}
+                        onClick={this.handlePermalink}
                     >
                         <FormattedMessage
-                            id='rhs_root.unpin'
-                            defaultMessage='Un-pin from channel'
+                            id='rhs_root.permalink'
+                            defaultMessage='Permalink'
                         />
                     </a>
                 </li>
             );
-        } else {
-            dropdownContents.push(
-                <li
-                    key='rhs-root-pin'
-                    role='presentation'
-                >
-                    <a
-                        href='#'
-                        onClick={this.pinPost}
+
+            if (post.is_pinned) {
+                dropdownContents.push(
+                    <li
+                        key='rhs-root-unpin'
+                        role='presentation'
                     >
-                        <FormattedMessage
-                            id='rhs_root.pin'
-                            defaultMessage='Pin to channel'
-                        />
-                    </a>
-                </li>
-            );
+                        <a
+                            href='#'
+                            onClick={this.unpinPost}
+                        >
+                            <FormattedMessage
+                                id='rhs_root.unpin'
+                                defaultMessage='Un-pin from channel'
+                            />
+                        </a>
+                    </li>
+                );
+            } else {
+                dropdownContents.push(
+                    <li
+                        key='rhs-root-pin'
+                        role='presentation'
+                    >
+                        <a
+                            href='#'
+                            onClick={this.pinPost}
+                        >
+                            <FormattedMessage
+                                id='rhs_root.pin'
+                                defaultMessage='Pin to channel'
+                            />
+                        </a>
+                    </li>
+                );
+            }
         }
 
         if (this.canDelete) {
@@ -443,7 +442,7 @@ export default class RhsRootPost extends React.Component {
             }
 
             botIndicator = <li className='col col__name bot-indicator'>{'BOT'}</li>;
-        } else if (PostUtils.isSystemMessage(post)) {
+        } else if (isSystemMessage) {
             userProfile = (
                 <UserProfile
                     user={{}}
@@ -485,7 +484,7 @@ export default class RhsRootPost extends React.Component {
             );
         }
 
-        if (PostUtils.isSystemMessage(post)) {
+        if (isSystemMessage) {
             profilePic = (
                 <span
                     className='icon'
-- 
cgit v1.2.3-1-g7c22

