Skip to content

Commit 06467a6

Browse files
authored
[IMPROVE] UserCard and UserInfo Show Real Names Setting (#18628)
1 parent 7d60bee commit 06467a6

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

client/components/basic/UserCard.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ export const Action = ({ icon, label, ...props }) => (
2222

2323
export const Info = (props) => (
2424
<Box
25-
mb='x4'
25+
mbe='x4'
2626
is='span'
27-
fontSize='p1'
2827
fontScale='p1'
2928
color='hint'
3029
withTruncatedText
3130
{...props}
3231
/>
3332
);
3433

35-
export const Username = ({ name, status = <Status.Offline/> }) => <Box display='flex' flexShrink={0} alignItems='center' fontScale='s2' color='default' withTruncatedText>
34+
export const Username = ({ name, status = <Status.Offline/>, title }) => <Box display='flex' title={title} flexShrink={0} alignItems='center' fontScale='s2' color='default' withTruncatedText>
3635
{status} <Box mis='x8' flexGrow={1} withTruncatedText>{name}</Box>
3736
</Box>;
3837

@@ -81,8 +80,9 @@ const UserCard = forwardRef(({
8180
</Box>}
8281
</Box>
8382
<Box display='flex' flexDirection='column' flexGrow={1} flexShrink={1} mis='x24' width='1px'>
84-
<Username status={status} name={name}/>
85-
{nickname && <Info title={t('Nickname')}>{nickname}</Info>}
83+
<Box withTruncatedText display='flex'>
84+
<Username status={status} name={name} title={username !== name && username}/>{nickname && <Box title={t('Nickname')} color='hint' mis='x8' fontScale='p1' withTruncatedText>({ nickname })</Box> }
85+
</Box>
8686
{ customStatus && <Info>{customStatus}</Info> }
8787
<Roles>{roles}</Roles>
8888
<Info>{localTime}</Info>

client/components/basic/UserCard.stories.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const user = {
1616
localTime: 'Local Time: 7:44 AM',
1717
};
1818

19+
const nickname = {
20+
...user,
21+
nickname: 'nicknamenickname',
22+
};
23+
1924
const largeName = {
2025
...user,
2126
customStatus:
@@ -59,8 +64,8 @@ const noBioNoLocalTimeNoRoles = {
5964

6065

6166
export const Basic = () => <UserCard {...user} />;
67+
export const Nickname = () => <UserCard {...nickname} />;
6268
export const LargeName = () => <UserCard {...largeName} />;
63-
6469
export const NoRoles = () => <UserCard {...noRoles} />;
6570
export const NoActions = () => <UserCard {...noActions} />;
6671
export const NoLocalTime = () => <UserCard {...noLocalTime} />;

client/components/basic/UserInfo.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const UserInfo = React.memo(function UserInfo({
4848
{actions}
4949

5050
<Margins block='x4'>
51-
<UserCard.Username name={username} status={status} />
51+
<UserCard.Username name={name || username} status={status} />
5252
<Info>{customStatus}</Info>
5353

5454
{!!roles && <>
@@ -61,6 +61,11 @@ export const UserInfo = React.memo(function UserInfo({
6161
<Info><UTCClock utcOffset={utcOffset}/></Info>
6262
</>}
6363

64+
{username !== name && <>
65+
<Label>{t('Username')}</Label>
66+
<Info>{username}</Info>
67+
</>}
68+
6469
<Label>{t('Last_login')}</Label>
6570
<Info>{lastLogin ? timeAgo(lastLogin) : t('Never')}</Info>
6671

client/components/basic/UserInfo.stories.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@ const user = {
2323
},
2424
};
2525

26+
const nickname = {
27+
...user,
28+
nickname: 'Nickname',
29+
};
30+
2631
export const Default = () => <VerticalBar><UserInfo { ...user } /></VerticalBar>;
32+
export const Nickname = () => <VerticalBar><UserInfo { ...nickname } /></VerticalBar>;

0 commit comments

Comments
 (0)