Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

PasswordRequiredPrompt.native.js 2.4KB

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