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.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { translate } from '../../base/i18n';
  4. import { Platform } from '../../base/react';
  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. type Props = {
  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<Object>,
  32. /**
  33. * The source type of the DesktopCapturerSources to display.
  34. */
  35. type: string,
  36. /**
  37. * Used to obtain translations.
  38. */
  39. t: Function
  40. };
  41. /**
  42. * React component for showing a grid of DesktopSourcePreviews.
  43. *
  44. * @augments Component
  45. */
  46. class DesktopPickerPane extends Component<Props> {
  47. /**
  48. * Initializes a new DesktopPickerPane instance.
  49. *
  50. * @param {Object} props - The read-only properties with which the new
  51. * instance is to be initialized.
  52. */
  53. constructor(props: Props) {
  54. super(props);
  55. this._onShareAudioCheck = this._onShareAudioCheck.bind(this);
  56. }
  57. _onShareAudioCheck: (Object) => void;
  58. /**
  59. * Function to be called when the Checkbox is used.
  60. *
  61. * @param {boolean} checked - Checkbox status (checked or not).
  62. * @returns {void}
  63. */
  64. _onShareAudioCheck({ target: { checked } }) {
  65. this.props.onShareAudioChecked(checked);
  66. }
  67. /**
  68. * Implements React's {@link Component#render()}.
  69. *
  70. * @inheritdoc
  71. * @returns {ReactElement}
  72. */
  73. render() {
  74. const {
  75. onClick,
  76. onDoubleClick,
  77. selectedSourceId,
  78. sources,
  79. type,
  80. t
  81. } = this.props;
  82. const classNames
  83. = `desktop-picker-pane default-scrollbar source-type-${type}`;
  84. const previews
  85. = sources
  86. ? sources.map(source => (
  87. <DesktopSourcePreview
  88. key = { source.id }
  89. onClick = { onClick }
  90. onDoubleClick = { onDoubleClick }
  91. selected = { source.id === selectedSourceId }
  92. source = { source }
  93. type = { type } />))
  94. : (
  95. <div className = 'desktop-picker-pane-spinner'>
  96. <Spinner />
  97. </div>
  98. );
  99. let checkBox;
  100. // Only display the share audio checkbox if we're on windows and on
  101. // desktop sharing tab.
  102. // App window and Mac OS screen sharing doesn't work with system audio.
  103. if (type === 'screen' && Platform.OS === 'windows') {
  104. checkBox = (<Checkbox
  105. label = { t('dialog.screenSharingAudio') }
  106. name = 'share-system-audio'
  107. onChange = { this._onShareAudioCheck } />);
  108. }
  109. return (
  110. <div className = { classNames }>
  111. { previews }
  112. { checkBox }
  113. </div>
  114. );
  115. }
  116. }
  117. export default translate(DesktopPickerPane);