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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React, { Component } from 'react';
  2. import Prompt from 'react-native-prompt';
  3. import { connect } from 'react-redux';
  4. import { endRoomLockRequest } from '../actions';
  5. import { translate } from '../../base/translation';
  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: React.PropTypes.object,
  23. dispatch: React.PropTypes.func,
  24. t: React.PropTypes.func
  25. }
  26. /**
  27. * Initializes a new RoomLockPrompt instance.
  28. *
  29. * @param {Object} props - The read-only properties with which the new
  30. * instance is to be initialized.
  31. */
  32. constructor(props) {
  33. super(props);
  34. // Bind event handlers so they are only bound once for every instance.
  35. this._onCancel = this._onCancel.bind(this);
  36. this._onSubmit = this._onSubmit.bind(this);
  37. }
  38. /**
  39. * Implements React's {@link Component#render()}.
  40. *
  41. * @inheritdoc
  42. * @returns {ReactElement}
  43. */
  44. render() {
  45. const { t } = this.props;
  46. return (
  47. <Prompt
  48. onCancel = { this._onCancel }
  49. onSubmit = { this._onSubmit }
  50. placeholder = { t('dialog.passwordLabel') }
  51. title = { t('toolbar.lock') }
  52. visible = { true } />
  53. );
  54. }
  55. /**
  56. * Notifies this prompt that it has been dismissed by cancel.
  57. *
  58. * @private
  59. * @returns {void}
  60. */
  61. _onCancel() {
  62. // An undefined password is understood to cancel the request to lock the
  63. // conference/room.
  64. this._onSubmit(undefined);
  65. }
  66. /**
  67. * Notifies this prompt that it has been dismissed by submitting a specific
  68. * value.
  69. *
  70. * @param {string} value - The submitted value.
  71. * @private
  72. * @returns {void}
  73. */
  74. _onSubmit(value) {
  75. this.props.dispatch(endRoomLockRequest(this.props.conference, value));
  76. }
  77. }
  78. export default translate(connect()(RoomLockPrompt));