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.

TileViewButton.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // @flow
  2. import Logger from 'jitsi-meet-logger';
  3. import type { Dispatch } from 'redux';
  4. import {
  5. createToolbarEvent,
  6. sendAnalytics
  7. } from '../../analytics';
  8. import { translate } from '../../base/i18n';
  9. import { connect } from '../../base/redux';
  10. import {
  11. AbstractButton,
  12. type AbstractButtonProps
  13. } from '../../base/toolbox';
  14. import { setTileView } from '../actions';
  15. const logger = Logger.getLogger(__filename);
  16. /**
  17. * The type of the React {@code Component} props of {@link TileViewButton}.
  18. */
  19. type Props = AbstractButtonProps & {
  20. /**
  21. * Whether or not tile view layout has been enabled as the user preference.
  22. */
  23. _tileViewEnabled: boolean,
  24. /**
  25. * Used to dispatch actions from the buttons.
  26. */
  27. dispatch: Dispatch<any>
  28. };
  29. /**
  30. * Component that renders a toolbar button for toggling the tile layout view.
  31. *
  32. * @extends AbstractButton
  33. */
  34. class TileViewButton<P: Props> extends AbstractButton<P, *> {
  35. accessibilityLabel = 'toolbar.accessibilityLabel.tileView';
  36. iconName = 'icon-tiles-many';
  37. label = 'toolbar.enterTileView';
  38. toggledLabel = 'toolbar.exitTileView';
  39. toggledIconName = 'icon-tiles-many toggled';
  40. tooltip = 'toolbar.tileViewToggle';
  41. /**
  42. * Handles clicking / pressing the button.
  43. *
  44. * @override
  45. * @protected
  46. * @returns {void}
  47. */
  48. _handleClick() {
  49. const { _tileViewEnabled, dispatch } = this.props;
  50. sendAnalytics(createToolbarEvent(
  51. 'tileview.button',
  52. {
  53. 'is_enabled': _tileViewEnabled
  54. }));
  55. const value = !_tileViewEnabled;
  56. logger.debug(`Tile view ${value ? 'enable' : 'disable'}`);
  57. dispatch(setTileView(value));
  58. }
  59. /**
  60. * Indicates whether this button is in toggled state or not.
  61. *
  62. * @override
  63. * @protected
  64. * @returns {boolean}
  65. */
  66. _isToggled() {
  67. return this.props._tileViewEnabled;
  68. }
  69. }
  70. /**
  71. * Maps (parts of) the redux state to the associated props for the
  72. * {@code TileViewButton} component.
  73. *
  74. * @param {Object} state - The Redux state.
  75. * @returns {{
  76. * _tileViewEnabled: boolean
  77. * }}
  78. */
  79. function _mapStateToProps(state) {
  80. return {
  81. _tileViewEnabled: state['features/video-layout'].tileViewEnabled
  82. };
  83. }
  84. export default translate(connect(_mapStateToProps)(TileViewButton));