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.

ToolboxFilmstrip.web.js 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { createToolbarEvent, sendAnalytics } from '../../analytics';
  5. import { translate } from '../../base/i18n';
  6. import { openDeviceSelectionDialog } from '../../device-selection';
  7. import ToolbarButtonV2 from './ToolbarButtonV2';
  8. import { AudioMuteButton, HangupButton, VideoMuteButton } from './buttons';
  9. declare var interfaceConfig: Object;
  10. /**
  11. * Implements the conference toolbox on React/Web for filmstrip only mode.
  12. *
  13. * @extends Component
  14. */
  15. class ToolboxFilmstrip extends Component<*> {
  16. _visibleButtons: Object;
  17. /**
  18. * Initializes a new {@code ToolboxFilmstrip} instance.
  19. *
  20. * @param {Props} props - The read-only React {@code Component} props with
  21. * which the new instance is to be initialized.
  22. */
  23. constructor(props) {
  24. super(props);
  25. this._visibleButtons = new Set(interfaceConfig.TOOLBAR_BUTTONS);
  26. // Bind event handlers so they are only bound once per instance.
  27. this._onToolbarOpenSettings = this._onToolbarOpenSettings.bind(this);
  28. }
  29. /**
  30. * Implements React's {@link Component#render()}.
  31. *
  32. * @inheritdoc
  33. * @returns {ReactElement}
  34. */
  35. render() {
  36. const { t } = this.props;
  37. return (
  38. <div
  39. className = 'filmstrip-toolbox'
  40. id = 'new-toolbox'>
  41. { this._shouldShowButton('microphone')
  42. && <AudioMuteButton tooltipPosition = 'left' /> }
  43. { this._shouldShowButton('camera')
  44. && <VideoMuteButton tooltipPosition = 'left' /> }
  45. { this._shouldShowButton('fodeviceselection')
  46. && <ToolbarButtonV2
  47. accessibilityLabel = 'Settings'
  48. iconName = 'icon-settings'
  49. onClick = { this._onToolbarOpenSettings }
  50. tooltip = { t('toolbar.Settings') }
  51. tooltipPosition = 'left' /> }
  52. { this._shouldShowButton('hangup')
  53. && <HangupButton tooltipPosition = 'left' /> }
  54. </div>
  55. );
  56. }
  57. _onToolbarOpenSettings: () => void;
  58. /**
  59. * Creates an analytics toolbar event for and dispatches an action to open
  60. * the device selection popup dialog.
  61. *
  62. * @private
  63. * @returns {void}
  64. */
  65. _onToolbarOpenSettings() {
  66. sendAnalytics(createToolbarEvent('filmstrip.only.device.selection'));
  67. this.props.dispatch(openDeviceSelectionDialog());
  68. }
  69. _shouldShowButton: (string) => boolean;
  70. /**
  71. * Returns if a button name has been explicitly configured to be displayed.
  72. *
  73. * @param {string} buttonName - The name of the button, as expected in
  74. * {@link intefaceConfig}.
  75. * @private
  76. * @returns {boolean} True if the button should be displayed.
  77. */
  78. _shouldShowButton(buttonName) {
  79. return this._visibleButtons.has(buttonName);
  80. }
  81. }
  82. export default translate(connect()(ToolboxFilmstrip));