Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

AbstractSecurityDialogButton.js 2.9KB

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