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

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