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.

AbstractGrantModeratorDialog.ts 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { Component } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { createRemoteVideoMenuButtonEvent } from '../../analytics/AnalyticsEvents';
  4. import { sendAnalytics } from '../../analytics/functions';
  5. import { IReduxState, IStore } from '../../app/types';
  6. import { grantModerator } from '../../base/participants/actions';
  7. import { getParticipantById } from '../../base/participants/functions';
  8. interface IProps extends WithTranslation {
  9. /**
  10. * The Redux dispatch function.
  11. */
  12. dispatch: IStore['dispatch'];
  13. /**
  14. * The ID of the remote participant to be granted moderator rights.
  15. */
  16. participantID: string;
  17. /**
  18. * The name of the remote participant to be granted moderator rights.
  19. */
  20. participantName: string;
  21. }
  22. /**
  23. * Abstract dialog to confirm granting moderator to a participant.
  24. */
  25. export default class AbstractGrantModeratorDialog
  26. extends Component<IProps> {
  27. /**
  28. * Initializes a new {@code AbstractGrantModeratorDialog} instance.
  29. *
  30. * @inheritdoc
  31. */
  32. constructor(props: IProps) {
  33. super(props);
  34. this._onSubmit = this._onSubmit.bind(this);
  35. }
  36. /**
  37. * Callback for the confirm button.
  38. *
  39. * @private
  40. * @returns {boolean} - True (to note that the modal should be closed).
  41. */
  42. _onSubmit() {
  43. const { dispatch, participantID } = this.props;
  44. sendAnalytics(createRemoteVideoMenuButtonEvent(
  45. 'grant.moderator.button',
  46. {
  47. 'participant_id': participantID
  48. }));
  49. dispatch(grantModerator(participantID));
  50. return true;
  51. }
  52. }
  53. /**
  54. * Maps (parts of) the Redux state to the associated {@code AbstractMuteEveryoneDialog}'s props.
  55. *
  56. * @param {IReduxState} state - The redux state.
  57. * @param {Object} ownProps - The properties explicitly passed to the component.
  58. * @returns {IProps}
  59. */
  60. export function abstractMapStateToProps(state: IReduxState, ownProps: IProps) {
  61. return {
  62. participantName: getParticipantById(state, ownProps.participantID)?.name
  63. };
  64. }