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.5KB

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