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

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