您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

PasswordRequiredPrompt.native.js 2.5KB

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