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

Regression: Parse outbound phone number removing * putting + char #26154

Merged
merged 8 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import type { IRoom } from '@rocket.chat/core-typings';
import type { IVoipRoom } from '@rocket.chat/core-typings';
import { Avatar, Box, Tag } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import React, { ReactElement } from 'react';

import { getUserAvatarURL } from '../../../../app/utils/client';
import { parseOutboundPhoneNumber } from '../../../../ee/client/lib/voip/parseOutboundPhoneNumber';

export const VoipRoomForeword = ({ room }: { room: IRoom }): ReactElement => {
export const VoipRoomForeword = ({ room }: { room: IVoipRoom }): ReactElement => {
const t = useTranslation();

const avatarUrl = getUserAvatarURL(room.name || room.fname);

const roomName = room.name || room.fname;

return (
tiagoevanp marked this conversation as resolved.
Show resolved Hide resolved
<Box is='div' flexGrow={1} display='flex' justifyContent='center' flexDirection='column'>
<Box display='flex' justifyContent='center' mbs='x24'>
Expand All @@ -21,7 +24,7 @@ export const VoipRoomForeword = ({ room }: { room: IRoom }): ReactElement => {
<Box is='div' mb='x8' flexGrow={1} display='flex' justifyContent='center'>
<Box mi='x4'>
<Tag style={{ cursor: 'default' }} variant='primary' medium>
{room.name || room.fname}
{roomName && parseOutboundPhoneNumber(roomName)}
</Tag>
</Box>
</Box>
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/client/sidebar/footer/voip/VoipFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Box, Button, ButtonGroup, Icon, SidebarFooter, Menu, IconButton } from
import React, { ReactElement, MouseEvent, ReactNode } from 'react';

import { useVoipFooterMenu } from '../../../../ee/client/hooks/useVoipFooterMenu';
import { parseOutboundPhoneNumber } from '../../../../ee/client/lib/voip/parseOutboundPhoneNumber';
import { CallActionsType } from '../../../contexts/CallContext';

type VoipFooterPropsType = {
Expand Down Expand Up @@ -118,7 +119,7 @@ export const VoipFooter = ({
<Box display='flex' flexDirection='row' mi='16px' mbe='12px' justifyContent='space-between' alignItems='center'>
<Box>
<Box color='white' fontScale='p2' withTruncatedText>
{caller.callerName || caller.callerId || anonymousText}
{caller.callerName || parseOutboundPhoneNumber(caller.callerId) || anonymousText}
</Box>
<Box color='hint' fontScale='c1' withTruncatedText>
{subtitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Meteor } from 'meteor/meteor';
import moment from 'moment';
import React, { useState, useMemo, useCallback, FC } from 'react';

import { parseOutboundPhoneNumber } from '../../../../../ee/client/lib/voip/parseOutboundPhoneNumber';
import GenericTable from '../../../../components/GenericTable';
import { useEndpointData } from '../../../../hooks/useEndpointData';

Expand Down Expand Up @@ -147,8 +148,10 @@ const CallTable: FC = () => {
const duration = moment.duration(callDuration / 1000, 'seconds');
return (
<Table.Row key={_id} tabIndex={0} role='link' onClick={(): void => onRowClick(_id, v?.token)} action qa-user-id={_id}>
<Table.Cell withTruncatedText>{fname}</Table.Cell>
<Table.Cell withTruncatedText>{Array.isArray(v?.phone) ? v?.phone[0]?.phoneNumber : v?.phone}</Table.Cell>
<Table.Cell withTruncatedText>{parseOutboundPhoneNumber(fname)}</Table.Cell>
tiagoevanp marked this conversation as resolved.
Show resolved Hide resolved
<Table.Cell withTruncatedText>
{Array.isArray(v?.phone) ? parseOutboundPhoneNumber(v?.phone[0]?.phoneNumber) : parseOutboundPhoneNumber(v?.phone)}
</Table.Cell>
<Table.Cell withTruncatedText>{queue}</Table.Cell>
<Table.Cell withTruncatedText>{moment(callStarted).format('L LTS')}</Table.Cell>
<Table.Cell withTruncatedText>{duration.isValid() && duration.humanize()}</Table.Cell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTranslation } from '@rocket.chat/ui-contexts';
import moment from 'moment';
import React, { ReactElement, useMemo } from 'react';

import { parseOutboundPhoneNumber } from '../../../../../../ee/client/lib/voip/parseOutboundPhoneNumber';
import { UserStatus } from '../../../../../components/UserStatus';
import VerticalBar from '../../../../../components/VerticalBar';
import UserAvatar from '../../../../../components/avatar/UserAvatar';
Expand Down Expand Up @@ -56,11 +57,11 @@ export const VoipInfo = ({ room, onClickClose /* , onClickReport */ }: VoipInfo
<InfoPanel.Label>{t('Contact')}</InfoPanel.Label>
<Box display='flex'>
<UserAvatar size='x28' username={_name} />
<AgentInfoDetails mis='x8' name={_name} status={<UserStatus status={v?.status} />} />
<AgentInfoDetails mis='x8' name={parseOutboundPhoneNumber(_name)} status={<UserStatus status={v?.status} />} />
</Box>
</InfoPanel.Field>
)}
{phoneNumber && <InfoField label={t('Caller_Id')} info={phoneNumber} />}
{phoneNumber && <InfoField label={t('Caller_Id')} info={parseOutboundPhoneNumber(phoneNumber)} />}
{queue && <InfoField label={t('Queue')} info={queue} />}
{endedAt && <InfoField label={t('Last_Call')} info={endedAt} />}
<InfoField label={t('Waiting_Time')} info={waiting || t('Not_Available')} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useDebouncedState, useDebouncedValue, useMutableCallback } from '@rocke
import { useRoute, useTranslation } from '@rocket.chat/ui-contexts';
import React, { useMemo, useEffect, ReactElement } from 'react';

import { parseOutboundPhoneNumber } from '../../../../../ee/client/lib/voip/parseOutboundPhoneNumber';
import FilterByText from '../../../../components/FilterByText';
import {
GenericTable,
Expand Down Expand Up @@ -145,8 +146,8 @@ function ContactTable({ setContactReload }: ContactTableProps): ReactElement {
height='40px'
>
<GenericTableCell withTruncatedText>{username}</GenericTableCell>
<GenericTableCell withTruncatedText>{name}</GenericTableCell>
<GenericTableCell withTruncatedText>{phoneNumber}</GenericTableCell>
<GenericTableCell withTruncatedText>{parseOutboundPhoneNumber(name)}</GenericTableCell>
<GenericTableCell withTruncatedText>{parseOutboundPhoneNumber(phoneNumber)}</GenericTableCell>
<GenericTableCell withTruncatedText>{visitorEmail}</GenericTableCell>
<GenericTableCell withTruncatedText>{lastChat && formatDate(lastChat.ts)}</GenericTableCell>
<GenericTableCell>{isCallReady && <ContactTableDialpadButton phoneNumber={phoneNumber} />}</GenericTableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useToastMessageDispatch, useCurrentRoute, useRoute, useTranslation } fr
import React, { useEffect, useMemo, useState } from 'react';

import { hasPermission } from '../../../../../../app/authorization/client';
import { parseOutboundPhoneNumber } from '../../../../../../ee/client/lib/voip/parseOutboundPhoneNumber';
import ContactManagerInfo from '../../../../../../ee/client/omnichannel/ContactManagerInfo';
import { UserStatus } from '../../../../../components/UserStatus';
import VerticalBar from '../../../../../components/VerticalBar';
Expand Down Expand Up @@ -106,7 +107,7 @@ const ContactInfo = ({ id, rid, route }) => {

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

const displayName = name || username;
const displayName = parseOutboundPhoneNumber(name) || username;

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

Expand All @@ -132,7 +133,7 @@ const ContactInfo = ({ id, rid, route }) => {
{phone && phone.length && (
<Field>
<Label>{t('Phone')}</Label>
<Info>{phoneNumber}</Info>
<Info>{parseOutboundPhoneNumber(phoneNumber)}</Info>
</Field>
)}
{ts && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { IVoipRoom } from '@rocket.chat/core-typings';
import { useLayout, useCurrentRoute } from '@rocket.chat/ui-contexts';
import React, { FC, useMemo } from 'react';

import { parseOutboundPhoneNumber } from '../../../../../ee/client/lib/voip/parseOutboundPhoneNumber';
import BurgerMenu from '../../../../components/BurgerMenu';
import TemplateHeader from '../../../../components/Header';
import { ToolboxActionConfig } from '../../lib/Toolbox';
import { ToolboxContext, useToolboxContext } from '../../lib/Toolbox/ToolboxContext';
import RoomHeader, { RoomHeaderProps } from '../RoomHeader';
import { BackButton } from './BackButton';

const VoipRoomHeader: FC<RoomHeaderProps> = ({ slots: parentSlot, room }) => {
export type VoipRoomHeaderProps = {
room: IVoipRoom;
} & Omit<RoomHeaderProps, 'room'>;

const VoipRoomHeader: FC<VoipRoomHeaderProps> = ({ slots: parentSlot, room }) => {
const [name] = useCurrentRoute();
const { isMobile } = useLayout();
const context = useToolboxContext();
Expand All @@ -35,7 +41,7 @@ const VoipRoomHeader: FC<RoomHeaderProps> = ({ slots: parentSlot, room }) => {
[context],
)}
>
<RoomHeader slots={slots} room={room} />
<RoomHeader slots={slots} room={{ ...room, name: parseOutboundPhoneNumber(room.name) }} />
</ToolboxContext.Provider>
);
};
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/ee/client/lib/voip/parseOutboundPhoneNumber.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const parseOutboundPhoneNumber = (phoneNumber: string): string => phoneNumber.replace(/\*/g, '+');
1 change: 1 addition & 0 deletions packages/core-typings/src/IRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export interface IOmnichannelRoom extends IOmnichannelGenericRoom {

export interface IVoipRoom extends IOmnichannelGenericRoom {
t: 'v';
name: string;
tiagoevanp marked this conversation as resolved.
Show resolved Hide resolved
// The timestamp when call was started
callStarted: Date;
// The amount of time the call lasted, in milliseconds
Expand Down