Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Prejoin.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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, ToggleButton } 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. isDeviceStatusVisible,
  20. isDisplayNameRequired,
  21. isJoinByPhoneButtonVisible,
  22. isJoinByPhoneDialogVisible,
  23. isPrejoinSkipped
  24. } from '../functions';
  25. import JoinByPhoneDialog from './dialogs/JoinByPhoneDialog';
  26. import DeviceStatus from './preview/DeviceStatus';
  27. type Props = {
  28. /**
  29. * Flag signaling if the 'skip prejoin' button is toggled or not.
  30. */
  31. buttonIsToggled: boolean,
  32. /**
  33. * Flag signaling if the device status is visible or not.
  34. */
  35. deviceStatusVisible: boolean,
  36. /**
  37. * If join by phone button should be visible.
  38. */
  39. hasJoinByPhoneButton: boolean,
  40. /**
  41. * If join button is disabled or not.
  42. */
  43. joinButtonDisabled: boolean,
  44. /**
  45. * Joins the current meeting.
  46. */
  47. joinConference: Function,
  48. /**
  49. * Joins the current meeting without audio.
  50. */
  51. joinConferenceWithoutAudio: Function,
  52. /**
  53. * The name of the user that is about to join.
  54. */
  55. name: string,
  56. /**
  57. * Updates settings.
  58. */
  59. updateSettings: Function,
  60. /**
  61. * The name of the meeting that is about to be joined.
  62. */
  63. roomName: string,
  64. /**
  65. * Sets visibility of the prejoin page for the next sessions.
  66. */
  67. setSkipPrejoin: Function,
  68. /**
  69. * Sets visibility of the 'JoinByPhoneDialog'.
  70. */
  71. setJoinByPhoneDialogVisiblity: Function,
  72. /**
  73. * Indicates whether the avatar should be shown when video is off
  74. */
  75. showAvatar: boolean,
  76. /**
  77. * Flag signaling the visibility of camera preview.
  78. */
  79. showCameraPreview: boolean,
  80. /**
  81. * Flag signaling the visibility of join label, input and buttons
  82. */
  83. showJoinActions: boolean,
  84. /**
  85. * If 'JoinByPhoneDialog' is visible or not.
  86. */
  87. showDialog: boolean,
  88. /**
  89. * Flag signaling the visibility of the skip prejoin toggle
  90. */
  91. showSkipPrejoin: boolean,
  92. /**
  93. * Used for translation.
  94. */
  95. t: Function,
  96. /**
  97. * The JitsiLocalTrack to display.
  98. */
  99. videoTrack: ?Object,
  100. };
  101. type State = {
  102. /**
  103. * Flag controlling the visibility of the 'join by phone' buttons.
  104. */
  105. showJoinByPhoneButtons: boolean
  106. }
  107. /**
  108. * This component is displayed before joining a meeting.
  109. */
  110. class Prejoin extends Component<Props, State> {
  111. /**
  112. * Default values for {@code Prejoin} component's properties.
  113. *
  114. * @static
  115. */
  116. static defaultProps = {
  117. showJoinActions: true,
  118. showSkipPrejoin: true
  119. };
  120. /**
  121. * Initializes a new {@code Prejoin} instance.
  122. *
  123. * @inheritdoc
  124. */
  125. constructor(props) {
  126. super(props);
  127. this.state = {
  128. showJoinByPhoneButtons: false
  129. };
  130. this._closeDialog = this._closeDialog.bind(this);
  131. this._showDialog = this._showDialog.bind(this);
  132. this._onToggleButtonClick = this._onToggleButtonClick.bind(this);
  133. this._onDropdownClose = this._onDropdownClose.bind(this);
  134. this._onOptionsClick = this._onOptionsClick.bind(this);
  135. this._setName = this._setName.bind(this);
  136. }
  137. _onToggleButtonClick: () => void;
  138. /**
  139. * Handler for the toggle button.
  140. *
  141. * @param {Object} e - The synthetic event.
  142. * @returns {void}
  143. */
  144. _onToggleButtonClick() {
  145. this.props.setSkipPrejoin(!this.props.buttonIsToggled);
  146. }
  147. _onDropdownClose: () => void;
  148. /**
  149. * Closes the dropdown.
  150. *
  151. * @returns {void}
  152. */
  153. _onDropdownClose() {
  154. this.setState({
  155. showJoinByPhoneButtons: false
  156. });
  157. }
  158. _onOptionsClick: () => void;
  159. /**
  160. * Displays the join by phone buttons dropdown.
  161. *
  162. * @param {Object} e - The synthetic event.
  163. * @returns {void}
  164. */
  165. _onOptionsClick(e) {
  166. e.stopPropagation();
  167. this.setState({
  168. showJoinByPhoneButtons: !this.state.showJoinByPhoneButtons
  169. });
  170. }
  171. _setName: () => void;
  172. /**
  173. * Sets the guest participant name.
  174. *
  175. * @param {string} displayName - Participant name.
  176. * @returns {void}
  177. */
  178. _setName(displayName) {
  179. this.props.updateSettings({
  180. displayName
  181. });
  182. }
  183. _closeDialog: () => void;
  184. /**
  185. * Closes the join by phone dialog.
  186. *
  187. * @returns {undefined}
  188. */
  189. _closeDialog() {
  190. this.props.setJoinByPhoneDialogVisiblity(false);
  191. }
  192. _showDialog: () => void;
  193. /**
  194. * Displays the dialog for joining a meeting by phone.
  195. *
  196. * @returns {undefined}
  197. */
  198. _showDialog() {
  199. this.props.setJoinByPhoneDialogVisiblity(true);
  200. this._onDropdownClose();
  201. }
  202. /**
  203. * Implements React's {@link Component#render()}.
  204. *
  205. * @inheritdoc
  206. * @returns {ReactElement}
  207. */
  208. render() {
  209. const {
  210. joinButtonDisabled,
  211. hasJoinByPhoneButton,
  212. joinConference,
  213. joinConferenceWithoutAudio,
  214. name,
  215. showAvatar,
  216. showCameraPreview,
  217. showDialog,
  218. showJoinActions,
  219. t,
  220. videoTrack
  221. } = this.props;
  222. const { _closeDialog, _onDropdownClose, _onOptionsClick, _setName, _showDialog } = this;
  223. const { showJoinByPhoneButtons } = this.state;
  224. return (
  225. <PreMeetingScreen
  226. footer = { this._renderFooter() }
  227. name = { name }
  228. showAvatar = { showAvatar }
  229. showConferenceInfo = { showJoinActions }
  230. skipPrejoinButton = { this._renderSkipPrejoinButton() }
  231. title = { t('prejoin.joinMeeting') }
  232. videoMuted = { !showCameraPreview }
  233. videoTrack = { videoTrack }>
  234. {showJoinActions && (
  235. <div className = 'prejoin-input-area-container'>
  236. <div className = 'prejoin-input-area'>
  237. <InputField
  238. onChange = { _setName }
  239. onSubmit = { joinConference }
  240. placeHolder = { t('dialog.enterDisplayName') }
  241. value = { name } />
  242. <div className = 'prejoin-preview-dropdown-container'>
  243. <InlineDialog
  244. content = { <div className = 'prejoin-preview-dropdown-btns'>
  245. <div
  246. className = 'prejoin-preview-dropdown-btn'
  247. onClick = { joinConferenceWithoutAudio }>
  248. <Icon
  249. className = 'prejoin-preview-dropdown-icon'
  250. size = { 24 }
  251. src = { IconVolumeOff } />
  252. { t('prejoin.joinWithoutAudio') }
  253. </div>
  254. {hasJoinByPhoneButton && <div
  255. className = 'prejoin-preview-dropdown-btn'
  256. onClick = { _showDialog }>
  257. <Icon
  258. className = 'prejoin-preview-dropdown-icon'
  259. size = { 24 }
  260. src = { IconPhone } />
  261. { t('prejoin.joinAudioByPhone') }
  262. </div>}
  263. </div> }
  264. isOpen = { showJoinByPhoneButtons }
  265. onClose = { _onDropdownClose }>
  266. <ActionButton
  267. disabled = { joinButtonDisabled }
  268. hasOptions = { true }
  269. onClick = { joinConference }
  270. onOptionsClick = { _onOptionsClick }
  271. type = 'primary'>
  272. { t('prejoin.joinMeeting') }
  273. </ActionButton>
  274. </InlineDialog>
  275. </div>
  276. </div>
  277. </div>
  278. )}
  279. { showDialog && (
  280. <JoinByPhoneDialog
  281. joinConferenceWithoutAudio = { joinConferenceWithoutAudio }
  282. onClose = { _closeDialog } />
  283. )}
  284. </PreMeetingScreen>
  285. );
  286. }
  287. /**
  288. * Renders the screen footer if any.
  289. *
  290. * @returns {React$Element}
  291. */
  292. _renderFooter() {
  293. return this.props.deviceStatusVisible && <DeviceStatus />;
  294. }
  295. /**
  296. * Renders the 'skip prejoin' button.
  297. *
  298. * @returns {React$Element}
  299. */
  300. _renderSkipPrejoinButton() {
  301. const { buttonIsToggled, t, showSkipPrejoin } = this.props;
  302. if (!showSkipPrejoin) {
  303. return null;
  304. }
  305. return (
  306. <div className = 'prejoin-checkbox-container'>
  307. <ToggleButton
  308. isToggled = { buttonIsToggled }
  309. onClick = { this._onToggleButtonClick }>
  310. {t('prejoin.doNotShow')}
  311. </ToggleButton>
  312. </div>
  313. );
  314. }
  315. }
  316. /**
  317. * Maps (parts of) the redux state to the React {@code Component} props.
  318. *
  319. * @param {Object} state - The redux state.
  320. * @returns {Object}
  321. */
  322. function mapStateToProps(state): Object {
  323. const name = getDisplayName(state);
  324. const joinButtonDisabled = isDisplayNameRequired(state) && !name;
  325. return {
  326. buttonIsToggled: isPrejoinSkipped(state),
  327. joinButtonDisabled,
  328. name,
  329. deviceStatusVisible: isDeviceStatusVisible(state),
  330. roomName: getRoomName(state),
  331. showDialog: isJoinByPhoneDialogVisible(state),
  332. hasJoinByPhoneButton: isJoinByPhoneButtonVisible(state),
  333. showCameraPreview: !isVideoMutedByUser(state),
  334. videoTrack: getLocalJitsiVideoTrack(state)
  335. };
  336. }
  337. const mapDispatchToProps = {
  338. joinConferenceWithoutAudio: joinConferenceWithoutAudioAction,
  339. joinConference: joinConferenceAction,
  340. setJoinByPhoneDialogVisiblity: setJoinByPhoneDialogVisiblityAction,
  341. setSkipPrejoin: setSkipPrejoinAction,
  342. updateSettings
  343. };
  344. export default connect(mapStateToProps, mapDispatchToProps)(translate(Prejoin));