Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Misaligned username on Room Info card for omnichannel chats #25331

Merged
merged 9 commits into from
Jun 30, 2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Box } from '@rocket.chat/fuselage';
import React, { ReactElement, ReactNode, ComponentProps } from 'react';

import * as UserStatus from '../../../components/UserStatus';

type AgentOrContactDetailsProps = ComponentProps<typeof Box> & {
name: ReactNode;
status: ReactNode;
};

const AgentOrContactDetails = ({ name, status = <UserStatus.Offline />, ...props }: AgentOrContactDetailsProps): ReactElement => (
<Box
display='flex'
title={name}
flexGrow={0}
flexShrink={1}
flexBasis={0}
alignItems='center'
fontScale='h4'
color='default'
withTruncatedText
{...props}
>
{status}{' '}
<Box mis='x8' flexGrow={1} withTruncatedText>
{name}
</Box>
</Box>
);

export default AgentOrContactDetails;
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { useTranslation } from '@rocket.chat/ui-contexts';
import moment from 'moment';
import React, { ReactElement, useMemo } from 'react';

import UserCard from '../../../../../components/UserCard';
import { UserStatus } from '../../../../../components/UserStatus';
import VerticalBar from '../../../../../components/VerticalBar';
import UserAvatar from '../../../../../components/avatar/UserAvatar';
import InfoPanel from '../../../../InfoPanel';
import AgentOrContactDetails from '../../../components/AgentOrContactDetails';
import AgentField from '../../chats/contextualBar/AgentField';
import { InfoField } from './InfoField';

Expand Down Expand Up @@ -54,7 +54,7 @@ export const VoipInfo = ({ room, onClickClose /* , onClickReport, onClickCall */
<InfoPanel.Label>{t('Contact')}</InfoPanel.Label>
<Box display='flex'>
<UserAvatar size='x28' username={_name} />
<UserCard.Username mis='x8' title={_name} name={_name} status={<UserStatus status={v?.status} />} />
<AgentOrContactDetails mis='x8' name={_name} status={<UserStatus status={v?.status} />} />
</Box>
</InfoPanel.Field>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Box } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import React from 'react';

import UserCard from '../../../../../components/UserCard';
import { UserStatus } from '../../../../../components/UserStatus';
import UserAvatar from '../../../../../components/avatar/UserAvatar';
import { AsyncStatePhase } from '../../../../../hooks/useAsyncState';
import { useEndpointData } from '../../../../../hooks/useEndpointData';
import AgentOrContactDetails from '../../../components/AgentOrContactDetails';
import Field from '../../../components/Field';
import Info from '../../../components/Info';
import Label from '../../../components/Label';
Expand All @@ -32,8 +32,8 @@ const AgentField = ({ agent, isSmall = false }) => {
<Label>{t('Agent')}</Label>
<Info style={{ display: 'flex' }}>
<UserAvatar size={isSmall ? 'x28' : 'x40'} title={username} username={username} />
<UserCard.Username mis={isSmall ? 'x8' : 'x10'} name={displayName} status={<UserStatus status={status} />} />
{username && name && (
<AgentOrContactDetails mis={isSmall ? 'x8' : 'x10'} name={displayName} status={<UserStatus status={status} />} />
{username && (
<Box display='flex' mis='x7' mb='x9' align='center' justifyContent='center'>
({username})
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Avatar, Box } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import React from 'react';

import UserCard from '../../../../../components/UserCard';
import { UserStatus } from '../../../../../components/UserStatus';
import { useEndpointData } from '../../../../../hooks/useEndpointData';
import { AsyncStatePhase } from '../../../../../lib/asyncState';
import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator';
import AgentOrContactDetails from '../../../components/AgentOrContactDetails';
import Field from '../../../components/Field';
import Info from '../../../components/Info';
import Label from '../../../components/Label';
Expand Down Expand Up @@ -39,8 +39,8 @@ const ContactField = ({ contact, room }) => {
<Label>{t('Contact')}</Label>
<Info style={{ display: 'flex' }}>
<Avatar size='x40' title={fname} url={avatarUrl} />
<UserCard.Username mis='x10' name={displayName} status={<UserStatus status={status} />} />
{username && name && (
<AgentOrContactDetails mis='x10' name={displayName} status={<UserStatus status={status} />} />
{username && (
<Box display='flex' mis='x7' mb='x9' align='center' justifyContent='center'>
({username})
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import React, { useEffect, useState } from 'react';

import { hasPermission } from '../../../../../../app/authorization/client';
import ContactManagerInfo from '../../../../../../ee/client/omnichannel/ContactManagerInfo';
import UserCard from '../../../../../components/UserCard/UserCard';
import { UserStatus } from '../../../../../components/UserStatus';
import VerticalBar from '../../../../../components/VerticalBar';
import UserAvatar from '../../../../../components/avatar/UserAvatar';
import { AsyncStatePhase } from '../../../../../hooks/useAsyncState';
import { useEndpointData } from '../../../../../hooks/useEndpointData';
import { useFormatDate } from '../../../../../hooks/useFormatDate';
import AgentOrContactDetails from '../../../components/AgentOrContactDetails';
import CustomField from '../../../components/CustomField';
import Field from '../../../components/Field';
import Info from '../../../components/Info';
Expand Down Expand Up @@ -106,8 +106,8 @@ const ContactInfo = ({ id, rid, route }) => {
<Label>{`${t('Name')} / ${t('Username')}`}</Label>
<Info style={{ display: 'flex' }}>
<UserAvatar size='x40' title={username} username={username} />
<UserCard.Username mis='x10' name={displayName} status={<UserStatus status={status} />} />
{username && name && (
<AgentOrContactDetails mis='x10' name={displayName} status={<UserStatus status={status} />} />
{username && (
<Box display='flex' mis='x7' mb='x9' align='center' justifyContent='center'>
({username})
</Box>
Expand Down
17 changes: 10 additions & 7 deletions apps/meteor/ee/client/omnichannel/ContactManagerInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { css } from '@rocket.chat/css-in-js';
import { Box } from '@rocket.chat/fuselage';
import React from 'react';

import UserCard from '../../../client/components/UserCard';
import { UserStatus } from '../../../client/components/UserStatus';
import UserAvatar from '../../../client/components/avatar/UserAvatar';
import { AsyncStatePhase } from '../../../client/hooks/useAsyncState';
import { useEndpointData } from '../../../client/hooks/useEndpointData';
import AgentOrContactDetails from '../../../client/views/omnichannel/components/AgentOrContactDetails';
import Info from '../../../client/views/omnichannel/components/Info';

const wordBreak = css`
word-break: break-word;
Expand All @@ -24,13 +25,15 @@ function ContactManagerInfo({ username }) {

return (
<>
<UserCard.Info className={wordBreak} flexShrink={0} style={{ display: 'flex' }}>
<Info className={wordBreak} style={{ display: 'flex' }}>
<UserAvatar title={username} username={username} />
<UserCard.Username mis='x10' name={username} status={<UserStatus status={status} />} />
<Box display='flex' mis='x7' mb='x9' align='center' justifyContent='center'>
({name})
</Box>
</UserCard.Info>
<AgentOrContactDetails mis='x10' name={username} status={<UserStatus status={status} />} />
{name && (
<Box display='flex' mis='x7' mb='x9' align='center' justifyContent='center'>
({name})
</Box>
)}
</Info>
KevLehman marked this conversation as resolved.
Show resolved Hide resolved
</>
);
}
Expand Down