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

SecurityDialogButton.js 2.1KB

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