diff --git a/apps/meteor/client/hooks/roomActions/useStartCallRoomAction/useStartCallRoomAction.tsx b/apps/meteor/client/hooks/roomActions/useStartCallRoomAction/useStartCallRoomAction.tsx
index ee3117d664d1..18d3efd01053 100644
--- a/apps/meteor/client/hooks/roomActions/useStartCallRoomAction/useStartCallRoomAction.tsx
+++ b/apps/meteor/client/hooks/roomActions/useStartCallRoomAction/useStartCallRoomAction.tsx
@@ -7,8 +7,8 @@ import useVideoConfMenuOptions from './useVideoConfMenuOptions';
import useVoipMenuOptions from './useVoipMenuOptions';
export const useStartCallRoomAction = () => {
- const voipCall = useVideoConfMenuOptions();
- const videoCall = useVoipMenuOptions();
+ const videoCall = useVideoConfMenuOptions();
+ const voipCall = useVoipMenuOptions();
return useMemo((): RoomToolboxActionConfig | undefined => {
if (!videoCall.allowed && !voipCall.allowed) {
diff --git a/apps/meteor/client/views/admin/users/AdminUsersPage.tsx b/apps/meteor/client/views/admin/users/AdminUsersPage.tsx
index 14757e3710b0..afe881f64cc9 100644
--- a/apps/meteor/client/views/admin/users/AdminUsersPage.tsx
+++ b/apps/meteor/client/views/admin/users/AdminUsersPage.tsx
@@ -147,12 +147,12 @@ const AdminUsersPage = (): ReactElement => {
diff --git a/apps/meteor/client/views/admin/users/UsersPageHeaderContent.spec.tsx b/apps/meteor/client/views/admin/users/UsersPageHeaderContent.spec.tsx
index f4691eb4dd69..6181fe4fed50 100644
--- a/apps/meteor/client/views/admin/users/UsersPageHeaderContent.spec.tsx
+++ b/apps/meteor/client/views/admin/users/UsersPageHeaderContent.spec.tsx
@@ -5,12 +5,31 @@ import '@testing-library/jest-dom';
import UsersPageHeaderContent from './UsersPageHeaderContent';
-it('should render "Associate Extension" button when VoIP_TeamCollab_Enabled setting is enabled', async () => {
+it('should not show "Assign Extension" button if voip setting is enabled but user dont have required permission', async () => {
render(, {
legacyRoot: true,
wrapper: mockAppRoot().withJohnDoe().withSetting('VoIP_TeamCollab_Enabled', true).build(),
});
+ expect(screen.queryByRole('button', { name: 'Assign_extension' })).not.toBeInTheDocument();
+});
+
+it('should not show "Assign Extension" button if user has required permission but voip setting is disabled', async () => {
+ render(, {
+ legacyRoot: true,
+ wrapper: mockAppRoot().withJohnDoe().withSetting('VoIP_TeamCollab_Enabled', true).build(),
+ });
+
+ expect(screen.queryByRole('button', { name: 'Assign_extension' })).not.toBeInTheDocument();
+});
+
+it('should show "Assign Extension" button if user has required permission and voip setting is enabled', async () => {
+ render(, {
+ legacyRoot: true,
+ wrapper: mockAppRoot().withJohnDoe().withSetting('VoIP_TeamCollab_Enabled', true).withPermission('manage-voip-extensions').build(),
+ });
+
+ expect(screen.getByRole('button', { name: 'Assign_extension' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Assign_extension' })).toBeEnabled();
});
diff --git a/apps/meteor/client/views/admin/users/UsersPageHeaderContent.tsx b/apps/meteor/client/views/admin/users/UsersPageHeaderContent.tsx
index e6794a9f98f6..89916c3e6f2e 100644
--- a/apps/meteor/client/views/admin/users/UsersPageHeaderContent.tsx
+++ b/apps/meteor/client/views/admin/users/UsersPageHeaderContent.tsx
@@ -1,5 +1,5 @@
import { Button, ButtonGroup, Margins } from '@rocket.chat/fuselage';
-import { usePermission, useRouter, useSetModal, useSetting } from '@rocket.chat/ui-contexts';
+import { usePermission, useRouter } from '@rocket.chat/ui-contexts';
import React from 'react';
import { useTranslation } from 'react-i18next';
@@ -7,7 +7,8 @@ import { useExternalLink } from '../../../hooks/useExternalLink';
import { useCheckoutUrl } from '../subscription/hooks/useCheckoutUrl';
import SeatsCapUsage from './SeatsCapUsage';
import type { SeatCapProps } from './useSeatsCap';
-import AssignExtensionModal from './voip/AssignExtensionModal';
+import AssignExtensionButton from './voip/AssignExtensionButton';
+import { useVoipExtensionPermission } from './voip/hooks/useVoipExtensionPermission';
type UsersPageHeaderContentProps = {
isSeatsCapExceeded: boolean;
@@ -17,10 +18,9 @@ type UsersPageHeaderContentProps = {
const UsersPageHeaderContent = ({ isSeatsCapExceeded, seatsCap }: UsersPageHeaderContentProps) => {
const { t } = useTranslation();
const router = useRouter();
- const setModal = useSetModal();
const canCreateUser = usePermission('create-user');
const canBulkCreateUser = usePermission('bulk-register-user');
- const canRegisterExtension = useSetting('VoIP_TeamCollab_Enabled');
+ const canManageVoipExtension = useVoipExtensionPermission();
const manageSubscriptionUrl = useCheckoutUrl()({ target: 'user-page', action: 'buy_more' });
const openExternalLink = useExternalLink();
@@ -41,11 +41,7 @@ const UsersPageHeaderContent = ({ isSeatsCapExceeded, seatsCap }: UsersPageHeade
)}
- {canRegisterExtension && (
-
- )}
+ {canManageVoipExtension && }
{canBulkCreateUser && (