Skip to content

Commit 7d9eb6a

Browse files
feat: standardize username display (#38532)
1 parent e1a7b39 commit 7d9eb6a

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

.changeset/wet-beers-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket.chat/meteor': minor
3+
---
4+
5+
Standardizes the display of username with `@` before

apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultipleOption.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const UserAutoCompleteMultipleOption = ({ label, ...props }: UserAutoCompleteMul
2424

2525
return (
2626
<>
27-
{name} {!_federated && <OptionDescription>({username})</OptionDescription>}
27+
{name} {!_federated && <OptionDescription>@{username}</OptionDescription>}
2828
</>
2929
);
3030
}, [_federated, name, useRealName, username]);

apps/meteor/client/views/room/composer/ComposerBoxPopupUser.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { OptionAvatar, OptionColumn, OptionContent, OptionInput } from '@rocket.chat/fuselage';
22
import { UserAvatar } from '@rocket.chat/ui-avatar';
3+
import { useSetting } from '@rocket.chat/ui-contexts';
34
import { useTranslation } from 'react-i18next';
45

6+
import { getUserDisplayNames } from '../../../../lib/getUserDisplayNames';
57
import ReactiveUserStatus from '../../../components/UserStatus/ReactiveUserStatus';
68

79
export type ComposerBoxPopupUserProps = {
@@ -19,6 +21,9 @@ export type ComposerBoxPopupUserProps = {
1921

2022
function ComposerBoxPopupUser({ _id, system, username, name, nickname, outside, suggestion, variant }: ComposerBoxPopupUserProps) {
2123
const { t } = useTranslation();
24+
const useRealName = useSetting('UI_Use_Real_Name', false);
25+
26+
const [nameOrUsername, displayUsername] = getUserDisplayNames(name, username, useRealName);
2227

2328
return (
2429
<>
@@ -31,15 +36,15 @@ function ComposerBoxPopupUser({ _id, system, username, name, nickname, outside,
3136
<ReactiveUserStatus uid={_id} />
3237
</OptionColumn>
3338
<OptionContent>
34-
<strong>{name ?? username}</strong> {name && name !== username && username}
35-
{nickname && <span className='popup-user-nickname'>({nickname})</span>}
39+
<strong>{nameOrUsername}</strong> {displayUsername && `@${displayUsername}`}
40+
{nickname && <span className='popup-user-nickname'> ({nickname})</span>}
3641
</OptionContent>
3742
</>
3843
)}
3944

4045
{system && (
4146
<OptionContent>
42-
<strong>{username}</strong> {name}
47+
<strong>@{username}</strong> {name}
4348
</OptionContent>
4449
)}
4550

apps/meteor/client/views/room/contextualBar/RoomMembers/RoomMembersItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const RoomMembersItem = ({
6767
</OptionAvatar>
6868
<OptionColumn>{federated ? <Icon name='globe' size='x16' /> : <ReactiveUserStatus uid={_id} />}</OptionColumn>
6969
<OptionContent data-qa={`MemberItem-${username}`}>
70-
{nameOrUsername} {displayUsername && <OptionDescription>({displayUsername})</OptionDescription>}
70+
{nameOrUsername} {displayUsername && <OptionDescription>@{displayUsername}</OptionDescription>}
7171
</OptionContent>
7272
{subscription?.status === 'INVITED' && (
7373
<OptionColumn>

apps/meteor/tests/e2e/message-mentions.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ test.describe.serial('message-mentions', () => {
111111
await poHomeChannel.navbar.openChat('general');
112112
await poHomeChannel.composer.inputMessage.type('@');
113113

114-
await expect(poHomeChannel.content.messagePopupUsers.locator('role=listitem >> text="all"')).toBeVisible();
115-
await expect(poHomeChannel.content.messagePopupUsers.locator('role=listitem >> text="here"')).toBeVisible();
114+
await expect(poHomeChannel.content.messagePopupUsers.locator('role=listitem >> text="@all"')).toBeVisible();
115+
await expect(poHomeChannel.content.messagePopupUsers.locator('role=listitem >> text="@here"')).toBeVisible();
116116
});
117117

118118
test.describe('users not in channel', () => {

0 commit comments

Comments
 (0)