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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { Dialog } from '../../base/dialog';
  5. import { endRoomLockRequest } from '../actions';
  6. /**
  7. * The style of the {@link TextInput} rendered by {@code RoomLockPrompt}. As it
  8. * requests the entry of a password, {@code TextInput} automatically correcting
  9. * the entry of the password is a pain to deal with as a user.
  10. */
  11. const _TEXT_INPUT_PROPS = {
  12. autoCapitalize: 'none',
  13. autoCorrect: false
  14. };
  15. /**
  16. * The type of the React {@code Component} props of {@link RoomLockPrompt}.
  17. */
  18. type Props = {
  19. /**
  20. * The JitsiConference which requires a password.
  21. */
  22. conference: Object,
  23. /**
  24. * Redux store dispatch function.
  25. */
  26. dispatch: Dispatch<*>,
  27. };
  28. /**
  29. * Implements a React Component which prompts the user for a password to lock a
  30. * conference/room.
  31. */
  32. class RoomLockPrompt extends Component<Props> {
  33. /**
  34. * Initializes a new RoomLockPrompt instance.
  35. *
  36. * @param {Props} props - The read-only properties with which the new
  37. * instance is to be initialized.
  38. */
  39. constructor(props) {
  40. super(props);
  41. // Bind event handlers so they are only bound once per instance.
  42. this._onCancel = this._onCancel.bind(this);
  43. this._onSubmit = this._onSubmit.bind(this);
  44. }
  45. /**
  46. * Implements React's {@link Component#render()}.
  47. *
  48. * @inheritdoc
  49. * @returns {ReactElement}
  50. */
  51. render() {
  52. return (
  53. <Dialog
  54. bodyKey = 'dialog.passwordLabel'
  55. onCancel = { this._onCancel }
  56. onSubmit = { this._onSubmit }
  57. textInputProps = { _TEXT_INPUT_PROPS }
  58. titleKey = 'dialog.lockRoom' />
  59. );
  60. }
  61. _onCancel: () => boolean;
  62. /**
  63. * Notifies this prompt that it has been dismissed by cancel.
  64. *
  65. * @private
  66. * @returns {boolean} True to hide this dialog/prompt; otherwise, false.
  67. */
  68. _onCancel() {
  69. // An undefined password is understood to cancel the request to lock the
  70. // conference/room.
  71. return this._onSubmit(undefined);
  72. }
  73. _onSubmit: (?string) => boolean;
  74. /**
  75. * Notifies this prompt that it has been dismissed by submitting a specific
  76. * value.
  77. *
  78. * @param {string|undefined} value - The submitted value.
  79. * @private
  80. * @returns {boolean} False because we do not want to hide this
  81. * dialog/prompt as the hiding will be handled inside endRoomLockRequest
  82. * after setting the password is resolved.
  83. */
  84. _onSubmit(value: ?string) {
  85. this.props.dispatch(endRoomLockRequest(this.props.conference, value));
  86. return false; // Do not hide.
  87. }
  88. }
  89. export default connect()(RoomLockPrompt);