Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

PasswordRequiredPrompt.native.js 3.1KB

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