You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SecurityDialogButton.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. tooltip = 'toolbar.security';
  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.onClick();
  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. /**
  61. * Maps dispatching of some action to React component props.
  62. *
  63. * @param {Function} dispatch - Redux action dispatcher.
  64. * @returns {Props}
  65. */
  66. const mapDispatchToProps = {
  67. onClick: () => toggleSecurityDialog()
  68. };
  69. export default translate(connect(mapStateToProps, mapDispatchToProps)(SecurityDialogButton));