Changed information displayed in user list to obey display name settings

Этот коммит содержится в:
hmhealey
2016-03-01 16:28:47 -05:00
коммит произвёл Harrison Healey
родитель 998d621155
Коммит 26ea30cb16
3 изменённых файлов: 14 добавлений и 26 удалений

Просмотреть файл

@@ -1,32 +1,18 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // 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'; import * as Utils from '../utils/utils.jsx';
export default function UserListRow({user, actions}) { export default function UserListRow({user, actions}) {
const details = []; const nameFormat = PreferenceStore.get(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', '');
const fullName = Utils.getFullName(user); let name = user.username;
if (fullName) { if (user.nickname && nameFormat === Constants.Preferences.DISPLAY_PREFER_NICKNAME) {
details.push( name = `${user.nickname} (${user.username})`;
<span } else if ((user.first_name || user.last_name) && (nameFormat === Constants.Preferences.DISPLAY_PREFER_NICKNAME || nameFormat === Constants.Preferences.DISPLAY_PREFER_FULL_NAME)) {
key={`${user.id}__full-name`} name = `${Utils.getFullName(user)} (${user.username})`;
className='full-name'
>
{fullName}
</span>
);
}
if (user.nickname) {
const separator = fullName ? ' - ' : '';
details.push(
<span
key={`${user.nickname}__nickname`}
>
{separator + user.nickname}
</span>
);
} }
const buttons = actions.map((Action, index) => { const buttons = actions.map((Action, index) => {
@@ -53,10 +39,10 @@ export default function UserListRow({user, actions}) {
className='user-list-item__details' className='user-list-item__details'
> >
<div className='more-name'> <div className='more-name'>
{user.username} {name}
</div> </div>
<div className='more-description'> <div className='more-description'>
{details} {user.email}
</div> </div>
</div> </div>
<div <div

Просмотреть файл

@@ -437,6 +437,8 @@ export default {
Preferences: { Preferences: {
CATEGORY_DIRECT_CHANNEL_SHOW: 'direct_channel_show', CATEGORY_DIRECT_CHANNEL_SHOW: 'direct_channel_show',
CATEGORY_DISPLAY_SETTINGS: 'display_settings', CATEGORY_DISPLAY_SETTINGS: 'display_settings',
DISPLAY_PREFER_NICKNAME: 'nickname_full_name',
DISPLAY_PREFER_FULL_NAME: 'full_name',
CATEGORY_ADVANCED_SETTINGS: 'advanced_settings', CATEGORY_ADVANCED_SETTINGS: 'advanced_settings',
TUTORIAL_STEP: 'tutorial_step' TUTORIAL_STEP: 'tutorial_step'
}, },

Просмотреть файл

@@ -1082,9 +1082,9 @@ export function displayUsername(userId) {
let username = ''; let username = '';
if (user) { if (user) {
if (nameFormat === 'nickname_full_name') { if (nameFormat === Constants.Preferences.DISPLAY_PREFER_NICKNAME) {
username = user.nickname || getFullName(user); username = user.nickname || getFullName(user);
} else if (nameFormat === 'full_name') { } else if (nameFormat === Constants.Preferences.DISPLAY_PREFER_FULL_NAME) {
username = getFullName(user); username = getFullName(user);
} }
if (!username.trim().length) { if (!username.trim().length) {