2020-03-30 14:17:18 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import InlineDialog from '@atlaskit/inline-dialog';
|
2020-05-20 10:57:03 +00:00
|
|
|
import React from 'react';
|
2020-03-30 14:17:18 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
getVideoDeviceIds,
|
2020-04-14 06:53:04 +00:00
|
|
|
setVideoInputDeviceAndUpdateSettings
|
2020-03-30 14:17:18 +00:00
|
|
|
} from '../../../../base/devices';
|
|
|
|
import { connect } from '../../../../base/redux';
|
|
|
|
import { getCurrentCameraDeviceId } from '../../../../base/settings';
|
2020-05-20 10:57:03 +00:00
|
|
|
import { toggleVideoSettings } from '../../../actions';
|
|
|
|
import { getVideoSettingsVisibility } from '../../../functions';
|
|
|
|
|
2020-03-30 14:17:18 +00:00
|
|
|
import VideoSettingsContent, { type Props as VideoSettingsProps } from './VideoSettingsContent';
|
|
|
|
|
|
|
|
|
|
|
|
type Props = VideoSettingsProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component children (the Video button).
|
|
|
|
*/
|
|
|
|
children: React$Node,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag controlling the visibility of the popup.
|
|
|
|
*/
|
|
|
|
isOpen: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback executed when the popup closes.
|
|
|
|
*/
|
|
|
|
onClose: Function,
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Popup with a preview of all the video devices.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
function VideoSettingsPopup({
|
|
|
|
currentCameraDeviceId,
|
|
|
|
children,
|
|
|
|
isOpen,
|
|
|
|
onClose,
|
|
|
|
setVideoInputDevice,
|
|
|
|
videoDeviceIds
|
|
|
|
}: Props) {
|
|
|
|
return (
|
|
|
|
<div className = 'video-preview'>
|
|
|
|
<InlineDialog
|
|
|
|
content = { <VideoSettingsContent
|
|
|
|
currentCameraDeviceId = { currentCameraDeviceId }
|
|
|
|
setVideoInputDevice = { setVideoInputDevice }
|
|
|
|
toggleVideoSettings = { onClose }
|
|
|
|
videoDeviceIds = { videoDeviceIds } /> }
|
|
|
|
isOpen = { isOpen }
|
|
|
|
onClose = { onClose }
|
|
|
|
position = 'top right'>
|
|
|
|
{ children }
|
|
|
|
</InlineDialog>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated {@code VideoSettingsPopup}'s
|
|
|
|
* props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
currentCameraDeviceId: getCurrentCameraDeviceId(state),
|
|
|
|
isOpen: getVideoSettingsVisibility(state),
|
|
|
|
videoDeviceIds: getVideoDeviceIds(state)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = {
|
|
|
|
onClose: toggleVideoSettings,
|
2020-04-14 06:53:04 +00:00
|
|
|
setVideoInputDevice: setVideoInputDeviceAndUpdateSettings
|
2020-03-30 14:17:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(VideoSettingsPopup);
|