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.

JoinByPhoneDialog.js 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { connect } from '../../../base/redux';
  4. import {
  5. getConferenceId,
  6. getDefaultDialInNumber,
  7. updateDialInNumbers
  8. } from '../../../invite';
  9. import {
  10. dialOut as dialOutAction,
  11. joinConferenceWithoutAudio as joinConferenceWithoutAudioAction,
  12. openDialInPage as openDialInPageAction
  13. } from '../../actions';
  14. import { getDialOutStatus, getFullDialOutNumber } from '../../functions';
  15. import CallingDialog from './CallingDialog';
  16. import DialInDialog from './DialInDialog';
  17. import DialOutDialog from './DialOutDialog';
  18. type Props = {
  19. /**
  20. * The number to call in order to join the conference.
  21. */
  22. dialInNumber: string,
  23. /**
  24. * The status of the call when the meeting calss the user.
  25. */
  26. dialOutStatus: string,
  27. /**
  28. * The action by which the meeting calls the user.
  29. */
  30. dialOut: Function,
  31. /**
  32. * The number the conference should call.
  33. */
  34. dialOutNumber: string,
  35. /**
  36. * Fetches conference dial in numbers & conference id
  37. */
  38. fetchConferenceDetails: Function,
  39. /**
  40. * Joins the conference without audio.
  41. */
  42. joinConferenceWithoutAudio: Function,
  43. /**
  44. * Closes the dialog.
  45. */
  46. onClose: Function,
  47. /**
  48. * Opens a web page with all the dial in numbers.
  49. */
  50. openDialInPage: Function,
  51. /**
  52. * The passCode of the conference used when joining a meeting by phone.
  53. */
  54. passCode: string,
  55. };
  56. type State = {
  57. /**
  58. * The dialout call is ongoing, 'CallingDialog' is shown;
  59. */
  60. isCalling: boolean,
  61. /**
  62. * If should show 'DialInDialog'.
  63. */
  64. showDialIn: boolean,
  65. /**
  66. * If should show 'DialOutDialog'.
  67. */
  68. showDialOut: boolean
  69. }
  70. /**
  71. * This is the dialog shown when a user wants to join with phone audio.
  72. */
  73. class JoinByPhoneDialog extends PureComponent<Props, State> {
  74. /**
  75. * Initializes a new {@code JoinByPhoneDialog} instance.
  76. *
  77. * @param {Props} props - The props of the component.
  78. * @inheritdoc
  79. */
  80. constructor(props) {
  81. super(props);
  82. this.state = {
  83. isCalling: false,
  84. showDialOut: true,
  85. showDialIn: false
  86. };
  87. this._dialOut = this._dialOut.bind(this);
  88. this._showDialInDialog = this._showDialInDialog.bind(this);
  89. this._showDialOutDialog = this._showDialOutDialog.bind(this);
  90. }
  91. _dialOut: () => void;
  92. /**
  93. * Meeting calls the user & shows the 'CallingDialog'.
  94. *
  95. * @returns {void}
  96. */
  97. _dialOut() {
  98. const { dialOut, joinConferenceWithoutAudio } = this.props;
  99. this.setState({
  100. isCalling: true,
  101. showDialOut: false,
  102. showDialIn: false
  103. });
  104. dialOut(joinConferenceWithoutAudio, this._showDialOutDialog);
  105. }
  106. _showDialInDialog: () => void;
  107. /**
  108. * Shows the 'DialInDialog'.
  109. *
  110. * @returns {void}
  111. */
  112. _showDialInDialog() {
  113. this.setState({
  114. isCalling: false,
  115. showDialOut: false,
  116. showDialIn: true
  117. });
  118. }
  119. _showDialOutDialog: () => void;
  120. /**
  121. * Shows the 'DialOutDialog'.
  122. *
  123. * @returns {void}
  124. */
  125. _showDialOutDialog() {
  126. this.setState({
  127. isCalling: false,
  128. showDialOut: true,
  129. showDialIn: false
  130. });
  131. }
  132. /**
  133. * Implements React's {@link Component#componentDidMount()}.
  134. *
  135. * @inheritdoc
  136. */
  137. componentDidMount() {
  138. this.props.fetchConferenceDetails();
  139. }
  140. /**
  141. * Implements React's {@link Component#render()}.
  142. *
  143. * @inheritdoc
  144. * @returns {ReactElement}
  145. */
  146. render() {
  147. const {
  148. dialOutStatus,
  149. dialInNumber,
  150. dialOutNumber,
  151. joinConferenceWithoutAudio,
  152. passCode,
  153. onClose,
  154. openDialInPage
  155. } = this.props;
  156. const {
  157. _dialOut,
  158. _showDialInDialog,
  159. _showDialOutDialog
  160. } = this;
  161. const { isCalling, showDialOut, showDialIn } = this.state;
  162. const className = isCalling
  163. ? 'prejoin-dialog prejoin-dialog--small'
  164. : 'prejoin-dialog';
  165. return (
  166. <div className = 'prejoin-dialog-container'>
  167. <div className = { className }>
  168. {showDialOut && (
  169. <DialOutDialog
  170. onClose = { onClose }
  171. onSubmit = { _dialOut }
  172. onTextButtonClick = { _showDialInDialog } />
  173. )}
  174. {showDialIn && (
  175. <DialInDialog
  176. number = { dialInNumber }
  177. onBack = { _showDialOutDialog }
  178. onPrimaryButtonClick = { joinConferenceWithoutAudio }
  179. onSmallTextClick = { openDialInPage }
  180. onTextButtonClick = { onClose }
  181. passCode = { passCode } />
  182. )}
  183. {isCalling && (
  184. <CallingDialog
  185. number = { dialOutNumber }
  186. onClose = { onClose }
  187. status = { dialOutStatus } />
  188. )}
  189. </div>
  190. </div>
  191. );
  192. }
  193. }
  194. /**
  195. * Maps (parts of) the redux state to the React {@code Component} props.
  196. *
  197. * @param {Object} state - The redux state.
  198. * @returns {Object}
  199. */
  200. function mapStateToProps(state): Object {
  201. return {
  202. dialInNumber: getDefaultDialInNumber(state),
  203. dialOutNumber: getFullDialOutNumber(state),
  204. dialOutStatus: getDialOutStatus(state),
  205. passCode: getConferenceId(state)
  206. };
  207. }
  208. const mapDispatchToProps = {
  209. dialOut: dialOutAction,
  210. fetchConferenceDetails: updateDialInNumbers,
  211. joinConferenceWithoutAudio: joinConferenceWithoutAudioAction,
  212. openDialInPage: openDialInPageAction
  213. };
  214. export default connect(mapStateToProps, mapDispatchToProps)(JoinByPhoneDialog);