-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Voip for Team Collaboration (#33346)
Co-authored-by: Aleksander Nicacio da Silva <6494543+aleksandernsilva@users.noreply.github.com>
- Loading branch information
1 parent
662aca3
commit bcacbb1
Showing
199 changed files
with
8,996 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
'@rocket.chat/freeswitch': major | ||
'@rocket.chat/mock-providers': patch | ||
'@rocket.chat/core-services': patch | ||
'@rocket.chat/model-typings': patch | ||
'@rocket.chat/core-typings': patch | ||
'@rocket.chat/rest-typings': patch | ||
'@rocket.chat/ui-client': patch | ||
'@rocket.chat/ui-voip': patch | ||
'@rocket.chat/i18n': patch | ||
'@rocket.chat/meteor': patch | ||
--- | ||
|
||
Implements integration with FreeSwitch to enable VoIP calls for team collaboration workspaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
apps/meteor/client/NavBarV2/NavBarSettingsToolbar/UserMenu/hooks/useVoipItems.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import type { GenericMenuItemProps } from '@rocket.chat/ui-client'; | ||
import { useToastMessageDispatch } from '@rocket.chat/ui-contexts'; | ||
import { useVoipAPI, useVoipState } from '@rocket.chat/ui-voip'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import React, { useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
export const useVoipItems = (): GenericMenuItemProps[] => { | ||
const { t } = useTranslation(); | ||
const dispatchToastMessage = useToastMessageDispatch(); | ||
|
||
const { clientError, isEnabled, isReady, isRegistered } = useVoipState(); | ||
const { register, unregister } = useVoipAPI(); | ||
|
||
const toggleVoip = useMutation({ | ||
mutationFn: async () => { | ||
if (!isRegistered) { | ||
await register(); | ||
return true; | ||
} | ||
|
||
await unregister(); | ||
return false; | ||
}, | ||
onSuccess: (isEnabled: boolean) => { | ||
dispatchToastMessage({ | ||
type: 'success', | ||
message: isEnabled ? t('Voice_calling_enabled') : t('Voice_calling_disabled'), | ||
}); | ||
}, | ||
}); | ||
|
||
const tooltip = useMemo(() => { | ||
if (clientError) { | ||
return t(clientError.message); | ||
} | ||
|
||
if (!isReady || toggleVoip.isLoading) { | ||
return t('Loading'); | ||
} | ||
|
||
return ''; | ||
}, [clientError, isReady, toggleVoip.isLoading, t]); | ||
|
||
return useMemo(() => { | ||
if (!isEnabled) { | ||
return []; | ||
} | ||
|
||
return [ | ||
{ | ||
id: 'toggle-voip', | ||
icon: isRegistered ? 'phone-disabled' : 'phone', | ||
disabled: !isReady || toggleVoip.isLoading, | ||
onClick: () => toggleVoip.mutate(), | ||
content: ( | ||
<Box is='span' title={tooltip}> | ||
{isRegistered ? t('Disable_voice_calling') : t('Enable_voice_calling')} | ||
</Box> | ||
), | ||
}, | ||
]; | ||
}, [isEnabled, isRegistered, isReady, tooltip, t, toggleVoip]); | ||
}; | ||
|
||
export default useVoipItems; |
48 changes: 48 additions & 0 deletions
48
apps/meteor/client/NavBarV2/NavBarVoipToolbar/NavBarItemVoipDialer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { NavBarItem } from '@rocket.chat/fuselage'; | ||
import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; | ||
import { useLayout } from '@rocket.chat/ui-contexts'; | ||
import { useVoipDialer, useVoipState } from '@rocket.chat/ui-voip'; | ||
import type { HTMLAttributes } from 'react'; | ||
import React, { useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
type NavBarItemVoipDialerProps = Omit<HTMLAttributes<HTMLElement>, 'is'> & { | ||
primary?: boolean; | ||
}; | ||
|
||
const NavBarItemVoipDialer = (props: NavBarItemVoipDialerProps) => { | ||
const { t } = useTranslation(); | ||
const { sidebar } = useLayout(); | ||
const { clientError, isEnabled, isReady, isRegistered } = useVoipState(); | ||
const { open: isDialerOpen, openDialer, closeDialer } = useVoipDialer(); | ||
|
||
const handleToggleDialer = useEffectEvent(() => { | ||
sidebar.toggle(); | ||
isDialerOpen ? closeDialer() : openDialer(); | ||
}); | ||
|
||
const title = useMemo(() => { | ||
if (!isReady && !clientError) { | ||
return t('Loading'); | ||
} | ||
|
||
if (!isRegistered || clientError) { | ||
return t('Voice_calling_disabled'); | ||
} | ||
|
||
return t('New_Call'); | ||
}, [clientError, isReady, isRegistered, t]); | ||
|
||
return isEnabled ? ( | ||
<NavBarItem | ||
{...props} | ||
title={title} | ||
icon='phone' | ||
onClick={handleToggleDialer} | ||
pressed={isDialerOpen} | ||
disabled={!isReady || !isRegistered} | ||
/> | ||
) : null; | ||
}; | ||
|
||
export default NavBarItemVoipDialer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as NavBarItemVoipDialer } from './NavBarItemVoipDialer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
apps/meteor/client/hooks/roomActions/useStartCallRoomAction/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './useStartCallRoomAction'; |
Oops, something went wrong.