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.

ParticipantsPaneButton.tsx 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import { IReduxState } from '../../../app/types';
  4. import { translate } from '../../../base/i18n/functions';
  5. import { IconUsers } from '../../../base/icons/svg';
  6. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  7. import {
  8. close as closeParticipantsPane,
  9. open as openParticipantsPane
  10. } from '../../../participants-pane/actions.web';
  11. import ParticipantsCounter from './ParticipantsCounter';
  12. /**
  13. * The type of the React {@code Component} props of {@link ParticipantsPaneButton}.
  14. */
  15. interface IProps extends AbstractButtonProps {
  16. /**
  17. * Whether or not the participants pane is open.
  18. */
  19. _isOpen: boolean;
  20. }
  21. /**
  22. * Implementation of a button for accessing participants pane.
  23. */
  24. class ParticipantsPaneButton extends AbstractButton<IProps> {
  25. accessibilityLabel = 'toolbar.accessibilityLabel.participants';
  26. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.closeParticipantsPane';
  27. icon = IconUsers;
  28. label = 'toolbar.participants';
  29. tooltip = 'toolbar.participants';
  30. toggledTooltip = 'toolbar.closeParticipantsPane';
  31. /**
  32. * Indicates whether this button is in toggled state or not.
  33. *
  34. * @override
  35. * @protected
  36. * @returns {boolean}
  37. */
  38. _isToggled() {
  39. return this.props._isOpen;
  40. }
  41. /**
  42. * Handles clicking the button, and toggles the participants pane.
  43. *
  44. * @private
  45. * @returns {void}
  46. */
  47. _handleClick() {
  48. const { dispatch, _isOpen } = this.props;
  49. if (_isOpen) {
  50. dispatch(closeParticipantsPane());
  51. } else {
  52. dispatch(openParticipantsPane());
  53. }
  54. }
  55. /**
  56. * Overrides AbstractButton's {@link Component#render()}.
  57. *
  58. * @override
  59. * @protected
  60. * @returns {React$Node}
  61. */
  62. render() {
  63. return (
  64. <div
  65. className = 'toolbar-button-with-badge'>
  66. {super.render()}
  67. <ParticipantsCounter />
  68. </div>
  69. );
  70. }
  71. }
  72. /**
  73. * Maps part of the Redux state to the props of this component.
  74. *
  75. * @param {Object} state - The Redux state.
  76. * @returns {IProps}
  77. */
  78. function mapStateToProps(state: IReduxState) {
  79. const { isOpen } = state['features/participants-pane'];
  80. return {
  81. _isOpen: isOpen
  82. };
  83. }
  84. export default translate(connect(mapStateToProps)(ParticipantsPaneButton));