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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. dispatch(cancelWaitForOwner());
  57. }
  58. _onIAmHost: () => void;
  59. /**
  60. * Called when the OK button is clicked.
  61. *
  62. * @private
  63. * @returns {void}
  64. */
  65. _onIAmHost() {
  66. const { onAuthNow } = this.props;
  67. onAuthNow && onAuthNow();
  68. }
  69. /**
  70. * Implements React's {@link Component#render()}.
  71. *
  72. * @inheritdoc
  73. */
  74. render() {
  75. const {
  76. _room: room,
  77. t
  78. } = this.props;
  79. return (
  80. <Dialog
  81. disableBlanketClickDismiss = { true }
  82. hideCloseIconButton = { true }
  83. okKey = { t('dialog.IamHost') }
  84. onCancel = { this._onCancelWaitForOwner }
  85. onSubmit = { this._onIAmHost }
  86. titleKey = { t('dialog.WaitingForHostTitle') }
  87. width = { 'small' }>
  88. <span>
  89. {
  90. translateToHTML(
  91. t, 'dialog.WaitForHostMsg', { room })
  92. }
  93. </span>
  94. </Dialog>
  95. );
  96. }
  97. }
  98. /**
  99. * Maps (parts of) the Redux state to the associated props for the
  100. * {@code WaitForOwnerDialog} component.
  101. *
  102. * @param {Object} state - The Redux state.
  103. * @private
  104. * @returns {Props}
  105. */
  106. function mapStateToProps(state) {
  107. const { authRequired } = state['features/base/conference'];
  108. return {
  109. _room: authRequired && safeDecodeURIComponent(authRequired.getName())
  110. };
  111. }
  112. export default translate(connect(mapStateToProps)(WaitForOwnerDialog));