Skip to content

Commit c638a09

Browse files
authored
Hide buttons based on role in Rooms call (#2944)
* Hide Camera, Microphone, and Screenshare buttons in rooms calls depending on role * Change files * Duplicate change files for beta release
1 parent b716bd4 commit c638a09

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Hide Camera, Microphone, and Screenshare buttons in rooms calls depending on role",
4+
"packageName": "@azure/communication-react",
5+
"email": "79475487+mgamis-msft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Hide Camera, Microphone, and Screenshare buttons in rooms calls depending on role",
4+
"packageName": "@azure/communication-react",
5+
"email": "79475487+mgamis-msft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-composites/src/composites/common/ControlBar/CommonCallControlBar.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { ChatAdapter } from '../../ChatComposite';
1313
import { ChatButtonWithUnreadMessagesBadge } from '../../CallWithChatComposite/ChatButtonWithUnreadMessagesBadge';
1414
import { BaseCustomStyles, ControlBarButtonStyles } from '@internal/react-components';
1515
import { ControlBar } from '@internal/react-components';
16+
/* @conditional-compile-remove(rooms) */
17+
import { _usePermissions } from '@internal/react-components';
1618
import { Microphone } from '../../CallComposite/components/buttons/Microphone';
1719
import { Camera } from '../../CallComposite/components/buttons/Camera';
1820
import { ScreenShare } from '../../CallComposite/components/buttons/ScreenShare';
@@ -234,6 +236,21 @@ export const CommonCallControlBar = (props: CommonCallControlBarProps & Containe
234236
<></>
235237
);
236238

239+
/* @conditional-compile-remove(rooms) */
240+
const rolePermissions = _usePermissions();
241+
242+
let screenShareButtonIsEnabled = isEnabled(options?.screenShareButton);
243+
/* @conditional-compile-remove(rooms) */
244+
screenShareButtonIsEnabled = rolePermissions.screenShare && screenShareButtonIsEnabled;
245+
246+
let microphoneButtonIsEnabled = isEnabled(options?.microphoneButton);
247+
/* @conditional-compile-remove(rooms) */
248+
microphoneButtonIsEnabled = rolePermissions.microphoneButton && microphoneButtonIsEnabled;
249+
250+
let cameraButtonIsEnabled = isEnabled(options?.cameraButton);
251+
/* @conditional-compile-remove(rooms) */
252+
cameraButtonIsEnabled = rolePermissions.cameraButton && cameraButtonIsEnabled;
253+
237254
return (
238255
<div ref={controlBarSizeRef}>
239256
<CallAdapterProvider adapter={props.callAdapter}>
@@ -275,7 +292,7 @@ export const CommonCallControlBar = (props: CommonCallControlBarProps & Containe
275292
*/}
276293
<div ref={controlBarContainerRef}>
277294
<ControlBar layout="horizontal" styles={centerContainerStyles}>
278-
{isEnabled(options.microphoneButton) && (
295+
{microphoneButtonIsEnabled && (
279296
<Microphone
280297
displayType={options.displayType}
281298
styles={commonButtonStyles}
@@ -284,7 +301,7 @@ export const CommonCallControlBar = (props: CommonCallControlBarProps & Containe
284301
disabled={props.disableButtonsForHoldScreen || isDisabled(options.microphoneButton)}
285302
/>
286303
)}
287-
{isEnabled(options.cameraButton) && (
304+
{cameraButtonIsEnabled && (
288305
<Camera
289306
displayType={options.displayType}
290307
styles={commonButtonStyles}
@@ -296,7 +313,7 @@ export const CommonCallControlBar = (props: CommonCallControlBarProps & Containe
296313
/>
297314
)}
298315
{props.mobileView && isEnabled(options?.chatButton) && chatButton}
299-
{isEnabled(options.screenShareButton) && (
316+
{screenShareButtonIsEnabled && (
300317
<ScreenShare
301318
option={options.screenShareButton}
302319
displayType={options.displayType}

0 commit comments

Comments
 (0)