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

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