You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PasswordRequiredPrompt.native.js 2.5KB

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