選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

AbstractGrantModeratorButton.ts 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { IReduxState } from '../../app/types';
  2. import { openDialog } from '../../base/dialog/actions';
  3. import { IconModerator } from '../../base/icons/svg';
  4. import { PARTICIPANT_ROLE } from '../../base/participants/constants';
  5. import { getLocalParticipant, getParticipantById, isParticipantModerator } from '../../base/participants/functions';
  6. import AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
  7. import { GrantModeratorDialog } from './';
  8. export interface IProps extends AbstractButtonProps {
  9. /**
  10. * The ID of the participant for whom to grant moderator status.
  11. */
  12. participantID: string;
  13. }
  14. /**
  15. * An abstract remote video menu button which kicks the remote participant.
  16. */
  17. export default class AbstractGrantModeratorButton extends AbstractButton<IProps> {
  18. accessibilityLabel = 'toolbar.accessibilityLabel.grantModerator';
  19. icon = IconModerator;
  20. label = 'videothumbnail.grantModerator';
  21. /**
  22. * Handles clicking / pressing the button, and kicks the participant.
  23. *
  24. * @private
  25. * @returns {void}
  26. */
  27. _handleClick() {
  28. const { dispatch, participantID } = this.props;
  29. dispatch(openDialog(GrantModeratorDialog, { participantID }));
  30. }
  31. }
  32. /**
  33. * Function that maps parts of Redux state tree into component props.
  34. *
  35. * @param {Object} state - Redux state.
  36. * @param {Object} ownProps - Properties of component.
  37. * @private
  38. * @returns {{
  39. * visible: boolean
  40. * }}
  41. */
  42. export function _mapStateToProps(state: IReduxState, ownProps: any) {
  43. const { participantID } = ownProps;
  44. const localParticipant = getLocalParticipant(state);
  45. const targetParticipant = getParticipantById(state, participantID);
  46. return {
  47. visible: Boolean(localParticipant?.role === PARTICIPANT_ROLE.MODERATOR)
  48. && !isParticipantModerator(targetParticipant)
  49. };
  50. }