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.

VideoSettingsPopup.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // @flow
  2. import React from 'react';
  3. import {
  4. setVideoInputDeviceAndUpdateSettings
  5. } from '../../../../base/devices/actions.web';
  6. import {
  7. getVideoDeviceIds
  8. } from '../../../../base/devices/functions.web';
  9. import Popover from '../../../../base/popover/components/Popover.web';
  10. import { connect } from '../../../../base/redux';
  11. import { SMALL_MOBILE_WIDTH } from '../../../../base/responsive-ui/constants';
  12. import { getCurrentCameraDeviceId } from '../../../../base/settings';
  13. import { toggleVideoSettings } from '../../../actions';
  14. import { getVideoSettingsVisibility } from '../../../functions';
  15. import VideoSettingsContent, { type Props as VideoSettingsProps } from './VideoSettingsContent';
  16. type Props = VideoSettingsProps & {
  17. /**
  18. * Component children (the Video button).
  19. */
  20. children: React$Node,
  21. /**
  22. * Flag controlling the visibility of the popup.
  23. */
  24. isOpen: boolean,
  25. /**
  26. * Callback executed when the popup closes.
  27. */
  28. onClose: Function,
  29. /**
  30. * The popup placement enum value.
  31. */
  32. popupPlacement: string
  33. }
  34. /**
  35. * Popup with a preview of all the video devices.
  36. *
  37. * @returns {ReactElement}
  38. */
  39. function VideoSettingsPopup({
  40. currentCameraDeviceId,
  41. children,
  42. isOpen,
  43. onClose,
  44. popupPlacement,
  45. setVideoInputDevice,
  46. videoDeviceIds
  47. }: Props) {
  48. return (
  49. <div className = 'video-preview'>
  50. <Popover
  51. content = { <VideoSettingsContent
  52. currentCameraDeviceId = { currentCameraDeviceId }
  53. setVideoInputDevice = { setVideoInputDevice }
  54. toggleVideoSettings = { onClose }
  55. videoDeviceIds = { videoDeviceIds } /> }
  56. onPopoverClose = { onClose }
  57. position = { popupPlacement }
  58. trigger = 'click'
  59. visible = { isOpen }>
  60. { children }
  61. </Popover>
  62. </div>
  63. );
  64. }
  65. /**
  66. * Maps (parts of) the redux state to the associated {@code VideoSettingsPopup}'s
  67. * props.
  68. *
  69. * @param {Object} state - Redux state.
  70. * @returns {Object}
  71. */
  72. function mapStateToProps(state) {
  73. const { clientWidth } = state['features/base/responsive-ui'];
  74. return {
  75. currentCameraDeviceId: getCurrentCameraDeviceId(state),
  76. isOpen: getVideoSettingsVisibility(state),
  77. popupPlacement: clientWidth <= SMALL_MOBILE_WIDTH ? 'auto' : 'top-end',
  78. videoDeviceIds: getVideoDeviceIds(state)
  79. };
  80. }
  81. const mapDispatchToProps = {
  82. onClose: toggleVideoSettings,
  83. setVideoInputDevice: setVideoInputDeviceAndUpdateSettings
  84. };
  85. export default connect(mapStateToProps, mapDispatchToProps)(VideoSettingsPopup);