Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

DemoteToVisitorButton.tsx 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { useDispatch } from 'react-redux';
  4. import { openDialog } from '../../../base/dialog/actions';
  5. import { IconUsers } from '../../../base/icons/svg';
  6. import ContextMenuItem from '../../../base/ui/components/web/ContextMenuItem';
  7. import { NOTIFY_CLICK_MODE } from '../../../toolbox/types';
  8. import { IButtonProps } from '../../types';
  9. import DemoteToVisitorDialog from './DemoteToVisitorDialog';
  10. interface IProps extends IButtonProps {
  11. /**
  12. * Button text class name.
  13. */
  14. className?: string;
  15. /**
  16. * Whether the icon should be hidden or not.
  17. */
  18. noIcon?: boolean;
  19. /**
  20. * Click handler executed aside from the main action.
  21. */
  22. onClick?: Function;
  23. }
  24. /**
  25. * Implements a React {@link Component} which displays a button for demoting a participant to visitor.
  26. *
  27. * @returns {JSX.Element}
  28. */
  29. export default function DemoteToVisitorButton({
  30. className,
  31. noIcon = false,
  32. notifyClick,
  33. notifyMode,
  34. participantID
  35. }: IProps): JSX.Element {
  36. const { t } = useTranslation();
  37. const dispatch = useDispatch();
  38. const handleClick = useCallback(() => {
  39. notifyClick?.();
  40. if (notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY) {
  41. return;
  42. }
  43. dispatch(openDialog(DemoteToVisitorDialog, { participantID }));
  44. }, [ dispatch, notifyClick, notifyMode, participantID ]);
  45. return (
  46. <ContextMenuItem
  47. accessibilityLabel = { t('videothumbnail.demote') }
  48. className = { className || 'demotelink' } // can be used in tests
  49. icon = { noIcon ? null : IconUsers }
  50. id = { `demotelink_${participantID}` }
  51. onClick = { handleClick }
  52. text = { t('videothumbnail.demote') } />
  53. );
  54. }