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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* @flow */
  2. import { Checkbox } from '@atlaskit/checkbox';
  3. import Spinner from '@atlaskit/spinner';
  4. import React, { Component } from 'react';
  5. import { translate } from '../../base/i18n';
  6. import { Platform } from '../../base/react';
  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. * @extends 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. isCompleting = { false }
  98. size = 'medium' />
  99. </div>
  100. );
  101. let checkBox;
  102. // Only display the share audio checkbox if we're on windows and on
  103. // desktop sharing tab.
  104. // App window and Mac OS screen sharing doesn't work with system audio.
  105. if (type === 'screen' && Platform.OS === 'windows') {
  106. checkBox = (<Checkbox
  107. label = { t('dialog.screenSharingAudio') }
  108. name = 'share-system-audio'
  109. onChange = { this._onShareAudioCheck } />);
  110. }
  111. return (
  112. <div className = { classNames }>
  113. { previews }
  114. { checkBox }
  115. </div>
  116. );
  117. }
  118. }
  119. export default translate(DesktopPickerPane);