Skip to content

Commit

Permalink
Regression: Added missing call button in the contact info contextual …
Browse files Browse the repository at this point in the history
…bar (#26135)
  • Loading branch information
aleksandernsilva authored and weslley543 committed Jul 8, 2022
1 parent bc2a0a1 commit 3783ecf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, { ReactElement, useMemo } from 'react';
import { UserStatus } from '../../../../../components/UserStatus';
import VerticalBar from '../../../../../components/VerticalBar';
import UserAvatar from '../../../../../components/avatar/UserAvatar';
import { useIsCallReady } from '../../../../../contexts/CallContext';
import InfoPanel from '../../../../InfoPanel';
import AgentInfoDetails from '../../../components/AgentInfoDetails';
import AgentField from '../../chats/contextualBar/AgentField';
Expand All @@ -21,6 +22,7 @@ type VoipInfoPropsType = {

export const VoipInfo = ({ room, onClickClose /* , onClickReport */ }: VoipInfoPropsType): ReactElement => {
const t = useTranslation();
const isCallReady = useIsCallReady();

const { servedBy, queue, v, fname, name, callDuration, callTotalHoldTime, closedAt, callWaitingTime, tags, lastMessage } = room;
const duration = callDuration && moment.utc(callDuration).format('HH:mm:ss');
Expand Down Expand Up @@ -90,7 +92,7 @@ export const VoipInfo = ({ room, onClickClose /* , onClickReport */ }: VoipInfo
{t('Report_Number')}
</Box>
</Button> */}
<VoipInfoCallButton phoneNumber={phoneNumber} />
{isCallReady && <VoipInfoCallButton phoneNumber={phoneNumber} />}
</ButtonGroup>
</VerticalBar.Footer>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Icon, Box } from '@rocket.chat/fuselage';
import { Button, Icon } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import React, { ReactElement } from 'react';

Expand All @@ -11,17 +11,19 @@ export const VoipInfoCallButton = ({ phoneNumber, ...props }: { phoneNumber: str
const { openDialModal } = useDialModal();

const { outBoundCallsAllowed, outBoundCallsEnabledForUser } = useVoipOutboundStates();

return (
<Button
{...props} // this props are injected by ButtonGroup
onClick={(): void => openDialModal({ initialValue: phoneNumber })}
disabled={!outBoundCallsEnabledForUser}
disabled={!outBoundCallsEnabledForUser || !phoneNumber}
title={outBoundCallsAllowed ? t('Call_number') : t('Call_number_enterprise_only')}
display='flex'
justifyContent='center'
fontSize='p2'
>
<Box display='flex' justifyContent='center' fontSize='p2'>
<Icon name='phone' size='x20' mie='4px' />
{t('Call')}
</Box>
<Icon name='phone' size='x20' mie='4px' />
{t('Call')}
</Button>
);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Margins, ButtonGroup, Button, Icon } from '@rocket.chat/fuselage';
import { Box, Margins, ButtonGroup, Button, Icon, Divider } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useToastMessageDispatch, useCurrentRoute, useRoute, useTranslation } from '@rocket.chat/ui-contexts';
import React, { useEffect, useMemo, useState } from 'react';
Expand All @@ -8,6 +8,7 @@ import ContactManagerInfo from '../../../../../../ee/client/omnichannel/ContactM
import { UserStatus } from '../../../../../components/UserStatus';
import VerticalBar from '../../../../../components/VerticalBar';
import UserAvatar from '../../../../../components/avatar/UserAvatar';
import { useIsCallReady } from '../../../../../contexts/CallContext';
import { AsyncStatePhase } from '../../../../../hooks/useAsyncState';
import { useEndpointData } from '../../../../../hooks/useEndpointData';
import { useFormatDate } from '../../../../../hooks/useFormatDate';
Expand All @@ -17,6 +18,7 @@ import Field from '../../../components/Field';
import Info from '../../../components/Info';
import Label from '../../../components/Label';
import { FormSkeleton } from '../../Skeleton';
import { VoipInfoCallButton } from '../../calls/contextualBar/VoipInfoCallButton';

const ContactInfo = ({ id, rid, route }) => {
const t = useTranslation();
Expand All @@ -32,6 +34,8 @@ const ContactInfo = ({ id, rid, route }) => {

const canViewCustomFields = () => hasPermission('view-livechat-room-customfields');

const isCallReady = useIsCallReady();

const onEditButtonClick = useMutableCallback(() => {
if (!hasPermission('edit-omnichannel-contact')) {
return dispatchToastMessage({ type: 'error', message: t('Not_authorized') });
Expand Down Expand Up @@ -100,10 +104,12 @@ const ContactInfo = ({ id, rid, route }) => {
liveRoute.push({ id: _id, tab: 'contact-chat-history' });
};

const showContactHistory = currentRouteName === 'live';
const showContactHistory = currentRouteName === 'live' && lastChat;

const displayName = name || username;

const { phoneNumber } = phone?.[0] || {};

return (
<>
<VerticalBar.ScrollableContent p='x24'>
Expand All @@ -126,7 +132,7 @@ const ContactInfo = ({ id, rid, route }) => {
{phone && phone.length && (
<Field>
<Label>{t('Phone')}</Label>
<Info>{phone[0].phoneNumber}</Info>
<Info>{phoneNumber}</Info>
</Field>
)}
{ts && (
Expand Down Expand Up @@ -157,13 +163,20 @@ const ContactInfo = ({ id, rid, route }) => {
</Margins>
</VerticalBar.ScrollableContent>
<VerticalBar.Footer>
<ButtonGroup stretch>
{showContactHistory && lastChat && (
<Button onClick={onChatHistory}>
<ButtonGroup stretch flexWrap='wrap'>
{isCallReady && (
<>
<VoipInfoCallButton phoneNumber={phoneNumber} mi={0} flexBasis='0' />
{showContactHistory && <Divider width='100%' />}
</>
)}

{showContactHistory && (
<Button onClick={onChatHistory} mis={0} flexBasis='0'>
<Icon name='history' size='x20' /> {t('Chat_History')}
</Button>
)}
<Button onClick={onEditButtonClick}>
<Button onClick={onEditButtonClick} flexBasis='0'>
<Icon name='pencil' size='x20' /> {t('Edit')}
</Button>
</ButtonGroup>
Expand Down

0 comments on commit 3783ecf

Please sign in to comment.