From 5a8c1c18e52c4604e1b8473fb3ab57c670e9858f Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Fri, 4 Aug 2017 13:51:08 -0400
Subject: PLT-7287 Move access token text in user list to under the dropdown
 (#7099)

* Move access token text in user list to under the dropdown

* Updating UI for token help text (#7107)
---
 .../system_users/system_users_dropdown.jsx         | 41 +++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

(limited to 'webapp/components/admin_console/system_users/system_users_dropdown.jsx')

diff --git a/webapp/components/admin_console/system_users/system_users_dropdown.jsx b/webapp/components/admin_console/system_users/system_users_dropdown.jsx
index 1dbb6b325..79ccc8b31 100644
--- a/webapp/components/admin_console/system_users/system_users_dropdown.jsx
+++ b/webapp/components/admin_console/system_users/system_users_dropdown.jsx
@@ -10,6 +10,7 @@ import Constants from 'utils/constants.jsx';
 import * as Utils from 'utils/utils.jsx';
 import {updateActive} from 'actions/user_actions.jsx';
 import {adminResetMfa} from 'actions/admin_actions.jsx';
+import * as UserUtils from 'mattermost-redux/utils/user_utils';
 
 import {FormattedMessage} from 'react-intl';
 
@@ -195,6 +196,43 @@ export default class SystemUsersDropdown extends React.Component {
         );
     }
 
+    renderAccessToken = () => {
+        const userAccessTokensEnabled = global.window.mm_config.EnableUserAccessTokens === 'true';
+        if (!userAccessTokensEnabled) {
+            return null;
+        }
+
+        const user = this.props.user;
+        const hasPostAllRole = UserUtils.hasPostAllRole(user.roles);
+        const hasPostAllPublicRole = UserUtils.hasPostAllPublicRole(user.roles);
+        const hasUserAccessTokenRole = UserUtils.hasUserAccessTokenRole(user.roles);
+        const isSystemAdmin = UserUtils.isSystemAdmin(user.roles);
+
+        let messageId = '';
+        if (hasUserAccessTokenRole || isSystemAdmin) {
+            if (hasPostAllRole) {
+                messageId = 'admin.user_item.userAccessTokenPostAll';
+            } else if (hasPostAllPublicRole) {
+                messageId = 'admin.user_item.userAccessTokenPostAllPublic';
+            } else {
+                messageId = 'admin.user_item.userAccessTokenYes';
+            }
+        }
+
+        if (!messageId) {
+            return null;
+        }
+
+        return (
+            <div className='light margin-top half'>
+                <FormattedMessage
+                    key='admin.user_item.userAccessToken'
+                    id={messageId}
+                />
+            </div>
+        );
+    }
+
     render() {
         let serverError = null;
         if (this.state.serverError) {
@@ -445,7 +483,7 @@ export default class SystemUsersDropdown extends React.Component {
         }
 
         return (
-            <div className='dropdown member-drop'>
+            <div className='dropdown member-drop text-right'>
                 <a
                     id='memberDropdown'
                     href='#'
@@ -457,6 +495,7 @@ export default class SystemUsersDropdown extends React.Component {
                     <span>{currentRoles} </span>
                     <span className='caret'/>
                 </a>
+                {this.renderAccessToken()}
                 <ul
                     className='dropdown-menu member-menu'
                     role='menu'
-- 
cgit v1.2.3-1-g7c22

