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.5KB

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