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

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