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.

VerifyParticipantButton.tsx 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { withStyles } from '@mui/styles';
  2. import React, { Component } from 'react';
  3. import { WithTranslation } from 'react-i18next';
  4. import { connect } from 'react-redux';
  5. import { IReduxState } from '../../../app/types';
  6. import { translate } from '../../../base/i18n/functions';
  7. import { IconCheck } from '../../../base/icons/svg';
  8. import ContextMenuItem from '../../../base/ui/components/web/ContextMenuItem';
  9. import { startVerification } from '../../../e2ee/actions';
  10. /**
  11. * The type of the React {@code Component} props of
  12. * {@link VerifyParticipantButton}.
  13. */
  14. interface IProps extends WithTranslation {
  15. /**
  16. * The redux {@code dispatch} function.
  17. */
  18. dispatch: Function;
  19. /**
  20. * The ID of the participant that this button is supposed to verified.
  21. */
  22. participantID: string;
  23. }
  24. const styles = () => {
  25. return {
  26. triggerButton: {
  27. padding: '3px !important',
  28. borderRadius: '4px'
  29. },
  30. contextMenu: {
  31. position: 'relative' as const,
  32. marginTop: 0,
  33. right: 'auto',
  34. marginRight: '4px',
  35. marginBottom: '4px'
  36. }
  37. };
  38. };
  39. /**
  40. * React {@code Component} for displaying an icon associated with opening the
  41. * the {@code VideoMenu}.
  42. *
  43. * @augments {Component}
  44. */
  45. class VerifyParticipantButton extends Component<IProps> {
  46. /**
  47. * Instantiates a new {@code Component}.
  48. *
  49. * @inheritdoc
  50. */
  51. constructor(props: IProps) {
  52. super(props);
  53. this._handleClick = this._handleClick.bind(this);
  54. }
  55. /**
  56. * Implements React's {@link Component#render()}.
  57. *
  58. * @inheritdoc
  59. * @returns {ReactElement}
  60. */
  61. render() {
  62. const { participantID, t } = this.props;
  63. return (
  64. <ContextMenuItem
  65. accessibilityLabel = { t('videothumbnail.verify') }
  66. className = 'verifylink'
  67. icon = { IconCheck }
  68. id = { `verifylink_${participantID}` }
  69. // eslint-disable-next-line react/jsx-handler-names
  70. onClick = { this._handleClick }
  71. text = { t('videothumbnail.verify') } />
  72. );
  73. }
  74. /**
  75. * Handles clicking / pressing the button, and starts the participant verification process.
  76. *
  77. * @private
  78. * @returns {void}
  79. */
  80. _handleClick() {
  81. const { dispatch, participantID } = this.props;
  82. dispatch(startVerification(participantID));
  83. }
  84. }
  85. /**
  86. * Maps (parts of) the Redux state to the associated {@code RemoteVideoMenuTriggerButton}'s props.
  87. *
  88. * @param {Object} state - The Redux state.
  89. * @param {Object} ownProps - The own props of the component.
  90. * @private
  91. * @returns {IProps}
  92. */
  93. function _mapStateToProps(state: IReduxState, ownProps: Partial<IProps>) {
  94. const { participantID } = ownProps;
  95. return {
  96. _participantID: participantID
  97. };
  98. }
  99. export default translate(connect(_mapStateToProps)(withStyles(styles)(VerifyParticipantButton)));