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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 { isLocalParticipantModerator } from '../../../../base/participants';
  6. import { connect } from '../../../../base/redux';
  7. import { E2EESection } from '../../../../e2ee/components';
  8. import { LobbySection } from '../../../../lobby';
  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. * Indicates whether e2ee will be displayed or not.
  35. */
  36. _showE2ee: boolean,
  37. /**
  38. * Action that sets the conference password.
  39. */
  40. setPassword: 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. _showE2ee,
  54. setPassword
  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. hideCancelButton = { true }
  65. submitDisabled = { true }
  66. titleKey = 'security.securityOptions'
  67. width = { 'small' }>
  68. <div className = 'security-dialog'>
  69. <LobbySection />
  70. <PasswordSection
  71. canEditPassword = { _canEditPassword }
  72. conference = { _conference }
  73. locked = { _locked }
  74. password = { _password }
  75. passwordEditEnabled = { passwordEditEnabled }
  76. passwordNumberOfDigits = { _passwordNumberOfDigits }
  77. setPassword = { setPassword }
  78. setPasswordEditEnabled = { setPasswordEditEnabled } />
  79. {
  80. _showE2ee ? <>
  81. <div className = 'separator-line' />
  82. <E2EESection />
  83. </> : null
  84. }
  85. </div>
  86. </Dialog>
  87. );
  88. }
  89. /**
  90. * Maps (parts of) the Redux state to the associated props for the
  91. * {@code SecurityDialog} component.
  92. *
  93. * @param {Object} state - The Redux state.
  94. * @private
  95. * @returns {Props}
  96. */
  97. function mapStateToProps(state) {
  98. const {
  99. conference,
  100. e2eeSupported,
  101. locked,
  102. password
  103. } = state['features/base/conference'];
  104. const { roomPasswordNumberOfDigits } = state['features/base/config'];
  105. const showE2ee = Boolean(e2eeSupported) && isLocalParticipantModerator(state);
  106. return {
  107. _canEditPassword: isLocalParticipantModerator(state),
  108. _conference: conference,
  109. _dialIn: state['features/invite'],
  110. _locked: locked,
  111. _password: password,
  112. _passwordNumberOfDigits: roomPasswordNumberOfDigits,
  113. _showE2ee: showE2ee
  114. };
  115. }
  116. const mapDispatchToProps = { setPassword: setPass };
  117. export default connect(mapStateToProps, mapDispatchToProps)(SecurityDialog);