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

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