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.

PinButton.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // @flow
  2. import { translate } from '../../../base/i18n';
  3. import { IconPin } from '../../../base/icons';
  4. import { pinParticipant } from '../../../base/participants';
  5. import { connect } from '../../../base/redux';
  6. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  7. import { shouldDisplayTileView } from '../../../video-layout/functions';
  8. export type Props = AbstractButtonProps & {
  9. /**
  10. * True if tile view is currently enabled.
  11. */
  12. _tileViewEnabled: boolean,
  13. /**
  14. * The redux {@code dispatch} function.
  15. */
  16. dispatch: Function,
  17. /**
  18. * The ID of the participant that this button is supposed to pin.
  19. */
  20. participantID: string,
  21. /**
  22. * The function to be used to translate i18n labels.
  23. */
  24. t: Function
  25. };
  26. /**
  27. * A remote video menu button which pins a participant and exist the tile view.
  28. */
  29. class PinButton extends AbstractButton<Props, *> {
  30. accessibilityLabel = 'toolbar.accessibilityLabel.show';
  31. icon = IconPin;
  32. label = 'videothumbnail.show';
  33. /**
  34. * Handles clicking / pressing the button, and kicks the participant.
  35. *
  36. * @private
  37. * @returns {void}
  38. */
  39. _handleClick() {
  40. const { dispatch } = this.props;
  41. // Pin participant, it will automatically exit the tile view
  42. dispatch(pinParticipant(this.props.participantID));
  43. }
  44. }
  45. /**
  46. * Maps part of the Redux state to the props of this component.
  47. *
  48. * @param {Object} state - The Redux state.
  49. * @returns {Props}
  50. */
  51. function _mapStateToProps(state) {
  52. const { isOpen } = state['features/participants-pane'];
  53. return {
  54. visible: !isOpen && shouldDisplayTileView(state)
  55. };
  56. }
  57. export default translate(connect(_mapStateToProps)(PinButton));