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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. cancelKey = 'dialog.Cancel'
  57. contentKey = {
  58. {
  59. key: 'dialog.WaitForHostMsgWOk',
  60. params: { room }
  61. }
  62. }
  63. okKey = 'dialog.Ok'
  64. onCancel = { this._onCancel }
  65. onSubmit = { this._onLogin } />
  66. );
  67. }
  68. _onCancel: () => void;
  69. /**
  70. * Called when the cancel button is clicked.
  71. *
  72. * @private
  73. * @returns {void}
  74. */
  75. _onCancel() {
  76. this.props.dispatch(cancelWaitForOwner());
  77. }
  78. _onLogin: () => void;
  79. /**
  80. * Called when the OK button is clicked.
  81. *
  82. * @private
  83. * @returns {void}
  84. */
  85. _onLogin() {
  86. this.props.dispatch(_openLoginDialog());
  87. }
  88. }
  89. /**
  90. * Maps (parts of) the Redux state to the associated props for the
  91. * {@code WaitForOwnerDialog} component.
  92. *
  93. * @param {Object} state - The Redux state.
  94. * @private
  95. * @returns {{
  96. * _room: string
  97. * }}
  98. */
  99. function _mapStateToProps(state) {
  100. const { authRequired } = state['features/base/conference'];
  101. return {
  102. _room: authRequired && authRequired.getName()
  103. };
  104. }
  105. export default translate(connect(_mapStateToProps)(WaitForOwnerDialog));