選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

AbstractSecurityDialogButton.js 2.8KB

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