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.

E2EEButton.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // @flow
  2. import React from 'react';
  3. import { createE2EEEvent, sendAnalytics } from '../../analytics';
  4. import { openDialog } from '../../base/dialog';
  5. import { translate } from '../../base/i18n';
  6. import { IconRoomUnlock } from '../../base/icons';
  7. import { connect } from '../../base/redux';
  8. import { AbstractButton, BetaTag } from '../../base/toolbox';
  9. import type { AbstractButtonProps } from '../../base/toolbox';
  10. import E2EEDialog from './E2EEDialog';
  11. type Props = AbstractButtonProps & {
  12. /**
  13. * The redux {@code dispatch} function.
  14. */
  15. dispatch: Function
  16. };
  17. /**
  18. * Button that open a dialog to set the E2EE key.
  19. */
  20. class E2EEButton extends AbstractButton<Props, *> {
  21. accessibilityLabel = 'toolbar.accessibilityLabel.e2ee';
  22. icon = IconRoomUnlock;
  23. label = 'toolbar.e2ee';
  24. tooltip = 'toolbar.e2ee';
  25. /**
  26. * Helper function to be implemented by subclasses, which returns
  27. * a React Element to display (a beta tag) at the end of the button.
  28. *
  29. * @override
  30. * @protected
  31. * @returns {ReactElement}
  32. */
  33. _getElementAfter() {
  34. return <BetaTag />;
  35. }
  36. /**
  37. * Handles clicking / pressing the button, and opens the E2EE dialog.
  38. *
  39. * @protected
  40. * @returns {void}
  41. */
  42. _handleClick() {
  43. sendAnalytics(createE2EEEvent('dialog.open'));
  44. this.props.dispatch(openDialog(E2EEDialog));
  45. }
  46. }
  47. /**
  48. * Maps (parts of) the redux state to the associated props for this component.
  49. *
  50. * @param {Object} state - The Redux state.
  51. * @param {Props} ownProps - The own props of the Component.
  52. * @private
  53. * @returns {Props}
  54. */
  55. export function mapStateToProps(state: Object, ownProps: Props) {
  56. const { e2eeSupported } = state['features/base/conference'];
  57. const { visible = Boolean(e2eeSupported) } = ownProps;
  58. return {
  59. visible
  60. };
  61. }
  62. export default translate(connect(mapStateToProps)(E2EEButton));