feat(toolbox) notify click for hangup-menu and end-meeting menu button

This commit is contained in:
Shawn 2022-09-14 17:42:30 +01:00 committed by Дамян Минков
parent 53ccb97d34
commit 93ab7725e7
7 changed files with 148 additions and 14 deletions

View File

@ -767,11 +767,13 @@ var config = {
// 'desktop', // 'desktop',
// 'download', // 'download',
// 'embedmeeting', // 'embedmeeting',
// 'end-meeting',
// 'etherpad', // 'etherpad',
// 'feedback', // 'feedback',
// 'filmstrip', // 'filmstrip',
// 'fullscreen', // 'fullscreen',
// 'hangup', // 'hangup',
// 'hangup-menu',
// 'help', // 'help',
// { // {
// key: 'invite', // key: 'invite',

View File

@ -39,11 +39,13 @@ type ButtonsWithNotifyClick = 'camera' |
'desktop' | 'desktop' |
'download' | 'download' |
'embedmeeting' | 'embedmeeting' |
'end-meeting' |
'etherpad' | 'etherpad' |
'feedback' | 'feedback' |
'filmstrip' | 'filmstrip' |
'fullscreen' | 'fullscreen' |
'hangup' | 'hangup' |
'hangup-menu' |
'help' | 'help' |
'invite' | 'invite' |
'livestreaming' | 'livestreaming' |

View File

@ -4,16 +4,36 @@ import { useDispatch, useSelector } from 'react-redux';
import { endConference } from '../../../base/conference/actions'; import { endConference } from '../../../base/conference/actions';
import { isLocalParticipantModerator } from '../../../base/participants/functions'; import { isLocalParticipantModerator } from '../../../base/participants/functions';
import Button from '../../../base/ui/components/web/Button';
import { BUTTON_TYPES } from '../../../base/ui/constants.web'; import { BUTTON_TYPES } from '../../../base/ui/constants.web';
import { isInBreakoutRoom } from '../../../breakout-rooms/functions'; import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
import { HangupContextMenuItem } from './HangupContextMenuItem';
/**
* The type of the React {@code Component} props of {@link EndConferenceButton}.
*/
type Props = {
/**
* Key to use for toolbarButtonClicked event.
*/
buttonKey: string;
/**
* Notify mode for `toolbarButtonClicked` event -
* whether to only notify or to also prevent button click routine.
*/
notifyMode?: string;
};
/** /**
* Button to end the conference for all participants. * Button to end the conference for all participants.
* *
* @param {Object} props - Component's props.
* @returns {JSX.Element} - The end conference button. * @returns {JSX.Element} - The end conference button.
*/ */
export const EndConferenceButton = () => { export const EndConferenceButton = (props: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const dispatch = useDispatch(); const dispatch = useDispatch();
const _isLocalParticipantModerator = useSelector(isLocalParticipantModerator); const _isLocalParticipantModerator = useSelector(isLocalParticipantModerator);
@ -24,11 +44,12 @@ export const EndConferenceButton = () => {
}, [ dispatch ]); }, [ dispatch ]);
return (<> return (<>
{ !_isInBreakoutRoom && _isLocalParticipantModerator && <Button { !_isInBreakoutRoom && _isLocalParticipantModerator && <HangupContextMenuItem
accessibilityLabel = { t('toolbar.accessibilityLabel.endConference') } accessibilityLabel = { t('toolbar.accessibilityLabel.endConference') }
fullWidth = { true } buttonKey = { props.buttonKey }
buttonType = { BUTTON_TYPES.DESTRUCTIVE }
label = { t('toolbar.endConference') } label = { t('toolbar.endConference') }
onClick = { onEndConference } notifyMode = { props.notifyMode }
type = { BUTTON_TYPES.DESTRUCTIVE } /> } onClick = { onEndConference } /> }
</>); </>);
}; };

View File

@ -0,0 +1,75 @@
import React, { useCallback } from 'react';
import Button from '../../../base/ui/components/web/Button';
import { NOTIFY_CLICK_MODE } from '../../constants';
/**
* The type of the React {@code Component} props of {@link HangupContextMenuItem}.
*/
type Props = {
/**
* Accessibility label for the button.
*/
accessibilityLabel: string;
/**
* Key to use for toolbarButtonClicked event.
*/
buttonKey: string;
/**
* Type of button to display.
*/
buttonType: string;
/**
* Text associated with the button.
*/
label: string;
/**
* Notify mode for `toolbarButtonClicked` event -
* whether to only notify or to also prevent button click routine.
*/
notifyMode?: string;
/**
* Callback that performs the actual hangup action.
*/
onClick: Function;
};
declare let APP: any;
/**
* Implementation of a button to be rendered within Hangup context menu.
*
* @param {Object} props - Component's props.
* @returns {JSX.Element} - Button that would trigger the hangup action.
*/
export const HangupContextMenuItem = (props: Props) => {
const shouldNotify = props.notifyMode !== undefined;
const shouldPreventExecution = props.notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY;
const _onClick = useCallback(() => {
if (shouldNotify) {
APP.API.notifyToolbarButtonClicked(props.buttonKey, shouldPreventExecution);
}
if (!shouldPreventExecution) {
props.onClick();
}
}, []);
return (
<Button
accessibilityLabel = { props.accessibilityLabel }
fullWidth = { true }
label = { props.label }
onClick = { _onClick }
type = { props.buttonType } />
);
};

View File

@ -28,6 +28,12 @@ interface IProps extends WithTranslation {
*/ */
isOpen: boolean; isOpen: boolean;
/**
* Notify mode for `toolbarButtonClicked` event -
* whether to only notify or to also prevent button click routine.
*/
notifyMode?: string;
/** /**
* Callback to change the visibility of the hangup menu. * Callback to change the visibility of the hangup menu.
*/ */
@ -88,9 +94,11 @@ class HangupMenuButton extends Component<IProps> {
trigger = 'click' trigger = 'click'
visible = { isOpen }> visible = { isOpen }>
<HangupToggleButton <HangupToggleButton
buttonKey = 'hangup-menu'
customClass = 'hangup-menu-button' customClass = 'hangup-menu-button'
handleClick = { this._toggleDialogVisibility } handleClick = { this._toggleDialogVisibility }
isOpen = { isOpen } isOpen = { isOpen }
notifyMode = { this.props.notifyMode }
onKeyDown = { this._onEscClick } /> onKeyDown = { this._onEscClick } />
</Popover> </Popover>
</div> </div>

View File

@ -5,15 +5,35 @@ import { useDispatch } from 'react-redux';
import { createToolbarEvent } from '../../../analytics/AnalyticsEvents'; import { createToolbarEvent } from '../../../analytics/AnalyticsEvents';
import { sendAnalytics } from '../../../analytics/functions'; import { sendAnalytics } from '../../../analytics/functions';
import { leaveConference } from '../../../base/conference/actions'; import { leaveConference } from '../../../base/conference/actions';
import Button from '../../../base/ui/components/web/Button';
import { BUTTON_TYPES } from '../../../base/ui/constants.web'; import { BUTTON_TYPES } from '../../../base/ui/constants.web';
import { HangupContextMenuItem } from './HangupContextMenuItem';
/**
* The type of the React {@code Component} props of {@link LeaveConferenceButton}.
*/
type Props = {
/**
* Key to use for toolbarButtonClicked event.
*/
buttonKey: string;
/**
* Notify mode for `toolbarButtonClicked` event -
* whether to only notify or to also prevent button click routine.
*/
notifyMode?: string;
};
/** /**
* Button to leave the conference. * Button to leave the conference.
* *
* @param {Object} props - Component's props.
* @returns {JSX.Element} - The leave conference button. * @returns {JSX.Element} - The leave conference button.
*/ */
export const LeaveConferenceButton = () => { export const LeaveConferenceButton = (props: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -23,11 +43,12 @@ export const LeaveConferenceButton = () => {
}, [ dispatch ]); }, [ dispatch ]);
return ( return (
<Button <HangupContextMenuItem
accessibilityLabel = { t('toolbar.accessibilityLabel.leaveConference') } accessibilityLabel = { t('toolbar.accessibilityLabel.leaveConference') }
fullWidth = { true } buttonKey = { props.buttonKey }
buttonType = { BUTTON_TYPES.SECONDARY }
label = { t('toolbar.leaveConference') } label = { t('toolbar.leaveConference') }
onClick = { onLeaveConference } notifyMode = { props.notifyMode }
type = { BUTTON_TYPES.SECONDARY } /> onClick = { onLeaveConference } />
); );
}; };

View File

@ -1489,6 +1489,7 @@ class Toolbox extends Component<IProps> {
ariaControls = 'hangup-menu' ariaControls = 'hangup-menu'
isOpen = { _hangupMenuVisible } isOpen = { _hangupMenuVisible }
key = 'hangup-menu' key = 'hangup-menu'
notifyMode = { this._getButtonNotifyMode('hangup-menu') }
onVisibilityChange = { this._onSetHangupVisible }> onVisibilityChange = { this._onSetHangupVisible }>
<ContextMenu <ContextMenu
accessibilityLabel = { t(toolbarAccLabel) } accessibilityLabel = { t(toolbarAccLabel) }
@ -1496,8 +1497,12 @@ class Toolbox extends Component<IProps> {
hidden = { false } hidden = { false }
inDrawer = { _overflowDrawer } inDrawer = { _overflowDrawer }
onKeyDown = { this._onEscKey }> onKeyDown = { this._onEscKey }>
<EndConferenceButton /> <EndConferenceButton
<LeaveConferenceButton /> buttonKey = 'end-meeting'
notifyMode = { this._getButtonNotifyMode('end-meeting') } />
<LeaveConferenceButton
buttonKey = 'hangup'
notifyMode = { this._getButtonNotifyMode('hangup') } />
</ContextMenu> </ContextMenu>
</HangupMenuButton> </HangupMenuButton>
: <HangupButton : <HangupButton