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

PasswordRequiredPrompt.native.js 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. import { translate } from '../../base/i18n';
  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: React.PropTypes.object,
  23. dispatch: React.PropTypes.func,
  24. /**
  25. * The function to translate human-readable text.
  26. *
  27. * @public
  28. * @type {Function}
  29. */
  30. t: React.PropTypes.func
  31. }
  32. /**
  33. * Initializes a new PasswordRequiredPrompt instance.
  34. *
  35. * @param {Object} props - The read-only properties with which the new
  36. * instance is to be initialized.
  37. */
  38. constructor(props) {
  39. super(props);
  40. // Bind event handlers so they are only bound once for every instance.
  41. this._onCancel = this._onCancel.bind(this);
  42. this._onSubmit = this._onSubmit.bind(this);
  43. }
  44. /**
  45. * Implements React's {@link Component#render()}.
  46. *
  47. * @inheritdoc
  48. * @returns {ReactElement}
  49. */
  50. render() {
  51. const { t } = this.props;
  52. return (
  53. <Prompt
  54. onCancel = { this._onCancel }
  55. onSubmit = { this._onSubmit }
  56. placeholder = { t('dialog.passwordLabel') }
  57. title = { t('dialog.passwordRequired') }
  58. visible = { true } />
  59. );
  60. }
  61. /**
  62. * Notifies this prompt that it has been dismissed by cancel.
  63. *
  64. * @private
  65. * @returns {void}
  66. */
  67. _onCancel() {
  68. // XXX The user has canceled this prompt for a password so we are to
  69. // attempt joining the conference without a password. If the conference
  70. // still requires a password to join, the user will be prompted again
  71. // later.
  72. this._onSubmit(undefined);
  73. }
  74. /**
  75. * Notifies this prompt that it has been dismissed by submitting a specific
  76. * value.
  77. *
  78. * @param {string} value - The submitted value.
  79. * @private
  80. * @returns {void}
  81. */
  82. _onSubmit(value) {
  83. const conference = this.props.conference;
  84. this.props.dispatch(setPassword(conference, conference.join, value));
  85. }
  86. }
  87. export default translate(connect()(PasswordRequiredPrompt));