2018-10-30 05:02:23 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2017-10-20 00:17:38 +00:00
|
|
|
import Spinner from '@atlaskit/spinner';
|
2017-03-30 16:58:31 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-04-06 16:45:36 +00:00
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
import DesktopSourcePreview from './DesktopSourcePreview';
|
|
|
|
|
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The type of the React {@code Component} props of {@link DesktopPickerPane}.
|
2017-03-30 16:58:31 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
type Props = {
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The handler to be invoked when a DesktopSourcePreview is clicked.
|
|
|
|
*/
|
|
|
|
onClick: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The handler to be invoked when a DesktopSourcePreview is double clicked.
|
|
|
|
*/
|
|
|
|
onDoubleClick: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The id of the DesktopCapturerSource that is currently selected.
|
2017-03-30 16:58:31 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
selectedSourceId: string,
|
2017-03-30 16:58:31 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* An array of DesktopCapturerSources.
|
|
|
|
*/
|
|
|
|
sources: Array<Object>,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The source type of the DesktopCapturerSources to display.
|
|
|
|
*/
|
|
|
|
type: string
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React component for showing a grid of DesktopSourcePreviews.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
|
|
|
class DesktopPickerPane extends Component<Props> {
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2017-04-06 16:45:36 +00:00
|
|
|
const {
|
|
|
|
onClick,
|
|
|
|
onDoubleClick,
|
|
|
|
selectedSourceId,
|
|
|
|
sources,
|
|
|
|
type
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const classNames
|
|
|
|
= `desktop-picker-pane default-scrollbar source-type-${type}`;
|
|
|
|
const previews
|
2018-08-06 16:09:32 +00:00
|
|
|
= sources
|
|
|
|
? sources.map(source => (
|
2017-04-06 16:45:36 +00:00
|
|
|
<DesktopSourcePreview
|
|
|
|
key = { source.id }
|
|
|
|
onClick = { onClick }
|
|
|
|
onDoubleClick = { onDoubleClick }
|
|
|
|
selected = { source.id === selectedSourceId }
|
2017-07-07 22:45:24 +00:00
|
|
|
source = { source }
|
2018-08-06 16:09:32 +00:00
|
|
|
type = { type } />))
|
|
|
|
: (
|
2017-10-20 00:17:38 +00:00
|
|
|
<div className = 'desktop-picker-pane-spinner'>
|
|
|
|
<Spinner
|
|
|
|
isCompleting = { false }
|
|
|
|
size = 'medium' />
|
|
|
|
</div>
|
|
|
|
);
|
2017-03-30 16:58:31 +00:00
|
|
|
|
|
|
|
return (
|
2017-04-06 16:45:36 +00:00
|
|
|
<div className = { classNames }>
|
2017-03-30 16:58:31 +00:00
|
|
|
{ previews }
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DesktopPickerPane;
|