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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import React, { useEffect, useState } from 'react';
  2. import { connect } from 'react-redux';
  3. import { IReduxState } from '../../../../app/types';
  4. import { setPassword as setPass } from '../../../../base/conference/actions';
  5. import { IJitsiConference } from '../../../../base/conference/reducer';
  6. import { getSecurityUiConfig } from '../../../../base/config/functions.any';
  7. import { isLocalParticipantModerator } from '../../../../base/participants/functions';
  8. import Dialog from '../../../../base/ui/components/web/Dialog';
  9. import E2EESection from '../../../../e2ee/components/E2EESection';
  10. import LobbySection from '../../../../lobby/components/web/LobbySection';
  11. import PasswordSection from './PasswordSection';
  12. export interface INotifyClick {
  13. key: string;
  14. preventExecution: boolean;
  15. }
  16. interface IProps {
  17. /**
  18. * Toolbar buttons which have their click exposed through the API.
  19. */
  20. _buttonsWithNotifyClick: Array<string | INotifyClick>;
  21. /**
  22. * Whether or not the current user can modify the current password.
  23. */
  24. _canEditPassword: boolean;
  25. /**
  26. * The JitsiConference for which to display a lock state and change the
  27. * password.
  28. */
  29. _conference?: IJitsiConference;
  30. /**
  31. * Whether to hide the lobby password section.
  32. */
  33. _disableLobbyPassword?: boolean;
  34. /**
  35. * The value for how the conference is locked (or undefined if not locked)
  36. * as defined by room-lock constants.
  37. */
  38. _locked?: string;
  39. /**
  40. * The current known password for the JitsiConference.
  41. */
  42. _password?: string;
  43. /**
  44. * The number of digits to be used in the password.
  45. */
  46. _passwordNumberOfDigits?: number;
  47. /**
  48. * Indicates whether e2ee will be displayed or not.
  49. */
  50. _showE2ee: boolean;
  51. /**
  52. * Action that sets the conference password.
  53. */
  54. setPassword: Function;
  55. }
  56. /**
  57. * Component that renders the security options dialog.
  58. *
  59. * @returns {React$Element<any>}
  60. */
  61. function SecurityDialog({
  62. _buttonsWithNotifyClick,
  63. _canEditPassword,
  64. _conference,
  65. _disableLobbyPassword,
  66. _locked,
  67. _password,
  68. _passwordNumberOfDigits,
  69. _showE2ee,
  70. setPassword
  71. }: IProps) {
  72. const [ passwordEditEnabled, setPasswordEditEnabled ] = useState(false);
  73. useEffect(() => {
  74. if (passwordEditEnabled && _password) {
  75. setPasswordEditEnabled(false);
  76. }
  77. }, [ _password ]);
  78. return (
  79. <Dialog
  80. cancel = {{ hidden: true }}
  81. ok = {{ hidden: true }}
  82. titleKey = 'security.title'>
  83. <div className = 'security-dialog'>
  84. <LobbySection />
  85. {!_disableLobbyPassword && (
  86. <>
  87. <div className = 'separator-line' />
  88. <PasswordSection
  89. buttonsWithNotifyClick = { _buttonsWithNotifyClick }
  90. canEditPassword = { _canEditPassword }
  91. conference = { _conference }
  92. locked = { _locked }
  93. password = { _password }
  94. passwordEditEnabled = { passwordEditEnabled }
  95. passwordNumberOfDigits = { _passwordNumberOfDigits }
  96. setPassword = { setPassword }
  97. setPasswordEditEnabled = { setPasswordEditEnabled } />
  98. </>
  99. )}
  100. {
  101. _showE2ee ? <>
  102. <div className = 'separator-line' />
  103. <E2EESection />
  104. </> : null
  105. }
  106. </div>
  107. </Dialog>
  108. );
  109. }
  110. /**
  111. * Maps (parts of) the Redux state to the associated props for the
  112. * {@code SecurityDialog} component.
  113. *
  114. * @param {Object} state - The Redux state.
  115. * @private
  116. * @returns {IProps}
  117. */
  118. function mapStateToProps(state: IReduxState) {
  119. const {
  120. conference,
  121. e2eeSupported,
  122. locked,
  123. password
  124. } = state['features/base/conference'];
  125. const {
  126. roomPasswordNumberOfDigits,
  127. buttonsWithNotifyClick
  128. } = state['features/base/config'];
  129. const { disableLobbyPassword } = getSecurityUiConfig(state);
  130. const showE2ee = Boolean(e2eeSupported) && isLocalParticipantModerator(state);
  131. return {
  132. _buttonsWithNotifyClick: buttonsWithNotifyClick ?? [],
  133. _canEditPassword: isLocalParticipantModerator(state),
  134. _conference: conference,
  135. _dialIn: state['features/invite'],
  136. _disableLobbyPassword: disableLobbyPassword,
  137. _locked: locked,
  138. _password: password,
  139. _passwordNumberOfDigits: roomPasswordNumberOfDigits,
  140. _showE2ee: showE2ee
  141. };
  142. }
  143. const mapDispatchToProps = { setPassword: setPass };
  144. export default connect(mapStateToProps, mapDispatchToProps)(SecurityDialog);