您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SecurityDialogButton.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import { createToolbarEvent, sendAnalytics } from '../../../analytics';
  4. import { translate } from '../../../base/i18n';
  5. import { IconSecurityOff, IconSecurityOn } from '../../../base/icons';
  6. import { connect } from '../../../base/redux';
  7. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  8. import { toggleSecurityDialog } from '../../actions';
  9. type Props = AbstractButtonProps & {
  10. /**
  11. * Whether the shared document is being edited or not.
  12. */
  13. _locked: boolean,
  14. /**
  15. * The redux {@code dispatch} function.
  16. */
  17. dispatch: Dispatch<any>
  18. };
  19. /**
  20. * Implements an {@link AbstractButton} to open the security dialog.
  21. */
  22. class SecurityDialogButton extends AbstractButton<Props, *> {
  23. accessibilityLabel = 'toolbar.accessibilityLabel.security';
  24. icon = IconSecurityOff;
  25. label = 'toolbar.security';
  26. toggledIcon = IconSecurityOn;
  27. /**
  28. * Handles clicking / pressing the button, and opens / closes the appropriate dialog.
  29. *
  30. * @private
  31. * @returns {void}
  32. */
  33. _handleClick() {
  34. sendAnalytics(createToolbarEvent('toggle.security', { enable: !this.props._locked }));
  35. this.props.dispatch(toggleSecurityDialog());
  36. }
  37. /**
  38. * Indicates whether this button is in toggled state or not.
  39. *
  40. * @override
  41. * @returns {boolean}
  42. */
  43. _isToggled() {
  44. return this.props._locked;
  45. }
  46. }
  47. /**
  48. * Maps part of the redux state to the component's props.
  49. *
  50. * @param {Object} state - The redux store/state.
  51. * @returns {Props}
  52. */
  53. function mapStateToProps(state: Object) {
  54. const { locked } = state['features/base/conference'];
  55. const { lobbyEnabled } = state['features/lobby'];
  56. return {
  57. _locked: locked || lobbyEnabled
  58. };
  59. }
  60. export default translate(connect(mapStateToProps)(SecurityDialogButton));