summaryrefslogtreecommitdiffstats
path: root/web/react/components/user_list_row.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-03 15:15:56 -0500
committerChristopher Speller <crspeller@gmail.com>2016-03-03 15:15:56 -0500
commita413c8ffa684b72840f116380c04a61f1d9cf524 (patch)
tree287e855db2906058928f1916cbd3fa84857fdcc3 /web/react/components/user_list_row.jsx
parentbc2768fd254e82b6ca39a916436ab4747898578e (diff)
parent449f1000e999c409f754724cb998f0b9f90cdd59 (diff)
downloadchat-a413c8ffa684b72840f116380c04a61f1d9cf524.tar.gz
chat-a413c8ffa684b72840f116380c04a61f1d9cf524.tar.bz2
chat-a413c8ffa684b72840f116380c04a61f1d9cf524.zip
Merge pull request #2318 from hmhealey/plt1090
PLT-1090 Refactored modals that display users
Diffstat (limited to 'web/react/components/user_list_row.jsx')
-rw-r--r--web/react/components/user_list_row.jsx65
1 files changed, 65 insertions, 0 deletions
diff --git a/web/react/components/user_list_row.jsx b/web/react/components/user_list_row.jsx
new file mode 100644
index 000000000..2aeca7d47
--- /dev/null
+++ b/web/react/components/user_list_row.jsx
@@ -0,0 +1,65 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import Constants from '../utils/constants.jsx';
+import PreferenceStore from '../stores/preference_store.jsx';
+import * as Utils from '../utils/utils.jsx';
+
+export default function UserListRow({user, actions}) {
+ const nameFormat = PreferenceStore.get(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', '');
+
+ let name = user.username;
+ if (user.nickname && nameFormat === Constants.Preferences.DISPLAY_PREFER_NICKNAME) {
+ name = `${user.nickname} (${user.username})`;
+ } else if ((user.first_name || user.last_name) && (nameFormat === Constants.Preferences.DISPLAY_PREFER_NICKNAME || nameFormat === Constants.Preferences.DISPLAY_PREFER_FULL_NAME)) {
+ name = `${Utils.getFullName(user)} (${user.username})`;
+ }
+
+ const buttons = actions.map((Action, index) => {
+ return (
+ <Action
+ key={index.toString()}
+ user={user}
+ />
+ );
+ });
+
+ return (
+ <tr>
+ <td
+ key={user.id}
+ className='direct-channel'
+ style={{display: 'flex'}}
+ >
+ <img
+ className='profile-img'
+ src={`/api/v1/users/${user.id}/image?time=${user.update_at}&${Utils.getSessionIndex()}`}
+ />
+ <div
+ className='user-list-item__details'
+ >
+ <div className='more-name'>
+ {name}
+ </div>
+ <div className='more-description'>
+ {user.email}
+ </div>
+ </div>
+ <div
+ className='user-list-item__actions'
+ >
+ {buttons}
+ </div>
+ </td>
+ </tr>
+ );
+}
+
+UserListRow.defaultProps = {
+ actions: []
+};
+
+UserListRow.propTypes = {
+ user: React.PropTypes.object.isRequired,
+ actions: React.PropTypes.arrayOf(React.PropTypes.func)
+};