Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

AbstractSecurityDialogButton.ts 3.0KB

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