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.

LocalVideoMenuTriggerButton.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // @flow
  2. import React from 'react';
  3. import { Icon, IconMenuThumb } from '../../../base/icons';
  4. import { Popover } from '../../../base/popover';
  5. import { connect } from '../../../base/redux';
  6. import { getLocalVideoTrack } from '../../../base/tracks';
  7. import { getCurrentLayout, LAYOUTS } from '../../../video-layout';
  8. import FlipLocalVideoButton from './FlipLocalVideoButton';
  9. import VideoMenu from './VideoMenu';
  10. /**
  11. * The type of the React {@code Component} props of
  12. * {@link LocalVideoMenuTriggerButton}.
  13. */
  14. type Props = {
  15. /**
  16. * The position relative to the trigger the local video menu should display
  17. * from. Valid values are those supported by AtlasKit
  18. * {@code InlineDialog}.
  19. */
  20. _menuPosition: string,
  21. /**
  22. * Whether to display the Popover as a drawer.
  23. */
  24. _overflowDrawer: boolean,
  25. /**
  26. * Shows/hides the local video flip button.
  27. */
  28. _showLocalVideoFlipButton: boolean
  29. };
  30. /**
  31. * React Component for displaying an icon associated with opening the
  32. * the video menu for the local participant.
  33. *
  34. * @param {Props} props - The props passed to the component.
  35. * @returns {ReactElement}
  36. */
  37. function LocalVideoMenuTriggerButton(props: Props) {
  38. return (
  39. props._showLocalVideoFlipButton
  40. ? <Popover
  41. content = {
  42. <VideoMenu id = 'localVideoMenu'>
  43. <FlipLocalVideoButton />
  44. </VideoMenu>
  45. }
  46. overflowDrawer = { props._overflowDrawer }
  47. position = { props._menuPosition }>
  48. <span
  49. className = 'popover-trigger local-video-menu-trigger'>
  50. <Icon
  51. size = '1em'
  52. src = { IconMenuThumb }
  53. title = 'Local user controls' />
  54. </span>
  55. </Popover>
  56. : null
  57. );
  58. }
  59. /**
  60. * Maps (parts of) the Redux state to the associated {@code LocalVideoMenuTriggerButton}'s props.
  61. *
  62. * @param {Object} state - The Redux state.
  63. * @private
  64. * @returns {Props}
  65. */
  66. function _mapStateToProps(state) {
  67. const currentLayout = getCurrentLayout(state);
  68. const { disableLocalVideoFlip } = state['features/base/config'];
  69. const videoTrack = getLocalVideoTrack(state['features/base/tracks']);
  70. const { overflowDrawer } = state['features/toolbox'];
  71. let _menuPosition;
  72. switch (currentLayout) {
  73. case LAYOUTS.TILE_VIEW:
  74. _menuPosition = 'left-start';
  75. break;
  76. case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
  77. _menuPosition = 'left-end';
  78. break;
  79. default:
  80. _menuPosition = 'auto';
  81. }
  82. return {
  83. _menuPosition,
  84. _showLocalVideoFlipButton: !disableLocalVideoFlip && videoTrack?.videoType !== 'desktop',
  85. _overflowDrawer: overflowDrawer
  86. };
  87. }
  88. export default connect(_mapStateToProps)(LocalVideoMenuTriggerButton);