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.

SettingsMenu.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { translate } from '../../../base/i18n';
  5. import {
  6. getLocalParticipant,
  7. PARTICIPANT_ROLE
  8. } from '../../../base/participants';
  9. import DeviceSelectionButton from './DeviceSelectionButton';
  10. import LanguageSelectDropdown from './LanguageSelectDropdown';
  11. import ModeratorCheckboxes from './ModeratorCheckboxes';
  12. /**
  13. * Implements a React {@link Component} which various ways to change application
  14. * settings.
  15. *
  16. * @extends Component
  17. */
  18. class SettingsMenu extends Component {
  19. /**
  20. * {@code SettingsMenu} component's property types.
  21. *
  22. * @static
  23. */
  24. static propTypes = {
  25. /**
  26. * Whether or not the local user is a moderator.
  27. */
  28. _isModerator: PropTypes.bool,
  29. /**
  30. * Whether or not the button to open device selection should display.
  31. */
  32. showDeviceSettings: PropTypes.bool,
  33. /**
  34. * Whether or not the dropdown to change the current translated language
  35. * should display.
  36. */
  37. showLanguageSettings: PropTypes.bool,
  38. /**
  39. * Whether or not moderator-only actions that affect the conference
  40. * should display.
  41. */
  42. showModeratorSettings: PropTypes.bool,
  43. /**
  44. * Whether or not menu section should have section titles displayed.
  45. */
  46. showTitles: PropTypes.bool,
  47. /**
  48. * Invoked to obtain translated strings.
  49. */
  50. t: PropTypes.func
  51. };
  52. /**
  53. * Implements React's {@link Component#render()}.
  54. *
  55. * @inheritdoc
  56. * @returns {ReactElement}
  57. */
  58. render() {
  59. const {
  60. _isModerator,
  61. showDeviceSettings,
  62. showLanguageSettings,
  63. showModeratorSettings,
  64. showTitles,
  65. t
  66. } = this.props;
  67. return (
  68. <div className = 'settings-menu'>
  69. <div className = 'title'>
  70. { t('settings.title') }
  71. </div>
  72. { showLanguageSettings
  73. ? <LanguageSelectDropdown />
  74. : null }
  75. { showDeviceSettings
  76. ? <DeviceSelectionButton showTitle = { showTitles } />
  77. : null }
  78. { _isModerator && showModeratorSettings
  79. ? <ModeratorCheckboxes showTitle = { showTitles } />
  80. : null }
  81. </div>
  82. );
  83. }
  84. }
  85. /**
  86. * Maps parts of Redux store to component prop types.
  87. *
  88. * @param {Object} state - Snapshot of Redux store.
  89. * @returns {{
  90. * _isModerator: boolean
  91. * }}
  92. */
  93. function _mapStateToProps(state) {
  94. return {
  95. _isModerator:
  96. getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR
  97. };
  98. }
  99. export default translate(connect(_mapStateToProps)(SettingsMenu));