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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. * Redux store dispatch method.
  18. */
  19. dispatch: IStore['dispatch'];
  20. }
  21. /**
  22. * Authentication message dialog for host confirmation.
  23. *
  24. * @returns {React$Element<any>}
  25. */
  26. class WaitForOwnerDialog extends PureComponent<IProps> {
  27. /**
  28. * Instantiates a new component.
  29. *
  30. * @param {Object} props - The read-only properties with which the new
  31. * instance is to be initialized.
  32. */
  33. constructor(props: IProps) {
  34. super(props);
  35. this._onCancelWaitForOwner = this._onCancelWaitForOwner.bind(this);
  36. this._onIAmHost = this._onIAmHost.bind(this);
  37. }
  38. /**
  39. * Called when the cancel button is clicked.
  40. *
  41. * @private
  42. * @returns {void}
  43. */
  44. _onCancelWaitForOwner() {
  45. const { dispatch } = this.props;
  46. dispatch(cancelWaitForOwner());
  47. }
  48. /**
  49. * Called when the OK button is clicked.
  50. *
  51. * @private
  52. * @returns {void}
  53. */
  54. _onIAmHost() {
  55. this.props.dispatch(login());
  56. }
  57. /**
  58. * Implements React's {@link Component#render()}.
  59. *
  60. * @inheritdoc
  61. */
  62. render() {
  63. const {
  64. t
  65. } = this.props;
  66. return (
  67. <Dialog
  68. cancel = {{ translationKey:
  69. this.props._alternativeCancelText ? 'dialog.WaitingForHostButton' : 'dialog.Cancel' }}
  70. disableBackdropClose = { true }
  71. hideCloseButton = { true }
  72. ok = {{ translationKey: 'dialog.IamHost' }}
  73. onCancel = { this._onCancelWaitForOwner }
  74. onSubmit = { this._onIAmHost }
  75. titleKey = { t('dialog.WaitingForHostTitle') }>
  76. <span>
  77. { t('dialog.WaitForHostMsg') }
  78. </span>
  79. </Dialog>
  80. );
  81. }
  82. }
  83. /**
  84. * Maps (parts of) the redux state to the associated
  85. * {@code WaitForOwnerDialog}'s props.
  86. *
  87. * @param {Object} state - The redux state.
  88. * @private
  89. * @returns {IProps}
  90. */
  91. function mapStateToProps(state: IReduxState) {
  92. const { membersOnly, lobbyWaitingForHost } = state['features/base/conference'];
  93. return {
  94. _alternativeCancelText: membersOnly && lobbyWaitingForHost
  95. };
  96. }
  97. export default translate(connect(mapStateToProps)(WaitForOwnerDialog));