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

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