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 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 { translate } from '../../../base/i18n';
  6. import { isLocalParticipantModerator } from '../../../base/participants';
  7. import { connect } from '../../../base/redux';
  8. import { LobbySection } from '../../../lobby';
  9. import Header from './Header';
  10. import PasswordSection from './PasswordSection';
  11. type Props = {
  12. /**
  13. * Whether or not the current user can modify the current password.
  14. */
  15. _canEditPassword: boolean,
  16. /**
  17. * The JitsiConference for which to display a lock state and change the
  18. * password.
  19. */
  20. _conference: Object,
  21. /**
  22. * The value for how the conference is locked (or undefined if not locked)
  23. * as defined by room-lock constants.
  24. */
  25. _locked: string,
  26. /**
  27. * The current known password for the JitsiConference.
  28. */
  29. _password: string,
  30. /**
  31. * The number of digits to be used in the password.
  32. */
  33. _passwordNumberOfDigits: ?number,
  34. /**
  35. * Action that sets the conference password.
  36. */
  37. setPassword: Function,
  38. /**
  39. * Invoked to obtain translated strings.
  40. */
  41. t: Function
  42. };
  43. /**
  44. * Component that renders the security options dialog.
  45. *
  46. * @returns {React$Element<any>}
  47. */
  48. function SecurityDialog({
  49. _canEditPassword,
  50. _conference,
  51. _locked,
  52. _password,
  53. _passwordNumberOfDigits,
  54. setPassword
  55. }: Props) {
  56. const [ passwordEditEnabled, setPasswordEditEnabled ] = useState(false);
  57. useEffect(() => {
  58. if (passwordEditEnabled && _password) {
  59. setPasswordEditEnabled(false);
  60. }
  61. }, [ _password ]);
  62. return (
  63. <Dialog
  64. customHeader = { Header }
  65. hideCancelButton = { true }
  66. submitDisabled = { true }
  67. titleKey = 'security.securityOptions'
  68. width = { 'small' }>
  69. <div className = 'security-dialog'>
  70. <LobbySection />
  71. <div className = 'separator-line' />
  72. <PasswordSection
  73. canEditPassword = { _canEditPassword }
  74. conference = { _conference }
  75. locked = { _locked }
  76. password = { _password }
  77. passwordEditEnabled = { passwordEditEnabled }
  78. passwordNumberOfDigits = { _passwordNumberOfDigits }
  79. setPassword = { setPassword }
  80. setPasswordEditEnabled = { setPasswordEditEnabled } />
  81. </div>
  82. </Dialog>
  83. );
  84. }
  85. /**
  86. * Maps (parts of) the Redux state to the associated props for the
  87. * {@code SecurityDialog} component.
  88. *
  89. * @param {Object} state - The Redux state.
  90. * @private
  91. * @returns {Props}
  92. */
  93. function mapStateToProps(state) {
  94. const {
  95. conference,
  96. locked,
  97. password
  98. } = state['features/base/conference'];
  99. return {
  100. _canEditPassword: isLocalParticipantModerator(state, state['features/base/config'].lockRoomGuestEnabled),
  101. _conference: conference,
  102. _dialIn: state['features/invite'],
  103. _locked: locked,
  104. _password: password
  105. };
  106. }
  107. const mapDispatchToProps = { setPassword: setPass };
  108. export default translate(connect(mapStateToProps, mapDispatchToProps)(SecurityDialog));