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 TeamStore from 'stores/team_store.jsx';
|
||||||
|
|
||||||
import Constants from 'utils/constants.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 {Client4} from 'mattermost-redux/client';
|
||||||
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
@@ -178,7 +178,7 @@ export default class AddUsersToTeam extends React.Component {
|
|||||||
className='more-modal__details'
|
className='more-modal__details'
|
||||||
>
|
>
|
||||||
<div className='more-modal__name'>
|
<div className='more-modal__name'>
|
||||||
{displayUsernameForUser(option)}
|
{displayEntireNameForUser(option)}
|
||||||
</div>
|
</div>
|
||||||
<div className='more-modal__description'>
|
<div className='more-modal__description'>
|
||||||
{option.email}
|
{option.email}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import UserStore from 'stores/user_store.jsx';
|
|||||||
import TeamStore from 'stores/team_store.jsx';
|
import TeamStore from 'stores/team_store.jsx';
|
||||||
|
|
||||||
import Constants from 'utils/constants.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 {Client4} from 'mattermost-redux/client';
|
||||||
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
@@ -236,7 +236,7 @@ export default class MoreDirectChannels extends React.Component {
|
|||||||
className='more-modal__details'
|
className='more-modal__details'
|
||||||
>
|
>
|
||||||
<div className='more-modal__name'>
|
<div className='more-modal__name'>
|
||||||
{displayUsernameForUser(option)}
|
{displayEntireNameForUser(option)}
|
||||||
</div>
|
</div>
|
||||||
<div className='more-modal__description'>
|
<div className='more-modal__description'>
|
||||||
{option.email}
|
{option.email}
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ export default class PopoverListMembers extends React.Component {
|
|||||||
|
|
||||||
if (members && teamMembers) {
|
if (members && teamMembers) {
|
||||||
members.sort((a, b) => {
|
members.sort((a, b) => {
|
||||||
const aName = Utils.displayUsername(a.id);
|
const aName = Utils.displayEntireName(a.id);
|
||||||
const bName = Utils.displayUsername(b.id);
|
const bName = Utils.displayEntireName(b.id);
|
||||||
|
|
||||||
return aName.localeCompare(bName);
|
return aName.localeCompare(bName);
|
||||||
});
|
});
|
||||||
@@ -112,7 +112,7 @@ export default class PopoverListMembers extends React.Component {
|
|||||||
|
|
||||||
let name = '';
|
let name = '';
|
||||||
if (teamMembers[m.username]) {
|
if (teamMembers[m.username]) {
|
||||||
name = Utils.displayUsername(teamMembers[m.username].id);
|
name = Utils.displayEntireNameForUser(teamMembers[m.username]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
|
|||||||
@@ -14,12 +14,6 @@ import React from 'react';
|
|||||||
import {FormattedHTMLMessage} from 'react-intl';
|
import {FormattedHTMLMessage} from 'react-intl';
|
||||||
|
|
||||||
export default function UserListRow({user, extraInfo, actions, actionProps, actionUserProps, userCount}) {
|
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;
|
let buttons = null;
|
||||||
if (actions) {
|
if (actions) {
|
||||||
buttons = actions.map((Action, index) => {
|
buttons = actions.map((Action, index) => {
|
||||||
@@ -80,7 +74,7 @@ export default function UserListRow({user, extraInfo, actions, actionProps, acti
|
|||||||
id={userCountID}
|
id={userCountID}
|
||||||
className='more-modal__name'
|
className='more-modal__name'
|
||||||
>
|
>
|
||||||
{name}
|
{Utils.displayEntireNameForUser(user)}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
id={userCountEmail}
|
id={userCountEmail}
|
||||||
|
|||||||
@@ -1003,10 +1003,16 @@ export function getDisplayName(user) {
|
|||||||
return user.username;
|
return user.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the display name of the user with the specified id, respecting the TeammateNameDisplay configuration setting
|
||||||
|
*/
|
||||||
export function displayUsername(userId) {
|
export function displayUsername(userId) {
|
||||||
return displayUsernameForUser(UserStore.getProfile(userId));
|
return displayUsernameForUser(UserStore.getProfile(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the display name of the specified user, respecting the TeammateNameDisplay configuration setting
|
||||||
|
*/
|
||||||
export function displayUsernameForUser(user) {
|
export function displayUsernameForUser(user) {
|
||||||
if (user) {
|
if (user) {
|
||||||
const nameFormat = global.window.mm_config.TeammateNameDisplay;
|
const nameFormat = global.window.mm_config.TeammateNameDisplay;
|
||||||
@@ -1023,6 +1029,35 @@ export function displayUsernameForUser(user) {
|
|||||||
return '';
|
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) {
|
export function imageURLForUser(userIdOrObject) {
|
||||||
if (typeof userIdOrObject == 'string') {
|
if (typeof userIdOrObject == 'string') {
|
||||||
const profile = UserStore.getProfile(userIdOrObject);
|
const profile = UserStore.getProfile(userIdOrObject);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user