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.

WaitForOwnerDialog.native.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { Text } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import { Dialog } from '../../base/dialog';
  6. import { translate } from '../../base/i18n';
  7. import { cancelWaitForOwner, _openLoginDialog } from '../actions';
  8. import styles from './styles';
  9. /**
  10. * The dialog is display in XMPP password + guest access configuration, after
  11. * user connects from anonymous domain and the conference does not exist yet.
  12. *
  13. * See {@link LoginDialog} description for more details.
  14. */
  15. class WaitForOwnerDialog extends Component {
  16. /**
  17. * WaitForOwnerDialog component's property types.
  18. *
  19. * @static
  20. */
  21. static propTypes = {
  22. /**
  23. * The name of the conference room (without the domain part).
  24. */
  25. _room: PropTypes.string,
  26. /**
  27. * Redux store dispatch function.
  28. */
  29. dispatch: PropTypes.func,
  30. /**
  31. * Invoked to obtain translated strings.
  32. */
  33. t: PropTypes.func
  34. };
  35. /**
  36. * Initializes a new WaitForWonderDialog instance.
  37. *
  38. * @param {Object} props - The read-only properties with which the new
  39. * instance is to be initialized.
  40. */
  41. constructor(props) {
  42. super(props);
  43. // Bind event handlers so they are only bound once per instance.
  44. this._onCancel = this._onCancel.bind(this);
  45. this._onLogin = this._onLogin.bind(this);
  46. }
  47. /**
  48. * Implements React's {@link Component#render()}.
  49. *
  50. * @inheritdoc
  51. * @returns {ReactElement}
  52. */
  53. render() {
  54. const {
  55. _room: room,
  56. t
  57. } = this.props;
  58. return (
  59. <Dialog
  60. okTitleKey = { 'dialog.IamHost' }
  61. onCancel = { this._onCancel }
  62. onSubmit = { this._onLogin }
  63. titleKey = 'dialog.WaitingForHost'>
  64. <Text style = { styles.waitForOwnerDialog }>
  65. {
  66. this._renderHTML(t('dialog.WaitForHostMsg', { room }))
  67. }
  68. </Text>
  69. </Dialog>
  70. );
  71. }
  72. /**
  73. * Called when the cancel button is clicked.
  74. *
  75. * @private
  76. * @returns {void}
  77. */
  78. _onCancel() {
  79. this.props.dispatch(cancelWaitForOwner());
  80. }
  81. /**
  82. * Called when the OK button is clicked.
  83. *
  84. * @private
  85. * @returns {void}
  86. */
  87. _onLogin() {
  88. this.props.dispatch(_openLoginDialog());
  89. }
  90. /**
  91. * Renders a specific <tt>string</tt> which may contain HTML.
  92. *
  93. * @param {string} html - The <tt>string</tt> which may contain HTML to
  94. * render.
  95. * @returns {string}
  96. */
  97. _renderHTML(html) {
  98. if (typeof html === 'string') {
  99. // TODO Limited styling may easily be provided by utilizing Text
  100. // with style.
  101. return html.replace(/<\/?b>/gi, '');
  102. }
  103. return html;
  104. }
  105. }
  106. /**
  107. * Maps (parts of) the Redux state to the associated props for the
  108. * {@code WaitForOwnerDialog} component.
  109. *
  110. * @param {Object} state - The Redux state.
  111. * @private
  112. * @returns {{
  113. * _room: string
  114. * }}
  115. */
  116. function _mapStateToProps(state) {
  117. const {
  118. authRequired
  119. } = state['features/base/conference'];
  120. return {
  121. _room: authRequired && authRequired.getName()
  122. };
  123. }
  124. export default translate(connect(_mapStateToProps)(WaitForOwnerDialog));