From 87746227bfbc738bf79bda35cb8c06859f186c18 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 24 Jul 2017 08:22:19 -0400 Subject: PLT-3470: Changed all instances of user list to show full name, username, and nickname (#6994) --- webapp/utils/utils.jsx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'webapp/utils') diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx index 0bd8c7bff..da5436737 100644 --- a/webapp/utils/utils.jsx +++ b/webapp/utils/utils.jsx @@ -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); -- cgit v1.2.3-1-g7c22