Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

WaitForOwnerDialog.tsx 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import { IReduxState, IStore } from '../../../app/types';
  4. import ConfirmDialog from '../../../base/dialog/components/native/ConfirmDialog';
  5. import { translate } from '../../../base/i18n/functions';
  6. import { cancelWaitForOwner, login } from '../../actions.native';
  7. /**
  8. * The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
  9. */
  10. interface IProps {
  11. /**
  12. * Whether to show alternative cancel button text.
  13. */
  14. _alternativeCancelText?: boolean;
  15. /**
  16. * Is confirm button hidden?
  17. */
  18. _isConfirmHidden?: boolean;
  19. /**
  20. * Redux store dispatch function.
  21. */
  22. dispatch: IStore['dispatch'];
  23. /**
  24. * Invoked to obtain translated strings.
  25. */
  26. t: Function;
  27. }
  28. /**
  29. * The dialog is display in XMPP password + guest access configuration, after
  30. * user connects from anonymous domain and the conference does not exist yet.
  31. *
  32. * See {@link LoginDialog} description for more details.
  33. */
  34. class WaitForOwnerDialog extends Component<IProps> {
  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: IProps) {
  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 { _isConfirmHidden } = this.props;
  55. return (
  56. <ConfirmDialog
  57. cancelLabel = { this.props._alternativeCancelText ? 'dialog.WaitingForHostButton' : 'dialog.Cancel' }
  58. confirmLabel = 'dialog.IamHost'
  59. descriptionKey = 'dialog.WaitForHostMsg'
  60. isConfirmHidden = { _isConfirmHidden }
  61. onCancel = { this._onCancel }
  62. onSubmit = { this._onLogin } />
  63. );
  64. }
  65. /**
  66. * Called when the cancel button is clicked.
  67. *
  68. * @private
  69. * @returns {void}
  70. */
  71. _onCancel() {
  72. this.props.dispatch(cancelWaitForOwner());
  73. }
  74. /**
  75. * Called when the OK button is clicked.
  76. *
  77. * @private
  78. * @returns {void}
  79. */
  80. _onLogin() {
  81. this.props.dispatch(login());
  82. }
  83. }
  84. /**
  85. * Maps (parts of) the redux state to the associated
  86. * {@code WaitForOwnerDialog}'s props.
  87. *
  88. * @param {Object} state - The redux state.
  89. * @private
  90. * @returns {IProps}
  91. */
  92. function mapStateToProps(state: IReduxState) {
  93. const { membersOnly, lobbyWaitingForHost } = state['features/base/conference'];
  94. const { locationURL } = state['features/base/connection'];
  95. return {
  96. _alternativeCancelText: membersOnly && lobbyWaitingForHost,
  97. _isConfirmHidden: locationURL?.hostname?.includes('8x8.vc')
  98. };
  99. }
  100. export default translate(connect(mapStateToProps)(WaitForOwnerDialog));