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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. * Indicates whether e2ee will be displayed or not.
  37. */
  38. _showE2ee: boolean,
  39. /**
  40. * Action that sets the conference password.
  41. */
  42. setPassword: Function,
  43. /**
  44. * Invoked to obtain translated strings.
  45. */
  46. t: Function
  47. };
  48. /**
  49. * Component that renders the security options dialog.
  50. *
  51. * @returns {React$Element<any>}
  52. */
  53. function SecurityDialog({
  54. _canEditPassword,
  55. _conference,
  56. _locked,
  57. _password,
  58. _passwordNumberOfDigits,
  59. _showE2ee,
  60. setPassword
  61. }: Props) {
  62. const [ passwordEditEnabled, setPasswordEditEnabled ] = useState(false);
  63. useEffect(() => {
  64. if (passwordEditEnabled && _password) {
  65. setPasswordEditEnabled(false);
  66. }
  67. }, [ _password ]);
  68. return (
  69. <Dialog
  70. customHeader = { Header }
  71. hideCancelButton = { true }
  72. submitDisabled = { true }
  73. titleKey = 'security.securityOptions'
  74. width = { 'small' }>
  75. <div className = 'security-dialog'>
  76. <LobbySection />
  77. <PasswordSection
  78. canEditPassword = { _canEditPassword }
  79. conference = { _conference }
  80. locked = { _locked }
  81. password = { _password }
  82. passwordEditEnabled = { passwordEditEnabled }
  83. passwordNumberOfDigits = { _passwordNumberOfDigits }
  84. setPassword = { setPassword }
  85. setPasswordEditEnabled = { setPasswordEditEnabled } />
  86. {
  87. _showE2ee ? <>
  88. <div className = 'separator-line' />
  89. <E2EESection />
  90. </> : null
  91. }
  92. </div>
  93. </Dialog>
  94. );
  95. }
  96. /**
  97. * Maps (parts of) the Redux state to the associated props for the
  98. * {@code SecurityDialog} component.
  99. *
  100. * @param {Object} state - The Redux state.
  101. * @private
  102. * @returns {Props}
  103. */
  104. function mapStateToProps(state) {
  105. const {
  106. conference,
  107. e2eeSupported,
  108. locked,
  109. password
  110. } = state['features/base/conference'];
  111. const {
  112. lockRoomGuestEnabled,
  113. roomPasswordNumberOfDigits
  114. } = state['features/base/config'];
  115. return {
  116. _canEditPassword: isLocalParticipantModerator(state, lockRoomGuestEnabled),
  117. _conference: conference,
  118. _dialIn: state['features/invite'],
  119. _locked: locked,
  120. _password: password,
  121. _passwordNumberOfDigits: roomPasswordNumberOfDigits,
  122. _showE2ee: Boolean(e2eeSupported)
  123. };
  124. }
  125. const mapDispatchToProps = { setPassword: setPass };
  126. export default translate(connect(mapStateToProps, mapDispatchToProps)(SecurityDialog));