Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

SecurityDialog.tsx 4.1KB

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