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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { setPassword } from '../../base/conference';
  5. import { InputDialog } from '../../base/dialog';
  6. import { _cancelPasswordRequiredPrompt } from '../actions';
  7. /**
  8. * {@code PasswordRequiredPrompt}'s React {@code Component} prop types.
  9. */
  10. type Props = {
  11. /**
  12. * The {@code JitsiConference} which requires a password.
  13. *
  14. * @type {JitsiConference}
  15. */
  16. conference: { join: Function },
  17. /**
  18. * The redux dispatch function.
  19. */
  20. dispatch: Dispatch<*>
  21. };
  22. /**
  23. * Implements a React {@code Component} which prompts the user when a password
  24. * is required to join a conference.
  25. */
  26. class PasswordRequiredPrompt extends Component<Props> {
  27. /**
  28. * Initializes a new {@code PasswordRequiredPrompt} instance.
  29. *
  30. * @param {Props} props - The read-only React {@code Component} props with
  31. * which the new instance is to be initialized.
  32. */
  33. constructor(props: Props) {
  34. super(props);
  35. // Bind event handlers so they are only bound once per instance.
  36. this._onCancel = this._onCancel.bind(this);
  37. this._onSubmit = this._onSubmit.bind(this);
  38. }
  39. /**
  40. * Implements React's {@link Component#render()}.
  41. *
  42. * @inheritdoc
  43. * @returns {ReactElement}
  44. */
  45. render() {
  46. return (
  47. <InputDialog
  48. contentKey = 'dialog.passwordLabel'
  49. onCancel = { this._onCancel }
  50. onSubmit = { this._onSubmit }
  51. textInputProps = {{
  52. secureTextEntry: true
  53. }} />
  54. );
  55. }
  56. _onCancel: () => boolean;
  57. /**
  58. * Notifies this prompt that it has been dismissed by cancel.
  59. *
  60. * @private
  61. * @returns {boolean} If this prompt is to be closed/hidden, {@code true};
  62. * otherwise, {@code false}.
  63. */
  64. _onCancel() {
  65. this.props.dispatch(
  66. _cancelPasswordRequiredPrompt(this.props.conference));
  67. return true;
  68. }
  69. _onSubmit: (?string) => boolean;
  70. /**
  71. * Notifies this prompt that it has been dismissed by submitting a specific
  72. * value.
  73. *
  74. * @param {string|undefined} value - The submitted value.
  75. * @private
  76. * @returns {boolean} If this prompt is to be closed/hidden, {@code true};
  77. * otherwise, {@code false}.
  78. */
  79. _onSubmit(value: ?string) {
  80. const { conference }: { conference: { join: Function } } = this.props;
  81. this.props.dispatch(setPassword(conference, conference.join, value));
  82. return true;
  83. }
  84. }
  85. export default connect()(PasswordRequiredPrompt);