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

PasswordRequiredPrompt.native.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import React, { Component } from 'react';
  2. import Prompt from 'react-native-prompt';
  3. import { connect } from 'react-redux';
  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. <Prompt
  45. onCancel = { this._onCancel }
  46. onSubmit = { this._onSubmit }
  47. placeholder = 'Password'
  48. title = 'Password required'
  49. visible = { true } />
  50. );
  51. }
  52. /**
  53. * Notifies this prompt that it has been dismissed by cancel.
  54. *
  55. * @private
  56. * @returns {void}
  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. 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 {void}
  72. */
  73. _onSubmit(value) {
  74. const conference = this.props.conference;
  75. this.props.dispatch(setPassword(conference, conference.join, value));
  76. }
  77. }
  78. export default connect()(PasswordRequiredPrompt);