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.js 4.0KB

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