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.tsx 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React, { PureComponent } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { connect } from 'react-redux';
  4. import { 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. * Redux store dispatch method.
  14. */
  15. dispatch: IStore['dispatch'];
  16. }
  17. /**
  18. * Authentication message dialog for host confirmation.
  19. *
  20. * @returns {React$Element<any>}
  21. */
  22. class WaitForOwnerDialog extends PureComponent<IProps> {
  23. /**
  24. * Instantiates a new component.
  25. *
  26. * @param {Object} props - The read-only properties with which the new
  27. * instance is to be initialized.
  28. */
  29. constructor(props: IProps) {
  30. super(props);
  31. this._onCancelWaitForOwner = this._onCancelWaitForOwner.bind(this);
  32. this._onIAmHost = this._onIAmHost.bind(this);
  33. }
  34. /**
  35. * Called when the cancel button is clicked.
  36. *
  37. * @private
  38. * @returns {void}
  39. */
  40. _onCancelWaitForOwner() {
  41. const { dispatch } = this.props;
  42. dispatch(cancelWaitForOwner());
  43. }
  44. /**
  45. * Called when the OK button is clicked.
  46. *
  47. * @private
  48. * @returns {void}
  49. */
  50. _onIAmHost() {
  51. this.props.dispatch(login());
  52. }
  53. /**
  54. * Implements React's {@link Component#render()}.
  55. *
  56. * @inheritdoc
  57. */
  58. render() {
  59. const {
  60. t
  61. } = this.props;
  62. return (
  63. <Dialog
  64. disableBackdropClose = { true }
  65. hideCloseButton = { true }
  66. ok = {{ translationKey: 'dialog.IamHost' }}
  67. onCancel = { this._onCancelWaitForOwner }
  68. onSubmit = { this._onIAmHost }
  69. titleKey = { t('dialog.WaitingForHostTitle') }>
  70. <span>
  71. { t('dialog.WaitForHostMsg') }
  72. </span>
  73. </Dialog>
  74. );
  75. }
  76. }
  77. export default translate(connect()(WaitForOwnerDialog));