diff --git a/.changeset/small-beers-call.md b/.changeset/small-beers-call.md new file mode 100644 index 000000000000..0e0f7414b8fc --- /dev/null +++ b/.changeset/small-beers-call.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Looking at the user's permission before rendering the 'Start Call' button on the UserInfo panel, so if the user does not have the permissions, the button does not show diff --git a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useCallAction.tsx b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useCallAction.tsx index 4889a50dbb7d..fa0fc46fe804 100644 --- a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useCallAction.tsx +++ b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useCallAction.tsx @@ -1,6 +1,6 @@ import type { IUser } from '@rocket.chat/core-typings'; import { isRoomFederated } from '@rocket.chat/core-typings'; -import { useTranslation, useUserRoom, useUserId, useUserSubscriptionByName } from '@rocket.chat/ui-contexts'; +import { useTranslation, useUserRoom, useUserId, useUserSubscriptionByName, useSetting, usePermission } from '@rocket.chat/ui-contexts'; import { useMemo } from 'react'; import { closeUserCard } from '../../../../../../app/ui/client/lib/userCard'; @@ -20,6 +20,9 @@ export const useCallAction = (user: Pick): UserInfoAc const isRinging = useVideoConfIsRinging(); const ownUserId = useUserId(); + const enabledForDMs = useSetting('VideoConf_Enable_DMs'); + const permittedToCallManagement = usePermission('call-management', room?._id); + const videoCallOption = useMemo(() => { const action = async (): Promise => { if (isCalling || isRinging || !room) { @@ -35,7 +38,10 @@ export const useCallAction = (user: Pick): UserInfoAc } }; - return room && !isRoomFederated(room) && user._id !== ownUserId + const shouldShowStartCall = + room && !isRoomFederated(room) && user._id !== ownUserId && enabledForDMs && permittedToCallManagement && !isCalling && !isRinging; + + return shouldShowStartCall ? { content: t('Start_call'), icon: 'phone' as const, @@ -43,7 +49,7 @@ export const useCallAction = (user: Pick): UserInfoAc type: 'communication' as UserInfoActionType, } : undefined; - }, [t, room, dispatchPopup, dispatchWarning, isCalling, isRinging, ownUserId, user._id]); + }, [room, user._id, ownUserId, enabledForDMs, permittedToCallManagement, isCalling, isRinging, t, dispatchPopup, dispatchWarning]); return videoCallOption; };