您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RoomLockPrompt.native.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // @flow
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { connect } from 'react-redux';
  5. import { Dialog } from '../../base/dialog';
  6. import { endRoomLockRequest } from '../actions';
  7. /**
  8. * Implements a React Component which prompts the user for a password to lock a
  9. * conference/room.
  10. */
  11. class RoomLockPrompt extends Component {
  12. /**
  13. * RoomLockPrompt component's property types.
  14. *
  15. * @static
  16. */
  17. static propTypes = {
  18. /**
  19. * The JitsiConference which requires a password.
  20. *
  21. * @type {JitsiConference}
  22. */
  23. conference: PropTypes.object,
  24. dispatch: PropTypes.func
  25. };
  26. /**
  27. * Initializes a new RoomLockPrompt instance.
  28. *
  29. * @param {Props} 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 per 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. return (
  46. <Dialog
  47. bodyKey = 'dialog.passwordLabel'
  48. onCancel = { this._onCancel }
  49. onSubmit = { this._onSubmit }
  50. titleKey = 'toolbar.lock' />
  51. );
  52. }
  53. _onCancel: () => boolean;
  54. /**
  55. * Notifies this prompt that it has been dismissed by cancel.
  56. *
  57. * @private
  58. * @returns {boolean} True to hide this dialog/prompt; otherwise, false.
  59. */
  60. _onCancel() {
  61. // An undefined password is understood to cancel the request to lock the
  62. // conference/room.
  63. return this._onSubmit(undefined);
  64. }
  65. _onSubmit: (?string) => boolean;
  66. /**
  67. * Notifies this prompt that it has been dismissed by submitting a specific
  68. * value.
  69. *
  70. * @param {string|undefined} value - The submitted value.
  71. * @private
  72. * @returns {boolean} False because we do not want to hide this
  73. * dialog/prompt as the hiding will be handled inside endRoomLockRequest
  74. * after setting the password is resolved.
  75. */
  76. _onSubmit(value: ?string) {
  77. this.props.dispatch(endRoomLockRequest(this.props.conference, value));
  78. return false; // Do not hide.
  79. }
  80. }
  81. export default connect()(RoomLockPrompt);