Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

PasswordRequiredPrompt.native.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // @flow
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { connect } from 'react-redux';
  5. import { setPassword } from '../../base/conference';
  6. import { Dialog } from '../../base/dialog';
  7. /**
  8. * {@code PasswordRequiredPrompt}'s React {@code Component} prop types.
  9. */
  10. type Props = {
  11. /**
  12. * The {@code JitsiConference} which requires a password.
  13. *
  14. * @type {JitsiConference}
  15. */
  16. conference: { join: Function },
  17. dispatch: Dispatch<*>
  18. };
  19. /**
  20. * Implements a React {@code Component} which prompts the user when a password
  21. * is required to join a conference.
  22. */
  23. class PasswordRequiredPrompt extends Component {
  24. /**
  25. * {@code PasswordRequiredPrompt}'s React {@code Component} prop types.
  26. *
  27. * @static
  28. */
  29. static propTypes = {
  30. conference: PropTypes.object,
  31. dispatch: PropTypes.func
  32. };
  33. /**
  34. * Initializes a new {@code PasswordRequiredPrompt} instance.
  35. *
  36. * @param {Props} props - The read-only React {@code Component} props with
  37. * which the new instance is to be initialized.
  38. */
  39. constructor(props: Props) {
  40. super(props);
  41. // Bind event handlers so they are only bound once per instance.
  42. this._onCancel = this._onCancel.bind(this);
  43. this._onSubmit = this._onSubmit.bind(this);
  44. }
  45. /**
  46. * Implements React's {@link Component#render()}.
  47. *
  48. * @inheritdoc
  49. * @returns {ReactElement}
  50. */
  51. render() {
  52. return (
  53. <Dialog
  54. bodyKey = 'dialog.passwordLabel'
  55. onCancel = { this._onCancel }
  56. onSubmit = { this._onSubmit }
  57. titleKey = 'dialog.passwordRequired' />
  58. );
  59. }
  60. _onCancel: () => boolean;
  61. /**
  62. * Notifies this prompt that it has been dismissed by cancel.
  63. *
  64. * @private
  65. * @returns {boolean} If this prompt is to be closed/hidden, {@code true};
  66. * otherwise, {@code false}.
  67. */
  68. _onCancel() {
  69. // XXX The user has canceled this prompt for a password so we are to
  70. // attempt joining the conference without a password. If the conference
  71. // still requires a password to join, the user will be prompted again
  72. // later.
  73. return this._onSubmit(undefined);
  74. }
  75. _onSubmit: (?string) => boolean;
  76. /**
  77. * Notifies this prompt that it has been dismissed by submitting a specific
  78. * value.
  79. *
  80. * @param {string|undefined} value - The submitted value.
  81. * @private
  82. * @returns {boolean} If this prompt is to be closed/hidden, {@code true};
  83. * otherwise, {@code false}.
  84. */
  85. _onSubmit(value: ?string) {
  86. const { conference }: { conference: { join: Function } } = this.props;
  87. this.props.dispatch(setPassword(conference, conference.join, value));
  88. return true;
  89. }
  90. }
  91. export default connect()(PasswordRequiredPrompt);