Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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,28 +1,21 @@
import { NavBarItem } from '@rocket.chat/fuselage';
import type { GenericMenuItemProps } from '@rocket.chat/ui-client';
import { GenericMenu } from '@rocket.chat/ui-client';
import { useVoipState } from '@rocket.chat/ui-voip';
import type { HTMLAttributes } from 'react';
import { useTranslation } from 'react-i18next';

import { useOmnichannelEnabled } from '../../hooks/omnichannel/useOmnichannelEnabled';

type NavBarControlsMenuProps = Omit<HTMLAttributes<HTMLElement>, 'is'> & {
voipItems: GenericMenuItemProps[];
omnichannelItems: GenericMenuItemProps[];
isPressed: boolean;
};

const NavBarControlsMenu = ({ voipItems, omnichannelItems, isPressed, ...props }: NavBarControlsMenuProps) => {
const NavBarControlsMenu = ({ omnichannelItems, isPressed, ...props }: NavBarControlsMenuProps) => {
const { t } = useTranslation();
const { isEnabled: showVoip } = useVoipState();
const showOmnichannel = useOmnichannelEnabled();

const sections = [
{
title: t('Voice_Call'),
items: showVoip ? voipItems : [],
},
{
title: t('Omnichannel'),
items: showOmnichannel ? omnichannelItems : [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import { useOmnichannelCallDialPadAction } from '../NavBarOmnichannelGroup/hooks
import { useOmnichannelCallToggleAction } from '../NavBarOmnichannelGroup/hooks/useOmnichannelCallToggleAction';

type NavBarControlsMenuProps = Omit<HTMLAttributes<HTMLElement>, 'is'> & {
voipItems: GenericMenuItemProps[];
omnichannelItems: GenericMenuItemProps[];
isPressed: boolean;
};

const NavBarControlsWithCall = ({ voipItems, omnichannelItems, isPressed, ...props }: NavBarControlsMenuProps) => {
const NavBarControlsWithCall = ({ omnichannelItems, isPressed, ...props }: NavBarControlsMenuProps) => {
const {
icon: omnichannelCallIcon,
title: omnichannelCallTitle,
Expand Down Expand Up @@ -44,7 +43,7 @@ const NavBarControlsWithCall = ({ voipItems, omnichannelItems, isPressed, ...pro
},
] as GenericMenuItemProps[];

return <NavBarControlsMenu voipItems={voipItems} omnichannelItems={omnichannelItemsWithCall} isPressed={isPressed} {...props} />;
return <NavBarControlsMenu omnichannelItems={omnichannelItemsWithCall} isPressed={isPressed} {...props} />;
};

export default NavBarControlsWithCall;
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ import { useIsCallEnabled } from '../../contexts/CallContext';
import { useOmnichannelContactAction } from '../NavBarOmnichannelGroup/hooks/useOmnichannelContactAction';
import { useOmnichannelLivechatToggle } from '../NavBarOmnichannelGroup/hooks/useOmnichannelLivechatToggle';
import { useOmnichannelQueueAction } from '../NavBarOmnichannelGroup/hooks/useOmnichannelQueueAction';
import { useVoipDialerAction } from '../NavBarVoipGroup/hooks/useVoipDialerAction';
import { useVoipTogglerAction } from '../NavBarVoipGroup/hooks/useVoipTogglerAction';

type NavBarControlsMenuProps = Omit<HTMLAttributes<HTMLElement>, 'is'>;

const NavBarControlsWithData = (props: NavBarControlsMenuProps) => {
const isCallEnabled = useIsCallEnabled();

const { title: dialerTitle, handleToggleDialer, isPressed: isVoipDialerPressed, isDisabled: dialerDisabled } = useVoipDialerAction();
const { isRegistered, title: togglerTitle, handleToggleVoip, isDisabled: togglerDisabled } = useVoipTogglerAction();

const {
isEnabled: queueEnabled,
icon: queueIcon,
Expand All @@ -39,30 +34,12 @@ const NavBarControlsWithData = (props: NavBarControlsMenuProps) => {
handleAvailableStatusChange,
} = useOmnichannelLivechatToggle();

const voipItems = [
{
id: 'voipDialer',
icon: 'dialpad',
content: dialerTitle,
onClick: handleToggleDialer,
disabled: dialerDisabled,
},
{
id: 'voipToggler',
icon: isRegistered ? 'phone-disabled' : 'phone',
content: togglerTitle,
onClick: handleToggleVoip,
disabled: togglerDisabled,
},
].filter(Boolean) as GenericMenuItemProps[];

const omnichannelItems = [
queueEnabled && {
id: 'omnichannelQueue',
icon: queueIcon,
content: queueTitle,
onClick: handleGoToQueue,
disabled: dialerDisabled,
},
{
id: 'omnichannelContact',
Expand All @@ -78,13 +55,13 @@ const NavBarControlsWithData = (props: NavBarControlsMenuProps) => {
},
].filter(Boolean) as GenericMenuItemProps[];

const isPressed = isVoipDialerPressed || isQueuePressed || isContactPressed;
const isPressed = isQueuePressed || isContactPressed;

if (isCallEnabled) {
return <NavbarControlsWithCall voipItems={voipItems} omnichannelItems={omnichannelItems} isPressed={isPressed} {...props} />;
return <NavbarControlsWithCall omnichannelItems={omnichannelItems} isPressed={isPressed} {...props} />;
}

return <NavBarControlsMenu voipItems={voipItems} omnichannelItems={omnichannelItems} isPressed={isPressed} {...props} />;
return <NavBarControlsMenu omnichannelItems={omnichannelItems} isPressed={isPressed} {...props} />;
};

export default NavBarControlsWithData;

This file was deleted.

This file was deleted.

This file was deleted.

78 changes: 0 additions & 78 deletions apps/meteor/client/hooks/roomActions/useVoiceCallRoomAction.tsx

This file was deleted.

75 changes: 0 additions & 75 deletions apps/meteor/client/sidebar/header/hooks/useVoipItemsSection.tsx

This file was deleted.

Loading
Loading