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

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