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.

SecurityDialog.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // @flow
  2. import React, { useState, useEffect } from 'react';
  3. import { setPassword as setPass } from '../../../base/conference';
  4. import { Dialog } from '../../../base/dialog';
  5. import { translate } from '../../../base/i18n';
  6. import { isLocalParticipantModerator } from '../../../base/participants';
  7. import { connect } from '../../../base/redux';
  8. import Header from './Header';
  9. import PasswordSection from './PasswordSection';
  10. type Props = {
  11. /**
  12. * Whether or not the current user can modify the current password.
  13. */
  14. _canEditPassword: boolean,
  15. /**
  16. * The JitsiConference for which to display a lock state and change the
  17. * password.
  18. */
  19. _conference: Object,
  20. /**
  21. * The value for how the conference is locked (or undefined if not locked)
  22. * as defined by room-lock constants.
  23. */
  24. _locked: string,
  25. /**
  26. * The current known password for the JitsiConference.
  27. */
  28. _password: string,
  29. /**
  30. * The number of digits to be used in the password.
  31. */
  32. _passwordNumberOfDigits: ?number,
  33. /**
  34. * Action that sets the conference password.
  35. */
  36. setPassword: Function,
  37. /**
  38. * Invoked to obtain translated strings.
  39. */
  40. t: Function
  41. };
  42. /**
  43. * Component that renders the security options dialog.
  44. *
  45. * @returns {React$Element<any>}
  46. */
  47. function SecurityDialog({
  48. _canEditPassword,
  49. _conference,
  50. _locked,
  51. _password,
  52. _passwordNumberOfDigits,
  53. setPassword,
  54. t
  55. }: Props) {
  56. const [ passwordEditEnabled, setPasswordEditEnabled ] = useState(false);
  57. useEffect(() => {
  58. if (passwordEditEnabled && _password) {
  59. setPasswordEditEnabled(false);
  60. }
  61. }, [ _password ]);
  62. return (
  63. <Dialog
  64. customHeader = { Header }
  65. hideCancelButton = { true }
  66. submitDisabled = { true }
  67. titleKey = 'security.securityOptions'
  68. width = { 'small' }>
  69. <div className = 'security-dialog'>
  70. { t('security.about') }
  71. <div className = 'invite-more-dialog separator' />
  72. <PasswordSection
  73. canEditPassword = { _canEditPassword }
  74. conference = { _conference }
  75. locked = { _locked }
  76. password = { _password }
  77. passwordEditEnabled = { passwordEditEnabled }
  78. passwordNumberOfDigits = { _passwordNumberOfDigits }
  79. setPassword = { setPassword }
  80. setPasswordEditEnabled = { setPasswordEditEnabled } />
  81. </div>
  82. </Dialog>
  83. );
  84. }
  85. /**
  86. * Maps (parts of) the Redux state to the associated props for the
  87. * {@code SecurityDialog} component.
  88. *
  89. * @param {Object} state - The Redux state.
  90. * @private
  91. * @returns {Props}
  92. */
  93. function mapStateToProps(state) {
  94. const {
  95. conference,
  96. locked,
  97. password
  98. } = state['features/base/conference'];
  99. return {
  100. _canEditPassword: isLocalParticipantModerator(state, state['features/base/config'].lockRoomGuestEnabled),
  101. _conference: conference,
  102. _dialIn: state['features/invite'],
  103. _locked: locked,
  104. _password: password
  105. };
  106. }
  107. const mapDispatchToProps = { setPassword: setPass };
  108. export default translate(connect(mapStateToProps, mapDispatchToProps)(SecurityDialog));