您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

HangupContextMenuItem.tsx 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React, { useCallback } from 'react';
  2. import Button from '../../../base/ui/components/web/Button';
  3. import { NOTIFY_CLICK_MODE } from '../../types';
  4. /**
  5. * The type of the React {@code Component} props of {@link HangupContextMenuItem}.
  6. */
  7. interface IProps {
  8. /**
  9. * Accessibility label for the button.
  10. */
  11. accessibilityLabel: string;
  12. /**
  13. * Key to use for toolbarButtonClicked event.
  14. */
  15. buttonKey: string;
  16. /**
  17. * Type of button to display.
  18. */
  19. buttonType: string;
  20. /**
  21. * Text associated with the button.
  22. */
  23. label: string;
  24. /**
  25. * Notify mode for `toolbarButtonClicked` event -
  26. * whether to only notify or to also prevent button click routine.
  27. */
  28. notifyMode?: string;
  29. /**
  30. * Callback that performs the actual hangup action.
  31. */
  32. onClick: Function;
  33. }
  34. /**
  35. * Implementation of a button to be rendered within Hangup context menu.
  36. *
  37. * @param {Object} props - Component's props.
  38. * @returns {JSX.Element} - Button that would trigger the hangup action.
  39. */
  40. export const HangupContextMenuItem = (props: IProps) => {
  41. const shouldNotify = props.notifyMode !== undefined;
  42. const shouldPreventExecution = props.notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY;
  43. const _onClick = useCallback(() => {
  44. if (shouldNotify) {
  45. APP.API.notifyToolbarButtonClicked(props.buttonKey, shouldPreventExecution);
  46. }
  47. if (!shouldPreventExecution) {
  48. props.onClick();
  49. }
  50. }, []);
  51. return (
  52. <Button
  53. accessibilityLabel = { props.accessibilityLabel }
  54. fullWidth = { true }
  55. label = { props.label }
  56. onClick = { _onClick }
  57. type = { props.buttonType } />
  58. );
  59. };