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

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