您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AbstractGrantModeratorButton.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // @flow
  2. import { openDialog } from '../../base/dialog';
  3. import { IconCrown } from '../../base/icons';
  4. import {
  5. getLocalParticipant,
  6. getParticipantById,
  7. isParticipantModerator,
  8. PARTICIPANT_ROLE
  9. } from '../../base/participants';
  10. import { AbstractButton } from '../../base/toolbox';
  11. import type { AbstractButtonProps } from '../../base/toolbox';
  12. import { GrantModeratorDialog } from '.';
  13. export type Props = AbstractButtonProps & {
  14. /**
  15. * The redux {@code dispatch} function.
  16. */
  17. dispatch: Function,
  18. /**
  19. * The ID of the participant for whom to grant moderator status.
  20. */
  21. participantID: string,
  22. /**
  23. * The function to be used to translate i18n labels.
  24. */
  25. t: Function
  26. };
  27. /**
  28. * An abstract remote video menu button which kicks the remote participant.
  29. */
  30. export default class AbstractGrantModeratorButton extends AbstractButton<Props, *> {
  31. accessibilityLabel = 'toolbar.accessibilityLabel.grantModerator';
  32. icon = IconCrown;
  33. label = 'videothumbnail.grantModerator';
  34. /**
  35. * Handles clicking / pressing the button, and kicks the participant.
  36. *
  37. * @private
  38. * @returns {void}
  39. */
  40. _handleClick() {
  41. const { dispatch, participantID } = this.props;
  42. dispatch(openDialog(GrantModeratorDialog, { participantID }));
  43. }
  44. }
  45. /**
  46. * Function that maps parts of Redux state tree into component props.
  47. *
  48. * @param {Object} state - Redux state.
  49. * @param {Object} ownProps - Properties of component.
  50. * @private
  51. * @returns {{
  52. * visible: boolean
  53. * }}
  54. */
  55. export function _mapStateToProps(state: Object, ownProps: Props) {
  56. const { participantID } = ownProps;
  57. const localParticipant = getLocalParticipant(state);
  58. const targetParticipant = getParticipantById(state, participantID);
  59. return {
  60. visible: Boolean(localParticipant?.role === PARTICIPANT_ROLE.MODERATOR)
  61. && !isParticipantModerator(targetParticipant)
  62. };
  63. }