您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SecurityDialog.tsx 4.2KB

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