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.

OverlayContainer.js 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* global APP */
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import PageReloadOverlay from './PageReloadOverlay';
  5. import SuspendedOverlay from './SuspendedOverlay';
  6. import UserMediaPermissionsOverlay from './UserMediaPermissionsOverlay';
  7. /**
  8. * Implements a React Component that will display the correct overlay when
  9. * needed.
  10. */
  11. class OverlayContainer extends Component {
  12. /**
  13. * OverlayContainer component's property types.
  14. *
  15. * @static
  16. */
  17. static propTypes = {
  18. /**
  19. * The browser which is used currently.
  20. * NOTE: Used by UserMediaPermissionsOverlay only.
  21. * @private
  22. * @type {string}
  23. */
  24. _browser: React.PropTypes.string,
  25. /**
  26. * The indicator which determines whether the status of
  27. * JitsiConnection object has been "established" or not.
  28. * NOTE: Used by PageReloadOverlay only.
  29. * @private
  30. * @type {boolean}
  31. */
  32. _connectionEstablished: React.PropTypes.bool,
  33. /**
  34. * The indicator which determines whether a critical error for reload
  35. * has been received.
  36. * NOTE: Used by PageReloadOverlay only.
  37. * @private
  38. * @type {boolean}
  39. */
  40. _haveToReload: React.PropTypes.bool,
  41. /**
  42. * The indicator which determines whether the reload was caused by
  43. * network failure.
  44. * NOTE: Used by PageReloadOverlay only.
  45. * @private
  46. * @type {boolean}
  47. */
  48. _isNetworkFailure: React.PropTypes.bool,
  49. /**
  50. * The indicator which determines whether the GUM permissions prompt
  51. * is displayed or not.
  52. * NOTE: Used by UserMediaPermissionsOverlay only.
  53. * @private
  54. * @type {boolean}
  55. */
  56. _mediaPermissionPromptVisible: React.PropTypes.bool,
  57. /**
  58. * The reason for the error that will cause the reload.
  59. * NOTE: Used by PageReloadOverlay only.
  60. * @private
  61. * @type {string}
  62. */
  63. _reason: React.PropTypes.string,
  64. /**
  65. * The indicator which determines whether the GUM permissions prompt
  66. * is displayed or not.
  67. * NOTE: Used by SuspendedOverlay only.
  68. * @private
  69. * @type {string}
  70. */
  71. _suspendDetected: React.PropTypes.bool
  72. }
  73. /**
  74. * React Component method that executes once component is updated.
  75. *
  76. * @inheritdoc
  77. * @returns {void}
  78. * @protected
  79. */
  80. componentDidUpdate() {
  81. // FIXME: Temporary workaround until everything is moved to react.
  82. APP.UI.overlayVisible
  83. = (this.props._connectionEstablished && this.props._haveToReload)
  84. || this.props._suspendDetected
  85. || this.props._mediaPermissionPromptVisible;
  86. }
  87. /**
  88. * Implements React's {@link Component#render()}.
  89. *
  90. * @inheritdoc
  91. * @returns {ReactElement|null}
  92. * @public
  93. */
  94. render() {
  95. if (this.props._connectionEstablished && this.props._haveToReload) {
  96. return (
  97. <PageReloadOverlay
  98. isNetworkFailure = { this.props._isNetworkFailure }
  99. reason = { this.props._reason } />
  100. );
  101. }
  102. if (this.props._suspendDetected) {
  103. return (
  104. <SuspendedOverlay />
  105. );
  106. }
  107. if (this.props._mediaPermissionPromptVisible) {
  108. return (
  109. <UserMediaPermissionsOverlay
  110. browser = { this.props._browser } />
  111. );
  112. }
  113. return null;
  114. }
  115. }
  116. /**
  117. * Maps (parts of) the Redux state to the associated OverlayContainer's props.
  118. *
  119. * @param {Object} state - The Redux state.
  120. * @returns {{
  121. * _browser: string,
  122. * _connectionEstablished: bool,
  123. * _haveToReload: bool,
  124. * _isNetworkFailure: bool,
  125. * _mediaPermissionPromptVisible: bool,
  126. * _reason: string,
  127. * _suspendDetected: bool
  128. * }}
  129. * @private
  130. */
  131. function _mapStateToProps(state) {
  132. return {
  133. /**
  134. * The browser which is used currently.
  135. * NOTE: Used by UserMediaPermissionsOverlay only.
  136. * @private
  137. * @type {string}
  138. */
  139. _browser: state['features/overlay'].browser,
  140. /**
  141. * The indicator which determines whether the status of
  142. * JitsiConnection object has been "established" or not.
  143. * NOTE: Used by PageReloadOverlay only.
  144. * @private
  145. * @type {boolean}
  146. */
  147. _connectionEstablished:
  148. state['features/overlay'].connectionEstablished,
  149. /**
  150. * The indicator which determines whether a critical error for reload
  151. * has been received.
  152. * NOTE: Used by PageReloadOverlay only.
  153. * @private
  154. * @type {boolean}
  155. */
  156. _haveToReload: state['features/overlay'].haveToReload,
  157. /**
  158. * The indicator which determines whether the reload was caused by
  159. * network failure.
  160. * NOTE: Used by PageReloadOverlay only.
  161. * @private
  162. * @type {boolean}
  163. */
  164. _isNetworkFailure: state['features/overlay'].isNetworkFailure,
  165. /**
  166. * The indicator which determines whether the GUM permissions prompt
  167. * is displayed or not.
  168. * NOTE: Used by UserMediaPermissionsOverlay only.
  169. * @private
  170. * @type {boolean}
  171. */
  172. _mediaPermissionPromptVisible:
  173. state['features/overlay'].mediaPermissionPromptVisible,
  174. /**
  175. * The reason for the error that will cause the reload.
  176. * NOTE: Used by PageReloadOverlay only.
  177. * @private
  178. * @type {string}
  179. */
  180. _reason: state['features/overlay'].reason,
  181. /**
  182. * The indicator which determines whether the GUM permissions prompt
  183. * is displayed or not.
  184. * NOTE: Used by SuspendedOverlay only.
  185. * @private
  186. * @type {string}
  187. */
  188. _suspendDetected: state['features/overlay'].suspendDetected
  189. };
  190. }
  191. export default connect(_mapStateToProps)(OverlayContainer);