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

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