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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import type { Dispatch } from 'redux';
  4. import { Dialog } from '../../../base/dialog';
  5. import { translate } from '../../../base/i18n';
  6. import { connect } from '../../../base/redux';
  7. import { cancelWaitForOwner } from '../../actions.web';
  8. /**
  9. * The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
  10. */
  11. type Props = {
  12. /**
  13. * Redux store dispatch method.
  14. */
  15. dispatch: Dispatch<any>,
  16. /**
  17. * Function to be invoked after click.
  18. */
  19. onAuthNow: ?Function,
  20. /**
  21. * Invoked to obtain translated strings.
  22. */
  23. t: Function
  24. }
  25. /**
  26. * Authentication message dialog for host confirmation.
  27. *
  28. * @returns {React$Element<any>}
  29. */
  30. class WaitForOwnerDialog extends PureComponent<Props> {
  31. /**
  32. * Instantiates a new component.
  33. *
  34. * @param {Object} props - The read-only properties with which the new
  35. * instance is to be initialized.
  36. */
  37. constructor(props: Props) {
  38. super(props);
  39. this._onCancelWaitForOwner = this._onCancelWaitForOwner.bind(this);
  40. this._onIAmHost = this._onIAmHost.bind(this);
  41. }
  42. _onCancelWaitForOwner: () => void;
  43. /**
  44. * Called when the cancel button is clicked.
  45. *
  46. * @private
  47. * @returns {void}
  48. */
  49. _onCancelWaitForOwner() {
  50. const { dispatch } = this.props;
  51. dispatch(cancelWaitForOwner());
  52. }
  53. _onIAmHost: () => void;
  54. /**
  55. * Called when the OK button is clicked.
  56. *
  57. * @private
  58. * @returns {void}
  59. */
  60. _onIAmHost() {
  61. const { onAuthNow } = this.props;
  62. onAuthNow && onAuthNow();
  63. }
  64. /**
  65. * Implements React's {@link Component#render()}.
  66. *
  67. * @inheritdoc
  68. */
  69. render() {
  70. const {
  71. t
  72. } = this.props;
  73. return (
  74. <Dialog
  75. disableBlanketClickDismiss = { true }
  76. hideCloseIconButton = { true }
  77. okKey = { t('dialog.IamHost') }
  78. onCancel = { this._onCancelWaitForOwner }
  79. onSubmit = { this._onIAmHost }
  80. titleKey = { t('dialog.WaitingForHostTitle') }
  81. width = { 'small' }>
  82. <span>
  83. { t('dialog.WaitForHostMsg') }
  84. </span>
  85. </Dialog>
  86. );
  87. }
  88. }
  89. export default translate(connect()(WaitForOwnerDialog));