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.

RemovePasswordForm.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { setPassword } from '../../base/conference';
  5. import { translate } from '../../base/i18n';
  6. /**
  7. * A React {@code Component} for removing a lock from a JitsiConference.
  8. */
  9. class RemovePasswordForm extends Component {
  10. /**
  11. * {@code RemovePasswordForm}'s property types.
  12. *
  13. * @static
  14. */
  15. static propTypes = {
  16. /**
  17. * The JitsiConference on which remove a lock.
  18. *
  19. * @type {JitsiConference}
  20. */
  21. conference: PropTypes.object,
  22. /**
  23. * Invoked to send a password removal request.
  24. */
  25. dispatch: PropTypes.func,
  26. /**
  27. * Whether or not the room lock, if any, was set by the local user.
  28. */
  29. lockedLocally: PropTypes.bool,
  30. /**
  31. * The current known password for the JitsiConference.
  32. */
  33. password: PropTypes.string,
  34. /**
  35. * Invoked to obtain translated strings.
  36. */
  37. t: PropTypes.func
  38. };
  39. /**
  40. * Initializes a new {@code RemovePasswordForm} instance.
  41. *
  42. * @param {Object} props - The read-only properties with which the new
  43. * instance is to be initialized.
  44. */
  45. constructor(props) {
  46. super(props);
  47. // Bind event handlers so they are only bound once for every instance.
  48. this._onClick = this._onClick.bind(this);
  49. }
  50. /**
  51. * Implements React's {@link Component#render()}.
  52. *
  53. * @private
  54. * @returns {ReactElement}
  55. */
  56. render() {
  57. return (
  58. <div className = 'remove-password'>
  59. <div className = 'remove-password-description'>
  60. { this._getPasswordPreviewText() }
  61. </div>
  62. <a
  63. className = 'remove-password-link'
  64. id = 'inviteDialogRemovePassword'
  65. onClick = { this._onClick }>
  66. { this.props.t('dialog.removePassword') }
  67. </a>
  68. </div>
  69. );
  70. }
  71. /**
  72. * Creates a ReactElement for displaying the current password.
  73. *
  74. * @private
  75. * @returns {ReactElement}
  76. */
  77. _getPasswordPreviewText() {
  78. const { lockedLocally, password, t } = this.props;
  79. return (
  80. <span>
  81. <span>
  82. { `${t('dialog.currentPassword')} ` }
  83. </span>
  84. <span className = 'remove-password-current'>
  85. { lockedLocally ? password : t('passwordSetRemotely') }
  86. </span>
  87. </span>
  88. );
  89. }
  90. /**
  91. * Dispatches a request to remove any set password on the JitsiConference.
  92. *
  93. * @private
  94. * @returns {void}
  95. */
  96. _onClick() {
  97. const { conference } = this.props;
  98. this.props.dispatch(setPassword(
  99. conference,
  100. conference.lock,
  101. ''
  102. ));
  103. }
  104. }
  105. export default translate(connect()(RemovePasswordForm));