You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EndConferenceButton.tsx 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { useDispatch, useSelector } from 'react-redux';
  4. import { endConference } from '../../../base/conference/actions';
  5. import { isLocalParticipantModerator } from '../../../base/participants/functions';
  6. import { BUTTON_TYPES } from '../../../base/ui/constants.web';
  7. import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
  8. import { HangupContextMenuItem } from './HangupContextMenuItem';
  9. /**
  10. * The type of the React {@code Component} props of {@link EndConferenceButton}.
  11. */
  12. type Props = {
  13. /**
  14. * Key to use for toolbarButtonClicked event.
  15. */
  16. buttonKey: string;
  17. /**
  18. * Notify mode for `toolbarButtonClicked` event -
  19. * whether to only notify or to also prevent button click routine.
  20. */
  21. notifyMode?: string;
  22. };
  23. /**
  24. * Button to end the conference for all participants.
  25. *
  26. * @param {Object} props - Component's props.
  27. * @returns {JSX.Element} - The end conference button.
  28. */
  29. export const EndConferenceButton = (props: Props) => {
  30. const { t } = useTranslation();
  31. const dispatch = useDispatch();
  32. const _isLocalParticipantModerator = useSelector(isLocalParticipantModerator);
  33. const _isInBreakoutRoom = useSelector(isInBreakoutRoom);
  34. const onEndConference = useCallback(() => {
  35. dispatch(endConference());
  36. }, [ dispatch ]);
  37. return (<>
  38. { !_isInBreakoutRoom && _isLocalParticipantModerator && <HangupContextMenuItem
  39. accessibilityLabel = { t('toolbar.accessibilityLabel.endConference') }
  40. buttonKey = { props.buttonKey }
  41. buttonType = { BUTTON_TYPES.DESTRUCTIVE }
  42. label = { t('toolbar.endConference') }
  43. notifyMode = { props.notifyMode }
  44. onClick = { onEndConference } /> }
  45. </>);
  46. };