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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. <div className = 'separator-line' />
  78. <PasswordSection
  79. canEditPassword = { _canEditPassword }
  80. conference = { _conference }
  81. locked = { _locked }
  82. password = { _password }
  83. passwordEditEnabled = { passwordEditEnabled }
  84. passwordNumberOfDigits = { _passwordNumberOfDigits }
  85. setPassword = { setPassword }
  86. setPasswordEditEnabled = { setPasswordEditEnabled } />
  87. {
  88. _showE2ee ? <>
  89. <div className = 'separator-line' />
  90. <E2EESection />
  91. </> : null
  92. }
  93. </div>
  94. </Dialog>
  95. );
  96. }
  97. /**
  98. * Maps (parts of) the Redux state to the associated props for the
  99. * {@code SecurityDialog} component.
  100. *
  101. * @param {Object} state - The Redux state.
  102. * @private
  103. * @returns {Props}
  104. */
  105. function mapStateToProps(state) {
  106. const {
  107. conference,
  108. e2eeSupported,
  109. locked,
  110. password
  111. } = state['features/base/conference'];
  112. return {
  113. _canEditPassword: isLocalParticipantModerator(state, state['features/base/config'].lockRoomGuestEnabled),
  114. _conference: conference,
  115. _dialIn: state['features/invite'],
  116. _locked: locked,
  117. _password: password,
  118. _showE2ee: Boolean(e2eeSupported)
  119. };
  120. }
  121. const mapDispatchToProps = { setPassword: setPass };
  122. export default translate(connect(mapStateToProps, mapDispatchToProps)(SecurityDialog));