您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Prejoin.js 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. // @flow
  2. import InlineDialog from '@atlaskit/inline-dialog';
  3. import React, { Component } from 'react';
  4. import { getRoomName } from '../../base/conference';
  5. import { translate } from '../../base/i18n';
  6. import { Icon, IconPhone, IconVolumeOff } from '../../base/icons';
  7. import { isVideoMutedByUser } from '../../base/media';
  8. import { ActionButton, InputField, PreMeetingScreen } from '../../base/premeeting';
  9. import { connect } from '../../base/redux';
  10. import { getDisplayName, updateSettings } from '../../base/settings';
  11. import { getLocalJitsiVideoTrack } from '../../base/tracks';
  12. import {
  13. joinConference as joinConferenceAction,
  14. joinConferenceWithoutAudio as joinConferenceWithoutAudioAction,
  15. setSkipPrejoin as setSkipPrejoinAction,
  16. setJoinByPhoneDialogVisiblity as setJoinByPhoneDialogVisiblityAction
  17. } from '../actions';
  18. import {
  19. isJoinByPhoneButtonVisible,
  20. isDeviceStatusVisible,
  21. isJoinByPhoneDialogVisible
  22. } from '../functions';
  23. import JoinByPhoneDialog from './dialogs/JoinByPhoneDialog';
  24. import DeviceStatus from './preview/DeviceStatus';
  25. type Props = {
  26. /**
  27. * Flag signaling if the device status is visible or not.
  28. */
  29. deviceStatusVisible: boolean,
  30. /**
  31. * If join by phone button should be visible.
  32. */
  33. hasJoinByPhoneButton: boolean,
  34. /**
  35. * Joins the current meeting.
  36. */
  37. joinConference: Function,
  38. /**
  39. * Joins the current meeting without audio.
  40. */
  41. joinConferenceWithoutAudio: Function,
  42. /**
  43. * The name of the user that is about to join.
  44. */
  45. name: string,
  46. /**
  47. * Updates settings.
  48. */
  49. updateSettings: Function,
  50. /**
  51. * The name of the meeting that is about to be joined.
  52. */
  53. roomName: string,
  54. /**
  55. * Sets visibility of the prejoin page for the next sessions.
  56. */
  57. setSkipPrejoin: Function,
  58. /**
  59. * Sets visibility of the 'JoinByPhoneDialog'.
  60. */
  61. setJoinByPhoneDialogVisiblity: Function,
  62. /**
  63. * Flag signaling the visibility of camera preview.
  64. */
  65. showCameraPreview: boolean,
  66. /**
  67. * If 'JoinByPhoneDialog' is visible or not.
  68. */
  69. showDialog: boolean,
  70. /**
  71. * Used for translation.
  72. */
  73. t: Function,
  74. /**
  75. * The JitsiLocalTrack to display.
  76. */
  77. videoTrack: ?Object,
  78. };
  79. type State = {
  80. /**
  81. * Flag controlling the visibility of the 'join by phone' buttons.
  82. */
  83. showJoinByPhoneButtons: boolean
  84. }
  85. /**
  86. * This component is displayed before joining a meeting.
  87. */
  88. class Prejoin extends Component<Props, State> {
  89. /**
  90. * Initializes a new {@code Prejoin} instance.
  91. *
  92. * @inheritdoc
  93. */
  94. constructor(props) {
  95. super(props);
  96. this.state = {
  97. showJoinByPhoneButtons: false
  98. };
  99. this._closeDialog = this._closeDialog.bind(this);
  100. this._showDialog = this._showDialog.bind(this);
  101. this._onCheckboxChange = this._onCheckboxChange.bind(this);
  102. this._onDropdownClose = this._onDropdownClose.bind(this);
  103. this._onOptionsClick = this._onOptionsClick.bind(this);
  104. this._setName = this._setName.bind(this);
  105. }
  106. _onCheckboxChange: () => void;
  107. /**
  108. * Handler for the checkbox.
  109. *
  110. * @param {Object} e - The synthetic event.
  111. * @returns {void}
  112. */
  113. _onCheckboxChange(e) {
  114. this.props.setSkipPrejoin(e.target.checked);
  115. }
  116. _onDropdownClose: () => void;
  117. /**
  118. * Closes the dropdown.
  119. *
  120. * @returns {void}
  121. */
  122. _onDropdownClose() {
  123. this.setState({
  124. showJoinByPhoneButtons: false
  125. });
  126. }
  127. _onOptionsClick: () => void;
  128. /**
  129. * Displays the join by phone buttons dropdown.
  130. *
  131. * @param {Object} e - The synthetic event.
  132. * @returns {void}
  133. */
  134. _onOptionsClick(e) {
  135. e.stopPropagation();
  136. this.setState({
  137. showJoinByPhoneButtons: !this.state.showJoinByPhoneButtons
  138. });
  139. }
  140. _setName: () => void;
  141. /**
  142. * Sets the guest participant name.
  143. *
  144. * @param {string} displayName - Participant name.
  145. * @returns {void}
  146. */
  147. _setName(displayName) {
  148. this.props.updateSettings({
  149. displayName
  150. });
  151. }
  152. _closeDialog: () => void;
  153. /**
  154. * Closes the join by phone dialog.
  155. *
  156. * @returns {undefined}
  157. */
  158. _closeDialog() {
  159. this.props.setJoinByPhoneDialogVisiblity(false);
  160. }
  161. _showDialog: () => void;
  162. /**
  163. * Displays the dialog for joining a meeting by phone.
  164. *
  165. * @returns {undefined}
  166. */
  167. _showDialog() {
  168. this.props.setJoinByPhoneDialogVisiblity(true);
  169. this._onDropdownClose();
  170. }
  171. /**
  172. * Implements React's {@link Component#render()}.
  173. *
  174. * @inheritdoc
  175. * @returns {ReactElement}
  176. */
  177. render() {
  178. const {
  179. hasJoinByPhoneButton,
  180. joinConference,
  181. joinConferenceWithoutAudio,
  182. name,
  183. showCameraPreview,
  184. showDialog,
  185. t,
  186. videoTrack
  187. } = this.props;
  188. const { _closeDialog, _onCheckboxChange, _onDropdownClose, _onOptionsClick, _setName, _showDialog } = this;
  189. const { showJoinByPhoneButtons } = this.state;
  190. return (
  191. <PreMeetingScreen
  192. footer = { this._renderFooter() }
  193. title = { t('prejoin.joinMeeting') }
  194. videoMuted = { !showCameraPreview }
  195. videoTrack = { videoTrack }>
  196. <div className = 'prejoin-input-area-container'>
  197. <div className = 'prejoin-input-area'>
  198. <InputField
  199. onChange = { _setName }
  200. onSubmit = { joinConference }
  201. placeHolder = { t('dialog.enterDisplayName') }
  202. value = { name } />
  203. <div className = 'prejoin-preview-dropdown-container'>
  204. <InlineDialog
  205. content = { <div className = 'prejoin-preview-dropdown-btns'>
  206. <div
  207. className = 'prejoin-preview-dropdown-btn'
  208. onClick = { joinConferenceWithoutAudio }>
  209. <Icon
  210. className = 'prejoin-preview-dropdown-icon'
  211. size = { 24 }
  212. src = { IconVolumeOff } />
  213. { t('prejoin.joinWithoutAudio') }
  214. </div>
  215. {hasJoinByPhoneButton && <div
  216. className = 'prejoin-preview-dropdown-btn'
  217. onClick = { _showDialog }>
  218. <Icon
  219. className = 'prejoin-preview-dropdown-icon'
  220. size = { 24 }
  221. src = { IconPhone } />
  222. { t('prejoin.joinAudioByPhone') }
  223. </div>}
  224. </div> }
  225. isOpen = { showJoinByPhoneButtons }
  226. onClose = { _onDropdownClose }>
  227. <ActionButton
  228. disabled = { !name }
  229. hasOptions = { true }
  230. onClick = { joinConference }
  231. onOptionsClick = { _onOptionsClick }
  232. type = 'primary'>
  233. { t('prejoin.joinMeeting') }
  234. </ActionButton>
  235. </InlineDialog>
  236. </div>
  237. </div>
  238. <div className = 'prejoin-checkbox-container'>
  239. <input
  240. className = 'prejoin-checkbox'
  241. onChange = { _onCheckboxChange }
  242. type = 'checkbox' />
  243. <span>{t('prejoin.doNotShow')}</span>
  244. </div>
  245. </div>
  246. { showDialog && (
  247. <JoinByPhoneDialog
  248. joinConferenceWithoutAudio = { joinConferenceWithoutAudio }
  249. onClose = { _closeDialog } />
  250. )}
  251. </PreMeetingScreen>
  252. );
  253. }
  254. /**
  255. * Renders the screen footer if any.
  256. *
  257. * @returns {React$Element}
  258. */
  259. _renderFooter() {
  260. return this.props.deviceStatusVisible && <DeviceStatus />;
  261. }
  262. }
  263. /**
  264. * Maps (parts of) the redux state to the React {@code Component} props.
  265. *
  266. * @param {Object} state - The redux state.
  267. * @returns {Object}
  268. */
  269. function mapStateToProps(state): Object {
  270. return {
  271. deviceStatusVisible: isDeviceStatusVisible(state),
  272. name: getDisplayName(state),
  273. roomName: getRoomName(state),
  274. showDialog: isJoinByPhoneDialogVisible(state),
  275. hasJoinByPhoneButton: isJoinByPhoneButtonVisible(state),
  276. showCameraPreview: !isVideoMutedByUser(state),
  277. videoTrack: getLocalJitsiVideoTrack(state)
  278. };
  279. }
  280. const mapDispatchToProps = {
  281. joinConferenceWithoutAudio: joinConferenceWithoutAudioAction,
  282. joinConference: joinConferenceAction,
  283. setJoinByPhoneDialogVisiblity: setJoinByPhoneDialogVisiblityAction,
  284. setSkipPrejoin: setSkipPrejoinAction,
  285. updateSettings
  286. };
  287. export default connect(mapStateToProps, mapDispatchToProps)(translate(Prejoin));