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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // @flow
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { connect } from 'react-redux';
  5. import { setPassword } from '../../base/conference';
  6. import { Dialog } from '../../base/dialog';
  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. dispatch: Dispatch<*>
  19. };
  20. /**
  21. * The style of the {@link TextInput} rendered by
  22. * {@code PasswordRequiredPrompt}. As it requests the entry of a password, the
  23. * entry should better be secure.
  24. */
  25. const _TEXT_INPUT_PROPS = {
  26. secureTextEntry: true
  27. };
  28. /**
  29. * Implements a React {@code Component} which prompts the user when a password
  30. * is required to join a conference.
  31. */
  32. class PasswordRequiredPrompt extends Component<Props> {
  33. /**
  34. * {@code PasswordRequiredPrompt}'s React {@code Component} prop types.
  35. *
  36. * @static
  37. */
  38. static propTypes = {
  39. conference: PropTypes.object,
  40. dispatch: PropTypes.func
  41. };
  42. /**
  43. * Initializes a new {@code PasswordRequiredPrompt} instance.
  44. *
  45. * @param {Props} props - The read-only React {@code Component} props with
  46. * which the new instance is to be initialized.
  47. */
  48. constructor(props: Props) {
  49. super(props);
  50. // Bind event handlers so they are only bound once per instance.
  51. this._onCancel = this._onCancel.bind(this);
  52. this._onSubmit = this._onSubmit.bind(this);
  53. }
  54. /**
  55. * Implements React's {@link Component#render()}.
  56. *
  57. * @inheritdoc
  58. * @returns {ReactElement}
  59. */
  60. render() {
  61. return (
  62. <Dialog
  63. bodyKey = 'dialog.passwordLabel'
  64. onCancel = { this._onCancel }
  65. onSubmit = { this._onSubmit }
  66. textInputProps = { _TEXT_INPUT_PROPS }
  67. titleKey = 'dialog.passwordRequired' />
  68. );
  69. }
  70. _onCancel: () => boolean;
  71. /**
  72. * Notifies this prompt that it has been dismissed by cancel.
  73. *
  74. * @private
  75. * @returns {boolean} If this prompt is to be closed/hidden, {@code true};
  76. * otherwise, {@code false}.
  77. */
  78. _onCancel() {
  79. this.props.dispatch(
  80. _cancelPasswordRequiredPrompt(this.props.conference));
  81. return true;
  82. }
  83. _onSubmit: (?string) => boolean;
  84. /**
  85. * Notifies this prompt that it has been dismissed by submitting a specific
  86. * value.
  87. *
  88. * @param {string|undefined} value - The submitted value.
  89. * @private
  90. * @returns {boolean} If this prompt is to be closed/hidden, {@code true};
  91. * otherwise, {@code false}.
  92. */
  93. _onSubmit(value: ?string) {
  94. const { conference }: { conference: { join: Function } } = this.props;
  95. this.props.dispatch(setPassword(conference, conference.join, value));
  96. return true;
  97. }
  98. }
  99. export default connect()(PasswordRequiredPrompt);