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

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