-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathMoreDrawer.tsx
More file actions
751 lines (691 loc) · 26.9 KB
/
MoreDrawer.tsx
File metadata and controls
751 lines (691 loc) · 26.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import React, { useCallback } from 'react';
import { useState } from 'react';
import { useMemo } from 'react';
import {
OptionsDevice,
_DrawerMenu as DrawerMenu,
_DrawerMenuItemProps as DrawerMenuItemProps,
_DrawerMenuStyles,
SpokenLanguageStrings,
CaptionLanguageStrings,
CaptionsSettingsModal
} from '@internal/react-components';
import { CaptionsBanner } from '@internal/react-components';
import { _ReactionDrawerMenuItem } from '@internal/react-components';
import { ReactionResources } from '@internal/react-components';
import { VideoGalleryLayout } from '@internal/react-components';
import { StartCaptionsButton } from '@internal/react-components';
import { HoldButton } from '@internal/react-components';
import { RaiseHandButton, RaiseHandButtonProps } from '@internal/react-components';
import { AudioDeviceInfo } from '@azure/communication-calling';
import {
CUSTOM_BUTTON_OPTIONS,
generateCustomCallDrawerButtons,
onFetchCustomButtonPropsTrampoline
} from '../ControlBar/CustomButton';
import { usePropsFor } from '../../CallComposite/hooks/usePropsFor';
import { useLocale } from '../../localization';
import { isDisabled } from '../../CallComposite/utils';
import { CommonCallControlOptions } from '../types/CommonCallControlOptions';
import { Stack, Toggle, useTheme } from '@fluentui/react';
import { _pxToRem } from '@internal/acs-ui-common';
import { CaptionLanguageSettingsDrawer } from './CaptionLanguageSettingsDrawer';
import { themedToggleButtonStyle } from './MoreDrawer.styles';
import { _spokenLanguageToCaptionLanguage } from '@internal/react-components';
import { useAdapter } from '../../CallComposite/adapter/CallAdapterProvider';
import { useSelector } from '../../CallComposite/hooks/useSelector';
import { getTargetCallees } from '../../CallComposite/selectors/baseSelectors';
import { getTeamsMeetingCoordinates, getIsTeamsMeeting } from '../../CallComposite/selectors/baseSelectors';
import { showDtmfDialer } from '../../CallComposite/utils/MediaGalleryUtils';
import { SpokenLanguageSettingsDrawer } from './SpokenLanguageSettingsDrawer';
import { DtmfDialPadOptions } from '../../CallComposite';
import { getRemoteParticipantsConnectedSelector } from '../../CallComposite/selectors/mediaGallerySelector';
/* @conditional-compile-remove(together-mode) */
import {
getCapabilites,
getIsTogetherModeActive,
getLocalUserId,
getIsTeamsCall
} from '../../CallComposite/selectors/baseSelectors';
import { CallingRealTimeTextModal } from '../CallingRealTimeTextModal';
/** @private */
export interface MoreDrawerStrings {
/**
* Label for people drawerMenuItem.
*/
peopleButtonLabel: string;
/**
* Label for audio device drawerMenuItem.
*
* @remarks This replaces the microphoneMenuTitle speakers can not be enumerated
*
*/
audioDeviceMenuTitle?: string;
/**
* Label for microphone drawerMenuItem.
*
* @remarks Only displayed when speakers can be enumerated otherwise audioDeviceMenuTitle is used
*
*/
microphoneMenuTitle: string;
/**
* Label for speaker drawerMenuItem.
*
* @remarks Only displayed when speakers can be enumerated
*
*/
speakerMenuTitle: string;
/**
* Label for captions drawerMenuItem
*
* @remarks Only displayed when in Teams call
*/
captionsMenuTitle: string;
/**
* Label for spokenLanguage drawerMenuItem
*
* @remarks Only displayed when in Teams call, disabled until captions is on
*/
spokenLanguageMenuTitle: string;
/**
* Label for captionLanguage drawerMenuItem
*
* @remarks Only displayed when in Teams call, disabled until captions is on
*/
captionLanguageMenuTitle: string;
/**
* Label for gallery options drawerMenuItem
*/
galleryOptionsMenuTitle: string;
}
/** @private */
export interface MoreDrawerDevicesMenuProps {
/**
* Available microphones for selection
*/
microphones?: OptionsDevice[];
/**
* Available speakers for selection
*/
speakers?: OptionsDevice[];
/**
* Microphone that is shown as currently selected
*/
selectedMicrophone?: OptionsDevice;
/**
* Speaker that is shown as currently selected
*/
selectedSpeaker?: OptionsDevice;
/**
* Speaker when a speaker is selected
*/
onSelectSpeaker: (device: AudioDeviceInfo) => Promise<void>;
/**
* Callback when a microphone is selected
*/
onSelectMicrophone: (device: AudioDeviceInfo) => Promise<void>;
userSetGalleryLayout?: VideoGalleryLayout;
/**
* Callback for when the gallery layout is changed
*/
onUserSetGalleryLayout?: (layout: VideoGalleryLayout) => void;
/**
* Callback to hide and show the dialpad in the more drawer
*/
onSetDialpadPage?: () => void;
/**
* Whether the dialpad is present in the call
*/
dtmfDialerPresent?: boolean;
/**
* options for the controls of the DTMF dialer
*/
dtmfDialerOptions?: boolean | DtmfDialPadOptions;
}
/** @private */
export interface MoreDrawerProps extends MoreDrawerDevicesMenuProps {
onLightDismiss: () => void;
onPeopleButtonClicked: () => void;
callControls?: boolean | CommonCallControlOptions;
onClickShowDialpad?: () => void;
isCaptionsSupported?: boolean;
isRealTimeTextSupported?: boolean;
strings: MoreDrawerStrings;
disableButtonsForHoldScreen?: boolean;
useTeamsCaptions?: boolean;
reactionResources?: ReactionResources;
onReactionClick?: (reaction: string) => Promise<void>;
onClickMeetingPhoneInfo?: () => void;
onMuteAllRemoteParticipants?: () => void;
onForbidOthersAudio?: () => void;
onPermitOthersAudio?: () => void;
onForbidOthersVideo?: () => void;
onPermitOthersVideo?: () => void;
onStartRealTimeText?: () => void;
startRealTimeTextButtonChecked?: boolean;
}
const inferCallWithChatControlOptions = (
callWithChatControls?: boolean | CommonCallControlOptions
): CommonCallControlOptions | false => {
if (callWithChatControls === false) {
return false;
}
const options = callWithChatControls === true || callWithChatControls === undefined ? {} : callWithChatControls;
return options;
};
/** @private */
export const MoreDrawer = (props: MoreDrawerProps): JSX.Element => {
const theme = useTheme();
const callAdapter = useAdapter();
const drawerMenuItems: DrawerMenuItemProps[] = [];
const { speakers, onSelectSpeaker, onLightDismiss } = props;
const localeStrings = useLocale();
const holdButtonProps = usePropsFor(HoldButton);
const realTimeTextProps = usePropsFor(CaptionsBanner);
const callees = useSelector(getTargetCallees);
const participants = useSelector(getRemoteParticipantsConnectedSelector);
const allowDtmfDialer = showDtmfDialer(callees, participants, props.dtmfDialerOptions);
const [dtmfDialerChecked, setDtmfDialerChecked] = useState<boolean>(props.dtmfDialerPresent ?? false);
const [showRealTimeTextModal, setShowRealTimeTextModal] = useState(false);
const openRealTimeTextModal = useCallback((): void => {
setShowRealTimeTextModal(true);
}, []);
const onDismissRealTimeTextModal = useCallback((): void => {
setShowRealTimeTextModal(false);
}, []);
const raiseHandButtonProps = usePropsFor(RaiseHandButton) as RaiseHandButtonProps;
/* @conditional-compile-remove(together-mode) */
const participantCapability = useSelector(getCapabilites);
/* @conditional-compile-remove(together-mode) */
const participantId = useSelector(getLocalUserId);
/* @conditional-compile-remove(together-mode) */
const isTogetherModeActive = useSelector(getIsTogetherModeActive);
/* @conditional-compile-remove(together-mode) */
const isTeamsCall = useSelector(getIsTeamsCall);
const isTeamsMeeting = getIsTeamsMeeting(callAdapter.getState());
const onSpeakerItemClick = useCallback(
(
_ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement> | undefined,
itemKey: string | undefined
) => {
const selected = speakers?.find((speaker) => speaker.id === itemKey);
if (selected) {
// This is unsafe - we're only passing in part of the argument to the handler.
// But this is a known issue in our state.
onSelectSpeaker(selected as AudioDeviceInfo);
}
onLightDismiss();
},
[speakers, onSelectSpeaker, onLightDismiss]
);
const drawerSelectionOptions = inferCallWithChatControlOptions(props.callControls);
const showCaptionsButton =
props.isCaptionsSupported && drawerSelectionOptions !== false && isEnabled(drawerSelectionOptions.captionsButton);
const showRealTimeTextButton =
props.isRealTimeTextSupported &&
drawerSelectionOptions !== false &&
isEnabled(drawerSelectionOptions.realTimeTextButton);
if (props.reactionResources !== undefined) {
drawerMenuItems.push({
itemKey: 'reactions',
onRendererContent: () => (
<_ReactionDrawerMenuItem
onReactionClick={async (reaction) => {
props.onReactionClick?.(reaction);
onLightDismiss();
}}
reactionResources={props.reactionResources}
/>
)
});
}
if (props.speakers && props.speakers.length > 0) {
drawerMenuItems.push({
itemKey: 'speakers',
disabled: props.disableButtonsForHoldScreen,
text: props.strings.speakerMenuTitle,
iconProps: { iconName: 'MoreDrawerSpeakers' },
subMenuProps: props.speakers.map((speaker) => ({
itemKey: speaker.id,
iconProps: {
iconName: isDeviceSelected(speaker, props.selectedSpeaker)
? 'MoreDrawerSelectedSpeaker'
: 'MoreDrawerSpeakers'
},
text: speaker.name,
onItemClick: onSpeakerItemClick,
secondaryIconProps: isDeviceSelected(speaker, props.selectedSpeaker) ? { iconName: 'Accept' } : undefined
})),
secondaryText: props.selectedSpeaker?.name
});
}
const { microphones, onSelectMicrophone } = props;
const onMicrophoneItemClick = useCallback(
(
_ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement> | undefined,
itemKey: string | undefined
) => {
const selected = microphones?.find((mic) => mic.id === itemKey);
if (selected) {
// This is unsafe - we're only passing in part of the argument to the handler.
// But this is a known issue in our state.
onSelectMicrophone(selected as AudioDeviceInfo);
}
onLightDismiss();
},
[microphones, onSelectMicrophone, onLightDismiss]
);
if (props.microphones && props.microphones.length > 0) {
// Set props as Microphone if speakers can be enumerated else set as Audio Device
const speakersAvailable = props.speakers && props.speakers.length > 0;
const itemKey = speakersAvailable ? 'microphones' : 'audioDevices';
const text = speakersAvailable ? props.strings.microphoneMenuTitle : props.strings.audioDeviceMenuTitle;
const iconName = speakersAvailable ? 'MoreDrawerMicrophones' : 'MoreDrawerSpeakers';
const selectedIconName = speakersAvailable ? 'MoreDrawerSelectedMicrophone' : 'MoreDrawerSelectedSpeaker';
drawerMenuItems.push({
itemKey: itemKey,
disabled: props.disableButtonsForHoldScreen,
text: text,
iconProps: { iconName: iconName },
subMenuProps: props.microphones.map((mic) => ({
itemKey: mic.id,
iconProps: {
iconName: isDeviceSelected(mic, props.selectedMicrophone) ? selectedIconName : iconName
},
text: mic.name,
onItemClick: onMicrophoneItemClick,
secondaryIconProps: isDeviceSelected(mic, props.selectedMicrophone) ? { iconName: 'Accept' } : undefined,
disabled: drawerSelectionOptions !== false ? isDisabled(drawerSelectionOptions.microphoneButton) : undefined
})),
secondaryText: props.selectedMicrophone?.name
});
}
const dtmfDialerScreenOption = {
itemKey: 'dtmfDialerScreenKey',
text: !dtmfDialerChecked
? localeStrings.strings.call.dtmfDialerMoreButtonLabelOn
: localeStrings.strings.call.dtmfDialerMoreButtonLabelOff,
onItemClick: () => {
if (props.onSetDialpadPage) {
props.onSetDialpadPage();
}
setDtmfDialerChecked(!dtmfDialerChecked);
onLightDismiss();
},
iconProps: {
iconName: 'DtmfDialpadButton',
styles: { root: { lineHeight: 0 } }
}
};
/**
* Only render the dtmf dialer if the dialpad for PSTN calls is not present
*/
if (
props.onSetDialpadPage &&
allowDtmfDialer &&
drawerSelectionOptions !== false &&
isEnabled(drawerSelectionOptions.dtmfDialerButton)
) {
drawerMenuItems.push(dtmfDialerScreenOption);
}
const galleryLayoutOptions = {
itemKey: 'galleryPositionKey',
iconProps: {
iconName: 'GalleryOptions',
styles: { root: { lineHeight: 0 } }
},
disabled: props.disableButtonsForHoldScreen,
text: localeStrings.strings.call.moreButtonGalleryControlLabel,
subMenuProps: [
{
itemKey: 'dynamicSelectionKey',
text: localeStrings.strings.call.moreButtonGalleryFloatingLocalLayoutLabel,
onItemClick: () => {
props.onUserSetGalleryLayout && props.onUserSetGalleryLayout('floatingLocalVideo');
onLightDismiss();
},
iconProps: {
iconName: 'FloatingLocalVideoGalleryLayout',
styles: { root: { lineHeight: 0 } }
},
secondaryIconProps: props.userSetGalleryLayout === 'floatingLocalVideo' ? { iconName: 'Accept' } : undefined
},
{
itemKey: 'focusedContentSelectionKey',
text: localeStrings.strings.call.moreButtonGalleryFocusedContentLayoutLabel,
onItemClick: () => {
props.onUserSetGalleryLayout && props.onUserSetGalleryLayout('focusedContent');
onLightDismiss();
},
iconProps: {
iconName: 'FocusedContentGalleryLayout',
styles: { root: { lineHeight: 0 } }
},
secondaryIconProps: props.userSetGalleryLayout === 'focusedContent' ? { iconName: 'Accept' } : undefined
}
]
};
/* @conditional-compile-remove(gallery-layout-composite) */
const galleryOption = {
itemKey: 'defaultSelectionKey',
text: localeStrings.strings.call.moreButtonGalleryDefaultLayoutLabel,
onItemClick: () => {
props.onUserSetGalleryLayout && props.onUserSetGalleryLayout('default');
onLightDismiss();
},
iconProps: {
iconName: 'DefaultGalleryLayout',
styles: { root: { lineHeight: 0 } }
},
secondaryIconProps: props.userSetGalleryLayout === 'default' ? { iconName: 'Accept' } : undefined
};
/* @conditional-compile-remove(together-mode) */
const togetherModeOption = {
itemKey: 'togetherModeSelectionKey',
text: localeStrings.strings.call.moreButtonTogetherModeLayoutLabel,
onItemClick: () => {
props.onUserSetGalleryLayout && props.onUserSetGalleryLayout('togetherMode');
onLightDismiss();
},
iconProps: {
iconName: 'TogetherModeLayout',
styles: { root: { lineHeight: 0 } }
},
disabled: !(
(participantId?.kind === 'microsoftTeamsUser' && participantCapability?.startTogetherMode?.isPresent) ||
isTogetherModeActive
),
secondaryIconProps: props.userSetGalleryLayout === 'default' ? { iconName: 'Accept' } : undefined
};
/* @conditional-compile-remove(gallery-layout-composite) */
galleryLayoutOptions.subMenuProps?.push(galleryOption);
/* @conditional-compile-remove(together-mode) */
if (isTeamsCall || isTeamsMeeting) {
galleryLayoutOptions.subMenuProps?.push(togetherModeOption);
}
if (drawerSelectionOptions !== false && isEnabled(drawerSelectionOptions?.galleryControlsButton)) {
drawerMenuItems.push(galleryLayoutOptions);
}
if (drawerSelectionOptions !== false && isEnabled(drawerSelectionOptions?.peopleButton)) {
drawerMenuItems.push({
itemKey: 'people',
id: 'call-composite-drawer-people-button',
text: props.strings.peopleButtonLabel,
iconProps: { iconName: 'MoreDrawerPeople' },
onItemClick: props.onPeopleButtonClicked,
disabled: isDisabled(drawerSelectionOptions.peopleButton) || props.disableButtonsForHoldScreen
});
}
if (drawerSelectionOptions !== false && isEnabled(drawerSelectionOptions?.holdButton)) {
drawerMenuItems.push({
itemKey: 'holdButtonKey',
disabled: props.disableButtonsForHoldScreen || isDisabled(drawerSelectionOptions.holdButton),
text: localeStrings.component.strings.holdButton.tooltipOffContent,
onItemClick: () => {
holdButtonProps.onToggleHold();
onLightDismiss();
},
iconProps: { iconName: 'HoldCallContextualMenuItem', styles: { root: { lineHeight: 0 } } }
});
}
const role = callAdapter.getState().call?.role;
const hideRaiseHandButtonInRoomsCall =
callAdapter.getState().isRoomsCall && role && ['Consumer', 'Unknown'].includes(role);
if (
drawerSelectionOptions !== false &&
isEnabled(drawerSelectionOptions?.raiseHandButton) &&
!hideRaiseHandButtonInRoomsCall
) {
const raiseHandIcon = raiseHandButtonProps.checked ? 'LowerHandContextualMenuItem' : 'RaiseHandContextualMenuItem';
drawerMenuItems.push({
itemKey: 'raiseHandButtonKey',
disabled: props.disableButtonsForHoldScreen || isDisabled(drawerSelectionOptions.raiseHandButton),
text: raiseHandButtonProps.checked
? localeStrings.component.strings.raiseHandButton.onLabel
: localeStrings.component.strings.raiseHandButton.offLabel,
onItemClick: () => {
if (raiseHandButtonProps.onToggleRaiseHand) {
raiseHandButtonProps.onToggleRaiseHand();
}
onLightDismiss();
},
iconProps: {
iconName: raiseHandIcon,
styles: { root: { lineHeight: 0 } }
}
});
}
const teamsMeetingCoordinates = getTeamsMeetingCoordinates(callAdapter.getState());
if (
drawerSelectionOptions !== false &&
isEnabled(drawerSelectionOptions?.teamsMeetingPhoneCallButton) &&
isTeamsMeeting &&
teamsMeetingCoordinates
) {
drawerMenuItems.push({
itemKey: 'phoneCallInfoKey',
disabled: isDisabled(drawerSelectionOptions.teamsMeetingPhoneCallButton),
text: localeStrings.strings.call.phoneCallMoreButtonLabel,
onItemClick: () => {
props.onClickMeetingPhoneInfo?.();
onLightDismiss();
},
iconProps: {
iconName: 'PhoneNumberButton',
styles: { root: { lineHeight: 0 } }
}
});
}
//Captions drawer menu
const supportedSpokenLanguageStrings = useLocale().strings.call.spokenLanguageStrings;
//Captions drawer menu
const supportedCaptionLanguageStrings = useLocale().strings.call.captionLanguageStrings;
const captionSettingsProp = usePropsFor(CaptionsSettingsModal);
const startCaptionsButtonProps = usePropsFor(StartCaptionsButton);
const [isSpokenLanguageDrawerOpen, setIsSpokenLanguageDrawerOpen] = useState<boolean>(false);
const [isCaptionLanguageDrawerOpen, setIsCaptionLanguageDrawerOpen] = useState<boolean>(false);
// we don't display the setting modal to set the spoken language on mobile
// so when spoken language is empty (not set), we default to 'en-us'
const [currentSpokenLanguage, setCurrentSpokenLanguage] = useState<keyof SpokenLanguageStrings>(
captionSettingsProp.currentSpokenLanguage && (captionSettingsProp.currentSpokenLanguage as string) !== ''
? captionSettingsProp.currentSpokenLanguage
: 'en-us'
);
const [currentCaptionLanguage, setCurrentCaptionLanguage] = useState<keyof CaptionLanguageStrings>(
captionSettingsProp.currentCaptionLanguage ?? _spokenLanguageToCaptionLanguage[currentSpokenLanguage]
);
const onToggleChange = useCallback(async () => {
if (!captionSettingsProp.isCaptionsFeatureActive) {
await startCaptionsButtonProps.onStartCaptions({
spokenLanguage: currentSpokenLanguage
});
} else {
startCaptionsButtonProps.onStopCaptions();
}
}, [captionSettingsProp.isCaptionsFeatureActive, startCaptionsButtonProps, currentSpokenLanguage]);
if (showCaptionsButton) {
const captionsDrawerItems: DrawerMenuItemProps[] = [];
const spokenLanguageString = supportedSpokenLanguageStrings
? supportedSpokenLanguageStrings[currentSpokenLanguage]
: currentSpokenLanguage;
drawerMenuItems.push({
itemKey: 'captions',
id: 'common-call-composite-captions-button',
disabled: props.disableButtonsForHoldScreen,
text: props.strings.captionsMenuTitle,
iconProps: { iconName: 'CaptionsIcon' },
subMenuProps: captionsDrawerItems
});
captionsDrawerItems.push({
itemKey: 'ToggleCaptionsKey',
text: captionSettingsProp.isCaptionsFeatureActive
? localeStrings.strings.call.startCaptionsButtonTooltipOnContent
: localeStrings.strings.call.startCaptionsButtonTooltipOffContent,
iconProps: {
iconName: captionSettingsProp.isCaptionsFeatureActive ? 'CaptionsOffIcon' : 'CaptionsIcon',
styles: { root: { lineHeight: 0 } }
},
onItemClick: onToggleChange,
disabled: props.disableButtonsForHoldScreen,
secondaryComponent: (
<Stack verticalFill verticalAlign="center">
<Toggle
id="common-call-composite-captions-toggle-button"
checked={captionSettingsProp.isCaptionsFeatureActive}
styles={themedToggleButtonStyle(theme, captionSettingsProp.isCaptionsFeatureActive)}
onChange={onToggleChange}
/>
</Stack>
)
});
captionsDrawerItems.push({
itemKey: 'ChangeSpokenLanguage',
text: props.strings.spokenLanguageMenuTitle,
id: 'common-call-composite-captions-spoken-settings-button',
secondaryText: spokenLanguageString,
iconProps: {
iconName: 'ChangeSpokenLanguageIcon',
styles: { root: { lineHeight: 0 } }
},
disabled: props.disableButtonsForHoldScreen || !captionSettingsProp.isCaptionsFeatureActive,
onItemClick: () => {
setIsSpokenLanguageDrawerOpen(true);
},
secondaryIconProps: {
iconName: 'ChevronRight',
styles: { root: { lineHeight: 0 } }
}
});
if (props.useTeamsCaptions) {
const captionLanguageString = supportedCaptionLanguageStrings
? supportedCaptionLanguageStrings[currentCaptionLanguage]
: currentCaptionLanguage;
captionsDrawerItems.push({
itemKey: 'ChangeCaptionLanguage',
text: props.strings.captionLanguageMenuTitle,
id: 'common-call-composite-captions-subtitle-settings-button',
secondaryText: captionLanguageString,
iconProps: {
iconName: 'ChangeCaptionLanguageIcon',
styles: { root: { lineHeight: 0 } }
},
disabled: props.disableButtonsForHoldScreen || !captionSettingsProp.isCaptionsFeatureActive,
onItemClick: () => {
setIsCaptionLanguageDrawerOpen(true);
},
secondaryIconProps: {
iconName: 'ChevronRight',
styles: { root: { lineHeight: 0 } }
}
});
}
}
const rttDisabled =
props.disableButtonsForHoldScreen || realTimeTextProps.isRealTimeTextOn || props.startRealTimeTextButtonChecked;
// rtt
if (showRealTimeTextButton) {
const realTimeTextDrawerItems: DrawerMenuItemProps[] = [];
drawerMenuItems.push({
itemKey: 'realTimeText',
id: 'common-call-composite-rtt-button',
disabled: props.disableButtonsForHoldScreen,
text: localeStrings.strings.call.realTimeTextLabel,
iconProps: { iconName: 'RealTimeTextIcon' },
subMenuProps: realTimeTextDrawerItems
});
realTimeTextDrawerItems.push({
itemKey: 'ToggleRTTKey',
id: 'common-call-composite-rtt-start-button',
text: localeStrings.strings.call.startRealTimeTextLabel,
ariaLabel: rttDisabled
? localeStrings.strings.call.disabledStartRealTimeTextLabel
: localeStrings.strings.call.startRealTimeTextLabel,
iconProps: {
iconName: 'RealTimeTextIcon',
styles: { root: { lineHeight: 0 } }
},
onItemClick: openRealTimeTextModal,
disabled: rttDisabled,
secondaryComponent: (
<Stack verticalFill verticalAlign="center">
<Toggle
id="common-call-composite-rtt-toggle-button"
checked={realTimeTextProps.isRealTimeTextOn || props.startRealTimeTextButtonChecked}
styles={themedToggleButtonStyle(
theme,
realTimeTextProps.isRealTimeTextOn || props.startRealTimeTextButtonChecked
)}
onChange={openRealTimeTextModal}
/>
</Stack>
)
});
}
const customDrawerButtons = useMemo(
() =>
generateCustomCallDrawerButtons(
onFetchCustomButtonPropsTrampoline(drawerSelectionOptions !== false ? drawerSelectionOptions : undefined),
drawerSelectionOptions !== false ? drawerSelectionOptions?.displayType : undefined
),
[drawerSelectionOptions]
);
customDrawerButtons['primary'].slice(CUSTOM_BUTTON_OPTIONS.MAX_PRIMARY_MOBILE_CUSTOM_BUTTONS).forEach((element) => {
drawerMenuItems.push(element);
});
customDrawerButtons['secondary'].forEach((element) => {
drawerMenuItems.push(element);
});
customDrawerButtons['overflow'].forEach((element) => {
const customButtonProps = { ...element };
// Default Auto dismiss drawer on click unless specified
if (customButtonProps.dismissDrawer !== false) {
element = {
...customButtonProps,
onItemClick: () => {
customButtonProps.onItemClick?.();
onLightDismiss();
}
};
}
drawerMenuItems.push(element);
});
return (
<>
{showRealTimeTextModal && (
<CallingRealTimeTextModal
showModal={showRealTimeTextModal}
onDismissModal={onDismissRealTimeTextModal}
onStartRealTimeText={props.onStartRealTimeText}
/>
)}
{isSpokenLanguageDrawerOpen && showCaptionsButton && (
<SpokenLanguageSettingsDrawer
onLightDismiss={props.onLightDismiss}
selectLanguage={setCurrentSpokenLanguage}
setCurrentLanguage={captionSettingsProp.onSetSpokenLanguage}
currentLanguage={currentSpokenLanguage}
strings={{ menuTitle: props.strings.spokenLanguageMenuTitle }}
supportedLanguageStrings={supportedSpokenLanguageStrings}
/>
)}
{isCaptionLanguageDrawerOpen && showCaptionsButton && (
<CaptionLanguageSettingsDrawer
onLightDismiss={props.onLightDismiss}
selectLanguage={setCurrentCaptionLanguage}
setCurrentLanguage={captionSettingsProp.onSetCaptionLanguage}
currentLanguage={currentCaptionLanguage}
strings={{ menuTitle: props.strings.captionLanguageMenuTitle }}
supportedLanguageStrings={supportedCaptionLanguageStrings}
/>
)}
{!isSpokenLanguageDrawerOpen && !isCaptionLanguageDrawerOpen && (
<DrawerMenu items={drawerMenuItems} onLightDismiss={props.onLightDismiss} />
)}
</>
);
};
const isDeviceSelected = (speaker: OptionsDevice, selectedSpeaker?: OptionsDevice): boolean =>
!!selectedSpeaker && speaker.id === selectedSpeaker.id;
const isEnabled = (option: unknown): boolean => option !== false;