diff --git a/change-beta/@azure-communication-react-e2353682-59d3-47be-9145-cd1eaf37003b.json b/change-beta/@azure-communication-react-e2353682-59d3-47be-9145-cd1eaf37003b.json new file mode 100644 index 00000000000..1b3048cff91 --- /dev/null +++ b/change-beta/@azure-communication-react-e2353682-59d3-47be-9145-cd1eaf37003b.json @@ -0,0 +1,9 @@ +{ + "type": "prerelease", + "area": "feature", + "workstream": "RTT", + "comment": "Add RTT to calling stateful sample. Fix bug in start RTT button", + "packageName": "@azure/communication-react", + "email": "carolinecao@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/common/config/babel/features.js b/common/config/babel/features.js index 94ce847e67e..0532f2a0990 100644 --- a/common/config/babel/features.js +++ b/common/config/babel/features.js @@ -22,9 +22,7 @@ module.exports = { // Feature for remote UFD "remote-ufd", // Feature for together mode - "together-mode", - // Feature for RTT - "rtt" + "together-mode" ], beta: [ "call-readiness", @@ -73,6 +71,8 @@ module.exports = { "call-participants-locator", // feature for breakout rooms "breakout-rooms", + // Feature for RTT + "rtt" ], stable: [ // Demo feature. Used in live-documentation of conditional compilation. diff --git a/packages/communication-react/review/beta/communication-react.api.md b/packages/communication-react/review/beta/communication-react.api.md index b80502725af..96d74ced60e 100644 --- a/packages/communication-react/review/beta/communication-react.api.md +++ b/packages/communication-react/review/beta/communication-react.api.md @@ -5125,7 +5125,7 @@ export interface StartRealTimeTextButtonProps extends ControlBarButtonProps { // @beta export interface StartRealTimeTextButtonStrings { label: string; - tooltipOnContent: string; + tooltipOffContent: string; } // @beta diff --git a/packages/react-components/src/components/StartRealTimeTextButton.tsx b/packages/react-components/src/components/StartRealTimeTextButton.tsx index bda0969516d..2923a8fac6a 100644 --- a/packages/react-components/src/components/StartRealTimeTextButton.tsx +++ b/packages/react-components/src/components/StartRealTimeTextButton.tsx @@ -42,9 +42,10 @@ export interface StartRealTimeTextButtonStrings { */ label: string; /** - * Content for when button is checked, RealTimeText is on + * Content for when button is not checked, Real-Time Text is off. + * We don't need to supply a tooltip string when RealTimeText is on, because the button will be disabled when Real-Time Text is on. */ - tooltipOnContent: string; + tooltipOffContent: string; } /* @conditional-compile-remove(rtt) */ @@ -70,7 +71,7 @@ export const StartRealTimeTextButton = (props: StartRealTimeTextButtonProps): JS strings={strings} onClick={onStartRealTimeText} onRenderOffIcon={onRenderStartIcon} - disabled={isRealTimeTextOn} + disabled={props.disabled || isRealTimeTextOn} /> ); }; diff --git a/packages/react-components/src/localization/locales/en-US/strings.json b/packages/react-components/src/localization/locales/en-US/strings.json index e939b751008..8bd24e55327 100644 --- a/packages/react-components/src/localization/locales/en-US/strings.json +++ b/packages/react-components/src/localization/locales/en-US/strings.json @@ -306,7 +306,7 @@ }, "startRealTimeTextButton": { "label": "Turn on RTT for this call", - "tooltipOnContent": "RTT is turned on for this call" + "tooltipOffContent": "Turn on RTT for this call" }, "messageThread": { "yesterday": "Yesterday", diff --git a/packages/storybook8/stories/Components/CaptionsBanner/snippets/CaptionsBanner.snippet.tsx b/packages/storybook8/stories/Components/CaptionsBanner/snippets/CaptionsBanner.snippet.tsx index 4e605a82416..3d7420834e9 100644 --- a/packages/storybook8/stories/Components/CaptionsBanner/snippets/CaptionsBanner.snippet.tsx +++ b/packages/storybook8/stories/Components/CaptionsBanner/snippets/CaptionsBanner.snippet.tsx @@ -6,5 +6,11 @@ import React from 'react'; export const CaptionsBannerStory = (): JSX.Element => { const captionsBannerProps = usePropsFor(CaptionsBanner); - return <>{captionsBannerProps?.isCaptionsOn && }; + return ( + <> + {(captionsBannerProps?.isCaptionsOn || captionsBannerProps?.isRealTimeTextOn) && ( + + )} + + ); }; diff --git a/packages/storybook8/stories/Components/StartRealTimeTextButton/snippets/StartRealTimeTextButton.snippet.tsx b/packages/storybook8/stories/Components/StartRealTimeTextButton/snippets/StartRealTimeTextButton.snippet.tsx index 34d707e9844..1a9d18a9716 100644 --- a/packages/storybook8/stories/Components/StartRealTimeTextButton/snippets/StartRealTimeTextButton.snippet.tsx +++ b/packages/storybook8/stories/Components/StartRealTimeTextButton/snippets/StartRealTimeTextButton.snippet.tsx @@ -1,14 +1,22 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { StartRealTimeTextButton } from '@azure/communication-react'; +import { CaptionsBanner, StartRealTimeTextButton, usePropsFor } from '@azure/communication-react'; import React from 'react'; export const StartRealTimeTextButtonStory = (): JSX.Element => { + /** + * In this example snippet we show case how to add a button to start real-time text + * The start button will enable real-time text for the local user so the user can start typing + * Once the first real-time text message is sent, real-time text will be enabled automatically for all participants. + * The start button is disabled when real-time text is on + */ + const [isRealTimeTextOn, setIsRealTimeTextOn] = React.useState(false); + const captionsBannerProps = usePropsFor(CaptionsBanner); return ( { alert('Real-Time Text started'); diff --git a/samples/CallingStateful/src/components/CallingComponents.tsx b/samples/CallingStateful/src/components/CallingComponents.tsx index 63180013d57..905d5ff8b3c 100644 --- a/samples/CallingStateful/src/components/CallingComponents.tsx +++ b/samples/CallingStateful/src/components/CallingComponents.tsx @@ -13,6 +13,8 @@ import { VideoStreamOptions, StartCaptionsButton } from '@azure/communication-react'; +/* @conditional-compile-remove(rtt) */ +import { StartRealTimeTextButton, RealTimeTextModal } from '@azure/communication-react'; import { Stack } from '@fluentui/react'; import { LocalLanguage20Regular } from '@fluentui/react-icons'; import React, { useCallback, useState } from 'react'; @@ -26,8 +28,11 @@ export const CallingComponents = (): JSX.Element => { const startCaptionsButtonProps = usePropsFor(StartCaptionsButton); const captionsSettingsModalProps = usePropsFor(CaptionsSettingsModal); const captionsBannerProps = usePropsFor(CaptionsBanner); - const [callEnded, setCallEnded] = useState(false); + /* @conditional-compile-remove(rtt) */ + const [showRealTimeTextModal, setShowRealTimeTextModal] = useState(false); + /* @conditional-compile-remove(rtt) */ + const [isRealTimeTextStarted, setIsRealTimeTextStarted] = useState(false); const [showCaptionsSettingsModal, setShowCaptionsSettingsModal] = useState(false); const call = useCall(); const localVideoViewOptions = { @@ -68,7 +73,28 @@ export const CallingComponents = (): JSX.Element => { }} /> )} - {captionsBannerProps?.isCaptionsOn && } + { + /* @conditional-compile-remove(rtt) */ showRealTimeTextModal && ( + { + setShowRealTimeTextModal(false); + }} + onStartRealTimeText={() => { + setIsRealTimeTextStarted(true); + }} + /> + ) + } + {(captionsBannerProps?.isCaptionsOn || + /* @conditional-compile-remove(rtt) */ captionsBannerProps.isRealTimeTextOn || + /* @conditional-compile-remove(rtt) */ isRealTimeTextStarted) && ( + + )} {cameraProps && } @@ -94,6 +120,15 @@ export const CallingComponents = (): JSX.Element => { }} /> )} + { + /* @conditional-compile-remove(rtt) */ { + setShowRealTimeTextModal(true); + }} + /> + } {endCallProps && }