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.

E2EELabel.tsx 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import React from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { connect } from 'react-redux';
  4. import { IReduxState } from '../../app/types';
  5. import { translate } from '../../base/i18n/functions';
  6. import { IconE2EE } from '../../base/icons/svg';
  7. import Label from '../../base/label/components/web/Label';
  8. import { COLORS } from '../../base/label/constants';
  9. import Tooltip from '../../base/tooltip/components/Tooltip';
  10. export interface IProps extends WithTranslation {
  11. /**
  12. * Custom e2ee labels.
  13. */
  14. _e2eeLabels?: any;
  15. /**
  16. * True if the label needs to be rendered, false otherwise.
  17. */
  18. _showLabel?: boolean;
  19. }
  20. const E2EELabel = ({ _e2eeLabels, _showLabel, t }: IProps) => {
  21. if (!_showLabel) {
  22. return null;
  23. }
  24. const content = _e2eeLabels?.tooltip || t('e2ee.labelToolTip');
  25. return (
  26. <Tooltip
  27. content = { content }
  28. position = { 'bottom' }>
  29. <Label
  30. color = { COLORS.green }
  31. icon = { IconE2EE } />
  32. </Tooltip>
  33. );
  34. };
  35. /**
  36. * Maps (parts of) the redux state to the associated props of this {@code Component}.
  37. *
  38. * @param {Object} state - The redux state.
  39. * @private
  40. * @returns {IProps}
  41. */
  42. export function _mapStateToProps(state: IReduxState) {
  43. const { e2ee = {} } = state['features/base/config'];
  44. return {
  45. _e2eeLabels: e2ee.labels,
  46. _showLabel: state['features/base/participants'].numberOfParticipantsDisabledE2EE === 0
  47. };
  48. }
  49. export default translate(connect(_mapStateToProps)(E2EELabel));