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 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // @flow
  2. import React, { Component } from 'react';
  3. import type { Dispatch } from 'redux';
  4. import { ConfirmDialog } from '../../base/dialog';
  5. import { translate } from '../../base/i18n';
  6. import { connect } from '../../base/redux';
  7. import { cancelWaitForOwner, _openLoginDialog } from '../actions';
  8. /**
  9. * The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
  10. */
  11. type Props = {
  12. /**
  13. * The name of the conference room (without the domain part).
  14. */
  15. _room: string,
  16. /**
  17. * Redux store dispatch function.
  18. */
  19. dispatch: Dispatch<any>,
  20. /**
  21. * Invoked to obtain translated strings.
  22. */
  23. t: Function
  24. };
  25. /**
  26. * The dialog is display in XMPP password + guest access configuration, after
  27. * user connects from anonymous domain and the conference does not exist yet.
  28. *
  29. * See {@link LoginDialog} description for more details.
  30. */
  31. class WaitForOwnerDialog extends Component<Props> {
  32. /**
  33. * Initializes a new WaitForWonderDialog instance.
  34. *
  35. * @param {Object} props - The read-only properties with which the new
  36. * instance is to be initialized.
  37. */
  38. constructor(props) {
  39. super(props);
  40. // Bind event handlers so they are only bound once per instance.
  41. this._onCancel = this._onCancel.bind(this);
  42. this._onLogin = this._onLogin.bind(this);
  43. }
  44. /**
  45. * Implements React's {@link Component#render()}.
  46. *
  47. * @inheritdoc
  48. * @returns {ReactElement}
  49. */
  50. render() {
  51. const {
  52. _room: room
  53. } = this.props;
  54. return (
  55. <ConfirmDialog
  56. contentKey = {
  57. {
  58. key: 'dialog.WaitForHostMsgWOk',
  59. params: { room }
  60. }
  61. }
  62. onCancel = { this._onCancel }
  63. onSubmit = { this._onLogin } />
  64. );
  65. }
  66. _onCancel: () => void;
  67. /**
  68. * Called when the cancel button is clicked.
  69. *
  70. * @private
  71. * @returns {void}
  72. */
  73. _onCancel() {
  74. this.props.dispatch(cancelWaitForOwner());
  75. }
  76. _onLogin: () => void;
  77. /**
  78. * Called when the OK button is clicked.
  79. *
  80. * @private
  81. * @returns {void}
  82. */
  83. _onLogin() {
  84. this.props.dispatch(_openLoginDialog());
  85. }
  86. }
  87. /**
  88. * Maps (parts of) the Redux state to the associated props for the
  89. * {@code WaitForOwnerDialog} component.
  90. *
  91. * @param {Object} state - The Redux state.
  92. * @private
  93. * @returns {{
  94. * _room: string
  95. * }}
  96. */
  97. function _mapStateToProps(state) {
  98. const { authRequired } = state['features/base/conference'];
  99. return {
  100. _room: authRequired && authRequired.getName()
  101. };
  102. }
  103. export default translate(connect(_mapStateToProps)(WaitForOwnerDialog));