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.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import type { Dispatch } from 'redux';
  4. import { Dialog } from '../../../base/dialog';
  5. import { translate, translateToHTML } from '../../../base/i18n';
  6. import { connect } from '../../../base/redux';
  7. import { cancelWaitForOwner } from '../../actions.web';
  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 method.
  18. */
  19. dispatch: Dispatch<any>,
  20. /**
  21. * Function to be invoked after click.
  22. */
  23. onAuthNow: ?Function,
  24. /**
  25. * Invoked to obtain translated strings.
  26. */
  27. t: Function
  28. }
  29. /**
  30. * Authentication message dialog for host confirmation.
  31. *
  32. * @returns {React$Element<any>}
  33. */
  34. class WaitForOwnerDialog extends PureComponent<Props> {
  35. /**
  36. * Instantiates a new component.
  37. *
  38. * @param {Object} props - The read-only properties with which the new
  39. * instance is to be initialized.
  40. */
  41. constructor(props: Props) {
  42. super(props);
  43. this._onCancelWaitForOwner = this._onCancelWaitForOwner.bind(this);
  44. this._onIAmHost = this._onIAmHost.bind(this);
  45. }
  46. _onCancelWaitForOwner: () => void;
  47. /**
  48. * Called when the cancel button is clicked.
  49. *
  50. * @private
  51. * @returns {void}
  52. */
  53. _onCancelWaitForOwner() {
  54. const { dispatch } = this.props;
  55. const cancelButton = document.getElementById('modal-dialog-cancel-button');
  56. if (cancelButton) {
  57. cancelButton.onclick = () => {
  58. dispatch(cancelWaitForOwner());
  59. };
  60. }
  61. return false;
  62. }
  63. _onIAmHost: () => void;
  64. /**
  65. * Called when the OK button is clicked.
  66. *
  67. * @private
  68. * @returns {void}
  69. */
  70. _onIAmHost() {
  71. const { onAuthNow } = this.props;
  72. onAuthNow && onAuthNow();
  73. }
  74. /**
  75. * Implements React's {@link Component#render()}.
  76. *
  77. * @inheritdoc
  78. */
  79. render() {
  80. const {
  81. _room: room,
  82. t
  83. } = this.props;
  84. return (
  85. <Dialog
  86. hideCloseIconButton = { true }
  87. okKey = { t('dialog.IamHost') }
  88. onCancel = { this._onCancelWaitForOwner }
  89. onSubmit = { this._onIAmHost }
  90. titleKey = { t('dialog.WaitingForHostTitle') }
  91. width = { 'small' }>
  92. <span>
  93. {
  94. translateToHTML(
  95. t, 'dialog.WaitForHostMsg', { room })
  96. }
  97. </span>
  98. </Dialog>
  99. );
  100. }
  101. }
  102. /**
  103. * Maps (parts of) the Redux state to the associated props for the
  104. * {@code WaitForOwnerDialog} component.
  105. *
  106. * @param {Object} state - The Redux state.
  107. * @private
  108. * @returns {Props}
  109. */
  110. function mapStateToProps(state) {
  111. const { authRequired } = state['features/base/conference'];
  112. return {
  113. _room: authRequired && authRequired.getName()
  114. };
  115. }
  116. export default translate(connect(mapStateToProps)(WaitForOwnerDialog));