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.

RoomLockPrompt.native.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // @flow
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { connect } from 'react-redux';
  5. import { Dialog } from '../../base/dialog';
  6. import { endRoomLockRequest } from '../actions';
  7. /**
  8. * The style of the {@link TextInput} rendered by {@code RoomLockPrompt}. As it
  9. * requests the entry of a password, {@code TextInput} automatically correcting
  10. * the entry of the password is a pain to deal with as a user.
  11. */
  12. const _TEXT_INPUT_PROPS = {
  13. autoCapitalize: 'none',
  14. autoCorrect: false
  15. };
  16. /**
  17. * Implements a React Component which prompts the user for a password to lock a
  18. * conference/room.
  19. */
  20. class RoomLockPrompt extends Component<*> {
  21. /**
  22. * RoomLockPrompt component's property types.
  23. *
  24. * @static
  25. */
  26. static propTypes = {
  27. /**
  28. * The JitsiConference which requires a password.
  29. *
  30. * @type {JitsiConference}
  31. */
  32. conference: PropTypes.object,
  33. dispatch: PropTypes.func
  34. };
  35. /**
  36. * Initializes a new RoomLockPrompt instance.
  37. *
  38. * @param {Props} props - The read-only properties with which the new
  39. * instance is to be initialized.
  40. */
  41. constructor(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 = 'toolbar.lock' />
  61. );
  62. }
  63. _onCancel: () => boolean;
  64. /**
  65. * Notifies this prompt that it has been dismissed by cancel.
  66. *
  67. * @private
  68. * @returns {boolean} True to hide this dialog/prompt; otherwise, false.
  69. */
  70. _onCancel() {
  71. // An undefined password is understood to cancel the request to lock the
  72. // conference/room.
  73. return this._onSubmit(undefined);
  74. }
  75. _onSubmit: (?string) => boolean;
  76. /**
  77. * Notifies this prompt that it has been dismissed by submitting a specific
  78. * value.
  79. *
  80. * @param {string|undefined} value - The submitted value.
  81. * @private
  82. * @returns {boolean} False because we do not want to hide this
  83. * dialog/prompt as the hiding will be handled inside endRoomLockRequest
  84. * after setting the password is resolved.
  85. */
  86. _onSubmit(value: ?string) {
  87. this.props.dispatch(endRoomLockRequest(this.props.conference, value));
  88. return false; // Do not hide.
  89. }
  90. }
  91. export default connect()(RoomLockPrompt);