Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

WaitForOwnerDialog.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 } from '../../actions.native';
  8. import LoginDialog from './LoginDialog';
  9. /**
  10. * The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
  11. */
  12. type Props = {
  13. /**
  14. * Redux store dispatch function.
  15. */
  16. dispatch: Dispatch<any>,
  17. /**
  18. * Invoked to obtain translated strings.
  19. */
  20. t: Function
  21. };
  22. /**
  23. * The dialog is display in XMPP password + guest access configuration, after
  24. * user connects from anonymous domain and the conference does not exist yet.
  25. *
  26. * See {@link LoginDialog} description for more details.
  27. */
  28. class WaitForOwnerDialog extends Component<Props> {
  29. /**
  30. * Initializes a new WaitForWonderDialog instance.
  31. *
  32. * @param {Object} props - The read-only properties with which the new
  33. * instance is to be initialized.
  34. */
  35. constructor(props) {
  36. super(props);
  37. this.state = {
  38. showLoginDialog: false
  39. };
  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. this._onLoginDialogCancel = this._onLoginDialogCancel.bind(this);
  44. }
  45. /**
  46. * Implements React's {@link Component#render()}.
  47. *
  48. * @inheritdoc
  49. * @returns {ReactElement}
  50. */
  51. render() {
  52. return (
  53. <ConfirmDialog
  54. cancelLabel = 'dialog.Cancel'
  55. confirmLabel = 'dialog.IamHost'
  56. descriptionKey = 'dialog.WaitForHostMsg'
  57. onCancel = { this._onCancel }
  58. onSubmit = { this._onLogin }>
  59. <LoginDialog
  60. // eslint-disable-next-line react/jsx-handler-names
  61. _onCancel = { this._onLoginDialogCancel }
  62. visible = { this.state.showLoginDialog } />
  63. </ConfirmDialog>
  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.setState({ showLoginDialog: true });
  85. }
  86. /**
  87. * Called when the nested login dialog is cancelled.
  88. *
  89. * @private
  90. * @returns {void}
  91. */
  92. _onLoginDialogCancel() {
  93. this.setState({ showLoginDialog: false });
  94. }
  95. }
  96. export default translate(connect()(WaitForOwnerDialog));