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.

DesktopPickerPane.tsx 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import React, { Component } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { translate } from '../../base/i18n/functions';
  4. import Platform from '../../base/react/Platform.web';
  5. import Checkbox from '../../base/ui/components/web/Checkbox';
  6. import Spinner from '../../base/ui/components/web/Spinner';
  7. import DesktopSourcePreview from './DesktopSourcePreview';
  8. /**
  9. * The type of the React {@code Component} props of {@link DesktopPickerPane}.
  10. */
  11. interface IProps extends WithTranslation {
  12. /**
  13. * The handler to be invoked when a DesktopSourcePreview is clicked.
  14. */
  15. onClick: Function;
  16. /**
  17. * The handler to be invoked when a DesktopSourcePreview is double clicked.
  18. */
  19. onDoubleClick: Function;
  20. /**
  21. * The handler to be invoked if the users checks the audio screen sharing checkbox.
  22. */
  23. onShareAudioChecked: Function;
  24. /**
  25. * The id of the DesktopCapturerSource that is currently selected.
  26. */
  27. selectedSourceId: string;
  28. /**
  29. * An array of DesktopCapturerSources.
  30. */
  31. sources: Array<any>;
  32. /**
  33. * The source type of the DesktopCapturerSources to display.
  34. */
  35. type: string;
  36. }
  37. /**
  38. * React component for showing a grid of DesktopSourcePreviews.
  39. *
  40. * @augments Component
  41. */
  42. class DesktopPickerPane extends Component<IProps> {
  43. /**
  44. * Initializes a new DesktopPickerPane instance.
  45. *
  46. * @param {Object} props - The read-only properties with which the new
  47. * instance is to be initialized.
  48. */
  49. constructor(props: IProps) {
  50. super(props);
  51. this._onShareAudioCheck = this._onShareAudioCheck.bind(this);
  52. }
  53. /**
  54. * Function to be called when the Checkbox is used.
  55. *
  56. * @param {boolean} checked - Checkbox status (checked or not).
  57. * @returns {void}
  58. */
  59. _onShareAudioCheck({ target: { checked } }: { target: { checked: boolean; }; }) {
  60. this.props.onShareAudioChecked(checked);
  61. }
  62. /**
  63. * Implements React's {@link Component#render()}.
  64. *
  65. * @inheritdoc
  66. * @returns {ReactElement}
  67. */
  68. render() {
  69. const {
  70. onClick,
  71. onDoubleClick,
  72. selectedSourceId,
  73. sources,
  74. type,
  75. t
  76. } = this.props;
  77. const classNames
  78. = `desktop-picker-pane default-scrollbar source-type-${type}`;
  79. const previews
  80. = sources
  81. ? sources.map(source => (
  82. <DesktopSourcePreview
  83. key = { source.id }
  84. onClick = { onClick }
  85. onDoubleClick = { onDoubleClick }
  86. selected = { source.id === selectedSourceId }
  87. source = { source }
  88. type = { type } />))
  89. : (
  90. <div className = 'desktop-picker-pane-spinner'>
  91. <Spinner />
  92. </div>
  93. );
  94. let checkBox;
  95. // Only display the share audio checkbox if we're on windows and on
  96. // desktop sharing tab.
  97. // App window and Mac OS screen sharing doesn't work with system audio.
  98. if (type === 'screen' && Platform.OS === 'windows') {
  99. checkBox = (<Checkbox
  100. label = { t('dialog.screenSharingAudio') }
  101. name = 'share-system-audio'
  102. onChange = { this._onShareAudioCheck } />);
  103. }
  104. return (
  105. <div className = { classNames }>
  106. { previews }
  107. { checkBox }
  108. </div>
  109. );
  110. }
  111. }
  112. export default translate(DesktopPickerPane);