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.2KB

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