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.web.js 2.9KB

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