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.

Prejoin.js 9.7KB

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