Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

JoinByPhoneDialog.tsx 6.2KB

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