PLT-3470: Changed all instances of user list to show full name, username, and nickname (#6994)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
b27d51d512
Коммит
87746227bf
@@ -11,7 +11,7 @@ import UserStore from 'stores/user_store.jsx';
|
||||
import TeamStore from 'stores/team_store.jsx';
|
||||
|
||||
import Constants from 'utils/constants.jsx';
|
||||
import {displayUsernameForUser} from 'utils/utils.jsx';
|
||||
import {displayEntireNameForUser} from 'utils/utils.jsx';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
@@ -178,7 +178,7 @@ export default class AddUsersToTeam extends React.Component {
|
||||
className='more-modal__details'
|
||||
>
|
||||
<div className='more-modal__name'>
|
||||
{displayUsernameForUser(option)}
|
||||
{displayEntireNameForUser(option)}
|
||||
</div>
|
||||
<div className='more-modal__description'>
|
||||
{option.email}
|
||||
|
||||
@@ -11,7 +11,7 @@ import UserStore from 'stores/user_store.jsx';
|
||||
import TeamStore from 'stores/team_store.jsx';
|
||||
|
||||
import Constants from 'utils/constants.jsx';
|
||||
import {displayUsernameForUser} from 'utils/utils.jsx';
|
||||
import {displayEntireNameForUser} from 'utils/utils.jsx';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
@@ -236,7 +236,7 @@ export default class MoreDirectChannels extends React.Component {
|
||||
className='more-modal__details'
|
||||
>
|
||||
<div className='more-modal__name'>
|
||||
{displayUsernameForUser(option)}
|
||||
{displayEntireNameForUser(option)}
|
||||
</div>
|
||||
<div className='more-modal__description'>
|
||||
{option.email}
|
||||
|
||||
@@ -98,8 +98,8 @@ export default class PopoverListMembers extends React.Component {
|
||||
|
||||
if (members && teamMembers) {
|
||||
members.sort((a, b) => {
|
||||
const aName = Utils.displayUsername(a.id);
|
||||
const bName = Utils.displayUsername(b.id);
|
||||
const aName = Utils.displayEntireName(a.id);
|
||||
const bName = Utils.displayEntireName(b.id);
|
||||
|
||||
return aName.localeCompare(bName);
|
||||
});
|
||||
@@ -112,7 +112,7 @@ export default class PopoverListMembers extends React.Component {
|
||||
|
||||
let name = '';
|
||||
if (teamMembers[m.username]) {
|
||||
name = Utils.displayUsername(teamMembers[m.username].id);
|
||||
name = Utils.displayEntireNameForUser(teamMembers[m.username]);
|
||||
}
|
||||
|
||||
if (name) {
|
||||
|
||||
@@ -14,12 +14,6 @@ import React from 'react';
|
||||
import {FormattedHTMLMessage} from 'react-intl';
|
||||
|
||||
export default function UserListRow({user, extraInfo, actions, actionProps, actionUserProps, userCount}) {
|
||||
const displayName = Utils.displayUsernameForUser(user);
|
||||
let name = `${displayName} (@${user.username})`;
|
||||
if (displayName === user.username) {
|
||||
name = user.username;
|
||||
}
|
||||
|
||||
let buttons = null;
|
||||
if (actions) {
|
||||
buttons = actions.map((Action, index) => {
|
||||
@@ -80,7 +74,7 @@ export default function UserListRow({user, extraInfo, actions, actionProps, acti
|
||||
id={userCountID}
|
||||
className='more-modal__name'
|
||||
>
|
||||
{name}
|
||||
{Utils.displayEntireNameForUser(user)}
|
||||
</div>
|
||||
<div
|
||||
id={userCountEmail}
|
||||
|
||||
@@ -1003,10 +1003,16 @@ export function getDisplayName(user) {
|
||||
return user.username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name of the user with the specified id, respecting the TeammateNameDisplay configuration setting
|
||||
*/
|
||||
export function displayUsername(userId) {
|
||||
return displayUsernameForUser(UserStore.getProfile(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name of the specified user, respecting the TeammateNameDisplay configuration setting
|
||||
*/
|
||||
export function displayUsernameForUser(user) {
|
||||
if (user) {
|
||||
const nameFormat = global.window.mm_config.TeammateNameDisplay;
|
||||
@@ -1023,6 +1029,35 @@ export function displayUsernameForUser(user) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entire name, including username, full name, and nickname, of the user with the specified id
|
||||
*/
|
||||
export function displayEntireName(userId) {
|
||||
return displayEntireNameForUser(UserStore.getProfile(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entire name, including username, full name, and nickname, of the specified user
|
||||
*/
|
||||
export function displayEntireNameForUser(user) {
|
||||
if (!user) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let displayName = user.username;
|
||||
const fullName = getFullName(user);
|
||||
|
||||
if (fullName && user.nickname) {
|
||||
displayName += ` - ${fullName} (${user.nickname})`;
|
||||
} else if (fullName) {
|
||||
displayName += ` - ${fullName}`;
|
||||
} else if (user.nickname) {
|
||||
displayName += ` - ${user.nickname}`;
|
||||
}
|
||||
|
||||
return displayName;
|
||||
}
|
||||
|
||||
export function imageURLForUser(userIdOrObject) {
|
||||
if (typeof userIdOrObject == 'string') {
|
||||
const profile = UserStore.getProfile(userIdOrObject);
|
||||
|
||||
Ссылка в новой задаче
Block a user