Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

WaitForOwnerDialog.tsx 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import React, { PureComponent } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { connect } from 'react-redux';
  4. import { IReduxState, IStore } from '../../../app/types';
  5. import { translate } from '../../../base/i18n/functions';
  6. import Dialog from '../../../base/ui/components/web/Dialog';
  7. import { cancelWaitForOwner, login } from '../../actions.web';
  8. /**
  9. * The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
  10. */
  11. interface IProps extends WithTranslation {
  12. /**
  13. * Whether to show alternative cancel button text.
  14. */
  15. _alternativeCancelText?: boolean;
  16. /**
  17. * Whether to hide the login button.
  18. */
  19. _hideLoginButton?: boolean;
  20. /**
  21. * Redux store dispatch method.
  22. */
  23. dispatch: IStore['dispatch'];
  24. }
  25. /**
  26. * Authentication message dialog for host confirmation.
  27. *
  28. * @returns {React$Element<any>}
  29. */
  30. class WaitForOwnerDialog extends PureComponent<IProps> {
  31. /**
  32. * Instantiates a new component.
  33. *
  34. * @param {Object} props - The read-only properties with which the new
  35. * instance is to be initialized.
  36. */
  37. constructor(props: IProps) {
  38. super(props);
  39. this._onCancelWaitForOwner = this._onCancelWaitForOwner.bind(this);
  40. this._onIAmHost = this._onIAmHost.bind(this);
  41. }
  42. /**
  43. * Called when the cancel button is clicked.
  44. *
  45. * @private
  46. * @returns {void}
  47. */
  48. _onCancelWaitForOwner() {
  49. const { dispatch } = this.props;
  50. dispatch(cancelWaitForOwner());
  51. }
  52. /**
  53. * Called when the OK button is clicked.
  54. *
  55. * @private
  56. * @returns {void}
  57. */
  58. _onIAmHost() {
  59. this.props.dispatch(login());
  60. }
  61. /**
  62. * Implements React's {@link Component#render()}.
  63. *
  64. * @inheritdoc
  65. */
  66. render() {
  67. const {
  68. t
  69. } = this.props;
  70. return (
  71. <Dialog
  72. cancel = {{ translationKey:
  73. this.props._alternativeCancelText ? 'dialog.WaitingForHostButton' : 'dialog.Cancel' }}
  74. disableBackdropClose = { true }
  75. hideCloseButton = { true }
  76. ok = { this.props._hideLoginButton ? { hidden: true,
  77. disabled: true } : { translationKey: 'dialog.IamHost' } }
  78. onCancel = { this._onCancelWaitForOwner }
  79. onSubmit = { this._onIAmHost }
  80. titleKey = { t('dialog.WaitingForHostTitle') }>
  81. <span>
  82. { this.props._hideLoginButton ? t('dialog.WaitForHostNoAuthMsg') : t('dialog.WaitForHostMsg') }
  83. </span>
  84. </Dialog>
  85. );
  86. }
  87. }
  88. /**
  89. * Maps (parts of) the redux state to the associated
  90. * {@code WaitForOwnerDialog}'s props.
  91. *
  92. * @param {Object} state - The redux state.
  93. * @private
  94. * @returns {IProps}
  95. */
  96. function mapStateToProps(state: IReduxState) {
  97. const { membersOnly, lobbyWaitingForHost } = state['features/base/conference'];
  98. const { hideLoginButton } = state['features/base/config'];
  99. return {
  100. _alternativeCancelText: membersOnly && lobbyWaitingForHost,
  101. _hideLoginButton: hideLoginButton
  102. };
  103. }
  104. export default translate(connect(mapStateToProps)(WaitForOwnerDialog));