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

AbstractGrantModeratorButton.js 1.9KB

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