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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* eslint-disable lines-around-comment */
  2. import React, { useEffect, useState } from 'react';
  3. import { IState } from '../../../../app/types';
  4. // @ts-ignore
  5. import { setPassword as setPass } from '../../../../base/conference';
  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. 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. cancel = {{ hidden: true }}
  78. ok = {{ hidden: true }}
  79. titleKey = 'security.title'>
  80. <div className = 'security-dialog'>
  81. <LobbySection />
  82. <PasswordSection
  83. buttonsWithNotifyClick = { _buttonsWithNotifyClick }
  84. canEditPassword = { _canEditPassword }
  85. conference = { _conference }
  86. locked = { _locked }
  87. password = { _password }
  88. passwordEditEnabled = { passwordEditEnabled }
  89. passwordNumberOfDigits = { _passwordNumberOfDigits }
  90. setPassword = { setPassword }
  91. setPasswordEditEnabled = { setPasswordEditEnabled } />
  92. {
  93. _showE2ee ? <>
  94. <div className = 'separator-line' />
  95. <E2EESection />
  96. </> : null
  97. }
  98. </div>
  99. </Dialog>
  100. );
  101. }
  102. /**
  103. * Maps (parts of) the Redux state to the associated props for the
  104. * {@code SecurityDialog} component.
  105. *
  106. * @param {Object} state - The Redux state.
  107. * @private
  108. * @returns {Props}
  109. */
  110. function mapStateToProps(state: IState) {
  111. const {
  112. conference,
  113. e2eeSupported,
  114. locked,
  115. password
  116. } = state['features/base/conference'];
  117. const { roomPasswordNumberOfDigits, buttonsWithNotifyClick } = state['features/base/config'];
  118. const showE2ee = Boolean(e2eeSupported) && isLocalParticipantModerator(state);
  119. return {
  120. _buttonsWithNotifyClick: buttonsWithNotifyClick,
  121. _canEditPassword: isLocalParticipantModerator(state),
  122. _conference: conference,
  123. _dialIn: state['features/invite'],
  124. _locked: locked,
  125. _password: password,
  126. _passwordNumberOfDigits: roomPasswordNumberOfDigits,
  127. _showE2ee: showE2ee
  128. };
  129. }
  130. const mapDispatchToProps = { setPassword: setPass };
  131. export default connect(mapStateToProps, mapDispatchToProps)(SecurityDialog);