Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

AbstractSecurityDialogButton.ts 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { createToolbarEvent } from '../../../analytics/AnalyticsEvents';
  2. import { sendAnalytics } from '../../../analytics/functions';
  3. import { IReduxState } from '../../../app/types';
  4. import { getSecurityUiConfig } from '../../../base/config/functions.any';
  5. import { LOBBY_MODE_ENABLED, MEETING_PASSWORD_ENABLED, SECURITY_OPTIONS_ENABLED } from '../../../base/flags/constants';
  6. import { getFeatureFlag } from '../../../base/flags/functions';
  7. import { IconSecurityOff, IconSecurityOn } from '../../../base/icons/svg';
  8. import { isLocalParticipantModerator } from '../../../base/participants/functions';
  9. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  10. import { isSecurityDialogButtonVisible } from '../../functions';
  11. export interface IProps extends AbstractButtonProps {
  12. /**
  13. * Whether the shared document is being edited or not.
  14. */
  15. _locked: boolean;
  16. }
  17. /**
  18. * Implements an {@link AbstractButton} to open the security dialog/screen.
  19. */
  20. export default class AbstractSecurityDialogButton<P extends IProps, S>
  21. extends AbstractButton<P, S> {
  22. accessibilityLabel = 'toolbar.accessibilityLabel.security';
  23. icon = IconSecurityOff;
  24. label = 'toolbar.security';
  25. toggledIcon = IconSecurityOn;
  26. tooltip = 'toolbar.security';
  27. /**
  28. * Helper function to be implemented by subclasses, which should be used
  29. * to handle the security button being clicked / pressed.
  30. *
  31. * @protected
  32. * @returns {void}
  33. */
  34. _handleClickSecurityButton() {
  35. // To be implemented by subclass.
  36. }
  37. /**
  38. * Handles clicking / pressing the button.
  39. *
  40. * @private
  41. * @returns {void}
  42. */
  43. _handleClick() {
  44. const { _locked } = this.props;
  45. sendAnalytics(createToolbarEvent('toggle.security', { enable: !_locked }));
  46. this._handleClickSecurityButton();
  47. }
  48. /**
  49. * Indicates whether this button is in toggled state or not.
  50. *
  51. * @override
  52. * @returns {boolean}
  53. */
  54. _isToggled() {
  55. return this.props._locked;
  56. }
  57. }
  58. /**
  59. * Maps part of the redux state to the component's props.
  60. *
  61. * @param {Object} state - The redux store/state.
  62. * @returns {IProps}
  63. */
  64. export function _mapStateToProps(state: IReduxState) {
  65. const { conference } = state['features/base/conference'];
  66. const { locked } = state['features/base/conference'];
  67. const { lobbyEnabled } = state['features/lobby'];
  68. const enabledSecurityOptionsFlag = getFeatureFlag(state, SECURITY_OPTIONS_ENABLED, true);
  69. const enabledLobbyModeFlag = getFeatureFlag(state, LOBBY_MODE_ENABLED, true);
  70. const enabledMeetingPassFlag = getFeatureFlag(state, MEETING_PASSWORD_ENABLED, true);
  71. return {
  72. _locked: Boolean(locked || lobbyEnabled),
  73. visible: isSecurityDialogButtonVisible({
  74. conference,
  75. securityUIConfig: getSecurityUiConfig(state),
  76. isModerator: isLocalParticipantModerator(state),
  77. enabledLobbyModeFlag,
  78. enabledMeetingPassFlag,
  79. enabledSecurityOptionsFlag
  80. })
  81. };
  82. }