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.

Toolbar.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect, equals } from '../../../base/redux';
  4. import { SettingsButton } from '../../../settings';
  5. import {
  6. AudioMuteButton,
  7. HangupButton,
  8. VideoMuteButton
  9. } from '../../../toolbox/components';
  10. declare var interfaceConfig: Object;
  11. // XXX: We are not currently using state here, but in the future, when
  12. // interfaceConfig is part of redux we will. This has to be retrieved from the store.
  13. const visibleButtons = new Set(interfaceConfig.TOOLBAR_BUTTONS);
  14. /**
  15. * The type of the React {@code Component} props of {@link Toolbar}.
  16. */
  17. type Props = {
  18. /**
  19. * The set of buttons which should be visible in this {@code Toolbar}.
  20. */
  21. _visibleButtons: Set<string>
  22. };
  23. /**
  24. * Implements the conference toolbar on React/Web for filmstrip-only mode.
  25. *
  26. * @extends Component
  27. */
  28. class Toolbar extends Component<Props> {
  29. /**
  30. * Implements React's {@link Component#render()}.
  31. *
  32. * @inheritdoc
  33. * @returns {ReactElement}
  34. */
  35. render() {
  36. return (
  37. <div
  38. className = 'filmstrip-toolbox'
  39. id = 'new-toolbox'>
  40. <HangupButton
  41. tooltipPosition = 'left'
  42. visible = { this._shouldShowButton('hangup') } />
  43. <AudioMuteButton
  44. tooltipPosition = 'left'
  45. visible = { this._shouldShowButton('microphone') } />
  46. <VideoMuteButton
  47. tooltipPosition = 'left'
  48. visible = { this._shouldShowButton('camera') } />
  49. <SettingsButton
  50. tooltipPosition = 'left'
  51. visible = { this._shouldShowButton('fodeviceselection') } />
  52. </div>
  53. );
  54. }
  55. _shouldShowButton: (string) => boolean;
  56. /**
  57. * Returns if a button name has been explicitly configured to be displayed.
  58. *
  59. * @param {string} buttonName - The name of the button, as expected in
  60. * {@link intefaceConfig}.
  61. * @private
  62. * @returns {boolean} True if the button should be displayed, false
  63. * otherwise.
  64. */
  65. _shouldShowButton(buttonName) {
  66. return this.props._visibleButtons.has(buttonName);
  67. }
  68. }
  69. /**
  70. * Maps (parts of) the redux state to the associated props for this component.
  71. *
  72. * @param {Object} state - The Redux state.
  73. * @private
  74. * @returns {{
  75. * _visibleButtons: Set<string>
  76. * }}
  77. */
  78. function _mapStateToProps(state): Object { // eslint-disable-line no-unused-vars
  79. // XXX: We are not currently using state here, but in the future, when
  80. // interfaceConfig is part of redux we will.
  81. //
  82. // NB: We compute the buttons again here because if URL parameters were used to
  83. // override them we'd miss it.
  84. const buttons = new Set(interfaceConfig.TOOLBAR_BUTTONS);
  85. return {
  86. _visibleButtons: equals(visibleButtons, buttons) ? visibleButtons : buttons
  87. };
  88. }
  89. export default connect(_mapStateToProps)(Toolbar);