Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

SecurityDialog.tsx 4.9KB

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