2022-08-26 18:25:04 +00:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
|
2022-10-19 08:42:54 +00:00
|
|
|
import { endConference } from '../../../base/conference/actions';
|
2022-10-11 10:47:54 +00:00
|
|
|
import { isLocalParticipantModerator } from '../../../base/participants/functions';
|
2022-11-09 12:45:55 +00:00
|
|
|
import { BUTTON_TYPES } from '../../../base/ui/constants.web';
|
2022-08-26 18:25:04 +00:00
|
|
|
import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
|
|
|
|
|
2022-09-14 16:42:30 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-26 18:25:04 +00:00
|
|
|
/**
|
|
|
|
* Button to end the conference for all participants.
|
|
|
|
*
|
2022-09-14 16:42:30 +00:00
|
|
|
* @param {Object} props - Component's props.
|
2022-08-26 18:25:04 +00:00
|
|
|
* @returns {JSX.Element} - The end conference button.
|
|
|
|
*/
|
2022-09-14 16:42:30 +00:00
|
|
|
export const EndConferenceButton = (props: Props) => {
|
2022-08-26 18:25:04 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const _isLocalParticipantModerator = useSelector(isLocalParticipantModerator);
|
|
|
|
const _isInBreakoutRoom = useSelector(isInBreakoutRoom);
|
|
|
|
|
|
|
|
const onEndConference = useCallback(() => {
|
|
|
|
dispatch(endConference());
|
|
|
|
}, [ dispatch ]);
|
|
|
|
|
|
|
|
return (<>
|
2022-09-14 16:42:30 +00:00
|
|
|
{ !_isInBreakoutRoom && _isLocalParticipantModerator && <HangupContextMenuItem
|
2022-08-26 18:25:04 +00:00
|
|
|
accessibilityLabel = { t('toolbar.accessibilityLabel.endConference') }
|
2022-09-14 16:42:30 +00:00
|
|
|
buttonKey = { props.buttonKey }
|
|
|
|
buttonType = { BUTTON_TYPES.DESTRUCTIVE }
|
2022-08-26 18:25:04 +00:00
|
|
|
label = { t('toolbar.endConference') }
|
2022-09-14 16:42:30 +00:00
|
|
|
notifyMode = { props.notifyMode }
|
|
|
|
onClick = { onEndConference } /> }
|
2022-08-26 18:25:04 +00:00
|
|
|
</>);
|
|
|
|
};
|