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.

SendToRoomButton.tsx 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { useDispatch } from 'react-redux';
  4. import { createBreakoutRoomsEvent } from '../../../analytics/AnalyticsEvents';
  5. import { sendAnalytics } from '../../../analytics/functions';
  6. import { IconRingGroup } from '../../../base/icons/svg';
  7. import ContextMenuItem from '../../../base/ui/components/web/ContextMenuItem';
  8. import { sendParticipantToRoom } from '../../../breakout-rooms/actions';
  9. import { IRoom } from '../../../breakout-rooms/types';
  10. import { NOTIFY_CLICK_MODE } from '../../../toolbox/constants';
  11. import { IButtonProps } from '../../types';
  12. interface IProps extends IButtonProps {
  13. /**
  14. * Click handler.
  15. */
  16. onClick?: Function;
  17. /**
  18. * The room to send the participant to.
  19. */
  20. room: IRoom;
  21. }
  22. const SendToRoomButton = ({
  23. notifyClick,
  24. notifyMode,
  25. onClick,
  26. participantID,
  27. room
  28. }: IProps) => {
  29. const dispatch = useDispatch();
  30. const { t } = useTranslation();
  31. const _onClick = useCallback(() => {
  32. notifyClick?.();
  33. if (notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY) {
  34. return;
  35. }
  36. onClick?.();
  37. sendAnalytics(createBreakoutRoomsEvent('send.participant.to.room'));
  38. dispatch(sendParticipantToRoom(participantID, room.id));
  39. }, [ dispatch, notifyClick, notifyMode, onClick, participantID, room, sendAnalytics ]);
  40. const roomName = room.name || t('breakoutRooms.mainRoom');
  41. return (
  42. <ContextMenuItem
  43. accessibilityLabel = { roomName }
  44. icon = { IconRingGroup }
  45. onClick = { _onClick }
  46. text = { roomName } />
  47. );
  48. };
  49. export default SendToRoomButton;