From 3783ecf501f75225a37a55466ca114e9261268d7 Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 6 Jul 2022 13:14:36 -0300 Subject: [PATCH] Regression: Added missing call button in the contact info contextual bar (#26135) --- .../calls/contextualBar/VoipInfo.tsx | 4 ++- .../contextualBar/VoipInfoCallButton.tsx | 14 +++++----- .../contacts/contextualBar/ContactInfo.js | 27 ++++++++++++++----- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/apps/meteor/client/views/omnichannel/directory/calls/contextualBar/VoipInfo.tsx b/apps/meteor/client/views/omnichannel/directory/calls/contextualBar/VoipInfo.tsx index 6654606f6fca..33c9e2559a2d 100644 --- a/apps/meteor/client/views/omnichannel/directory/calls/contextualBar/VoipInfo.tsx +++ b/apps/meteor/client/views/omnichannel/directory/calls/contextualBar/VoipInfo.tsx @@ -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'; @@ -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'); @@ -90,7 +92,7 @@ export const VoipInfo = ({ room, onClickClose /* , onClickReport */ }: VoipInfo {t('Report_Number')} */} - + {isCallReady && } diff --git a/apps/meteor/client/views/omnichannel/directory/calls/contextualBar/VoipInfoCallButton.tsx b/apps/meteor/client/views/omnichannel/directory/calls/contextualBar/VoipInfoCallButton.tsx index 54c94d87c5b7..c3f126485802 100644 --- a/apps/meteor/client/views/omnichannel/directory/calls/contextualBar/VoipInfoCallButton.tsx +++ b/apps/meteor/client/views/omnichannel/directory/calls/contextualBar/VoipInfoCallButton.tsx @@ -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'; @@ -11,17 +11,19 @@ export const VoipInfoCallButton = ({ phoneNumber, ...props }: { phoneNumber: str const { openDialModal } = useDialModal(); const { outBoundCallsAllowed, outBoundCallsEnabledForUser } = useVoipOutboundStates(); + return ( ); }; diff --git a/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactInfo.js b/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactInfo.js index 7a8abde93a1d..90e9efb39209 100644 --- a/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactInfo.js +++ b/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactInfo.js @@ -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'; @@ -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'; @@ -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(); @@ -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') }); @@ -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 ( <> @@ -126,7 +132,7 @@ const ContactInfo = ({ id, rid, route }) => { {phone && phone.length && ( - {phone[0].phoneNumber} + {phoneNumber} )} {ts && ( @@ -157,13 +163,20 @@ const ContactInfo = ({ id, rid, route }) => { - - {showContactHistory && lastChat && ( - )} -