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 React, { Component } from 'react';
  3. import type { Dispatch } from 'redux';
  4. import { InputDialog } from '../../base/dialog';
  5. import { connect } from '../../base/redux';
  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. * The type of the React {@code Component} props of {@link RoomLockPrompt}.
  18. */
  19. type Props = {
  20. /**
  21. * The JitsiConference which requires a password.
  22. */
  23. conference: Object,
  24. /**
  25. * Redux store dispatch function.
  26. */
  27. dispatch: Dispatch<any>,
  28. };
  29. /**
  30. * Implements a React Component which prompts the user for a password to lock a
  31. * conference/room.
  32. */
  33. class RoomLockPrompt extends Component<Props> {
  34. /**
  35. * Initializes a new RoomLockPrompt instance.
  36. *
  37. * @param {Props} props - The read-only properties with which the new
  38. * instance is to be initialized.
  39. */
  40. constructor(props: Props) {
  41. super(props);
  42. // Bind event handlers so they are only bound once per instance.
  43. this._onCancel = this._onCancel.bind(this);
  44. this._onSubmit = this._onSubmit.bind(this);
  45. }
  46. /**
  47. * Implements React's {@link Component#render()}.
  48. *
  49. * @inheritdoc
  50. * @returns {ReactElement}
  51. */
  52. render() {
  53. return (
  54. <InputDialog
  55. contentKey = 'dialog.passwordLabel'
  56. onCancel = { this._onCancel }
  57. onSubmit = { this._onSubmit }
  58. textInputProps = { _TEXT_INPUT_PROPS } />
  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);