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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import PropTypes from 'prop-types';
  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. * Implements a React Component which prompts the user for a password to lock a
  8. * conference/room.
  9. */
  10. class RoomLockPrompt extends Component {
  11. /**
  12. * RoomLockPrompt component's property types.
  13. *
  14. * @static
  15. */
  16. static propTypes = {
  17. /**
  18. * The JitsiConference which requires a password.
  19. *
  20. * @type {JitsiConference}
  21. */
  22. conference: PropTypes.object,
  23. dispatch: PropTypes.func
  24. };
  25. /**
  26. * Initializes a new RoomLockPrompt instance.
  27. *
  28. * @param {Object} props - The read-only properties with which the new
  29. * instance is to be initialized.
  30. */
  31. constructor(props) {
  32. super(props);
  33. // Bind event handlers so they are only bound once for every instance.
  34. this._onCancel = this._onCancel.bind(this);
  35. this._onSubmit = this._onSubmit.bind(this);
  36. }
  37. /**
  38. * Implements React's {@link Component#render()}.
  39. *
  40. * @inheritdoc
  41. * @returns {ReactElement}
  42. */
  43. render() {
  44. return (
  45. <Dialog
  46. bodyKey = 'dialog.passwordLabel'
  47. onCancel = { this._onCancel }
  48. onSubmit = { this._onSubmit }
  49. titleKey = 'toolbar.lock' />
  50. );
  51. }
  52. /**
  53. * Notifies this prompt that it has been dismissed by cancel.
  54. *
  55. * @private
  56. * @returns {boolean} True to hide this dialog/prompt; otherwise, false.
  57. */
  58. _onCancel() {
  59. // An undefined password is understood to cancel the request to lock the
  60. // conference/room.
  61. return this._onSubmit(undefined);
  62. }
  63. /**
  64. * Notifies this prompt that it has been dismissed by submitting a specific
  65. * value.
  66. *
  67. * @param {string} value - The submitted value.
  68. * @private
  69. * @returns {boolean} False because we do not want to hide this
  70. * dialog/prompt as the hiding will be handled inside endRoomLockRequest
  71. * after setting the password is resolved.
  72. */
  73. _onSubmit(value) {
  74. this.props.dispatch(endRoomLockRequest(this.props.conference, value));
  75. return false; // Do not hide.
  76. }
  77. }
  78. export default connect()(RoomLockPrompt);