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.

MoreTab.js 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. // @flow
  2. import { Checkbox } from '@atlaskit/checkbox';
  3. import DropdownMenu, {
  4. DropdownItem,
  5. DropdownItemGroup
  6. } from '@atlaskit/dropdown-menu';
  7. import React from 'react';
  8. import { AbstractDialogTab } from '../../../base/dialog';
  9. import type { Props as AbstractDialogTabProps } from '../../../base/dialog';
  10. import { translate } from '../../../base/i18n';
  11. /**
  12. * The type of the React {@code Component} props of {@link MoreTab}.
  13. */
  14. export type Props = {
  15. ...$Exact<AbstractDialogTabProps>,
  16. /**
  17. * The currently selected language to display in the language select
  18. * dropdown.
  19. */
  20. currentLanguage: string,
  21. /**
  22. * Whether or not follow me is currently active (enabled by some other participant).
  23. */
  24. followMeActive: boolean,
  25. /**
  26. * Whether or not the user has selected the Follow Me feature to be enabled.
  27. */
  28. followMeEnabled: boolean,
  29. /**
  30. * All available languages to display in the language select dropdown.
  31. */
  32. languages: Array<string>,
  33. /**
  34. * Whether or not to display the language select dropdown.
  35. */
  36. showLanguageSettings: boolean,
  37. /**
  38. * Whether or not to display moderator-only settings.
  39. */
  40. showModeratorSettings: boolean,
  41. /**
  42. * Whether or not to display the prejoin settings section.
  43. */
  44. showPrejoinSettings: boolean,
  45. /**
  46. * Whether or not to show prejoin screen.
  47. */
  48. showPrejoinPage: boolean,
  49. /**
  50. * Whether or not the user has selected the Start Audio Muted feature to be
  51. * enabled.
  52. */
  53. startAudioMuted: boolean,
  54. /**
  55. * Whether or not the user has selected the Start Video Muted feature to be
  56. * enabled.
  57. */
  58. startVideoMuted: boolean,
  59. /**
  60. * Invoked to obtain translated strings.
  61. */
  62. t: Function
  63. };
  64. /**
  65. * The type of the React {@code Component} state of {@link MoreTab}.
  66. */
  67. type State = {
  68. /**
  69. * Whether or not the language select dropdown is open.
  70. */
  71. isLanguageSelectOpen: boolean
  72. };
  73. /**
  74. * React {@code Component} for modifying language and moderator settings.
  75. *
  76. * @extends Component
  77. */
  78. class MoreTab extends AbstractDialogTab<Props, State> {
  79. /**
  80. * Initializes a new {@code MoreTab} instance.
  81. *
  82. * @param {Object} props - The read-only properties with which the new
  83. * instance is to be initialized.
  84. */
  85. constructor(props: Props) {
  86. super(props);
  87. this.state = {
  88. isLanguageSelectOpen: false
  89. };
  90. // Bind event handler so it is only bound once for every instance.
  91. this._onLanguageDropdownOpenChange
  92. = this._onLanguageDropdownOpenChange.bind(this);
  93. }
  94. /**
  95. * Implements React's {@link Component#render()}.
  96. *
  97. * @inheritdoc
  98. * @returns {ReactElement}
  99. */
  100. render() {
  101. const { showModeratorSettings, showLanguageSettings, showPrejoinSettings } = this.props;
  102. const content = [];
  103. if (showPrejoinSettings) {
  104. content.push(this._renderPrejoinScreenSettings());
  105. }
  106. if (showModeratorSettings) {
  107. content.push(this._renderModeratorSettings());
  108. }
  109. if (showLanguageSettings) {
  110. content.push(this._renderLangaugeSelect());
  111. }
  112. return <div className = 'more-tab'>{ content }</div>;
  113. }
  114. _onLanguageDropdownOpenChange: (Object) => void;
  115. /**
  116. * Callback invoked to toggle display of the language select dropdown.
  117. *
  118. * @param {Object} event - The event for opening or closing the dropdown.
  119. * @private
  120. * @returns {void}
  121. */
  122. _onLanguageDropdownOpenChange({ isOpen }) {
  123. this.setState({ isLanguageSelectOpen: isOpen });
  124. }
  125. /**
  126. * Returns the menu item for changing displayed language.
  127. *
  128. * @private
  129. * @returns {ReactElement}
  130. */
  131. _renderLangaugeSelect() {
  132. const {
  133. currentLanguage,
  134. languages,
  135. t
  136. } = this.props;
  137. const languageItems
  138. = languages.map(language => (
  139. <DropdownItem
  140. key = { language }
  141. // eslint-disable-next-line react/jsx-no-bind
  142. onClick = {
  143. e => {
  144. e.stopPropagation();
  145. super._onChange({ currentLanguage: language });
  146. }
  147. }>
  148. { t(`languages:${language}`) }
  149. </DropdownItem>));
  150. return (
  151. <div
  152. className = 'settings-sub-pane language-settings'
  153. key = 'language'>
  154. <div className = 'mock-atlaskit-label'>
  155. { t('settings.language') }
  156. </div>
  157. <div className = 'dropdown-menu'>
  158. <DropdownMenu
  159. isOpen = { this.state.isLanguageSelectOpen }
  160. onOpenChange = { this._onLanguageDropdownOpenChange }
  161. shouldFitContainer = { true }
  162. trigger = { currentLanguage
  163. ? t(`languages:${currentLanguage}`)
  164. : '' }
  165. triggerButtonProps = {{
  166. shouldFitContainer: true
  167. }}
  168. triggerType = 'button'>
  169. <DropdownItemGroup>
  170. { languageItems }
  171. </DropdownItemGroup>
  172. </DropdownMenu>
  173. </div>
  174. </div>
  175. );
  176. }
  177. /**
  178. * Returns the React Element for modifying conference-wide settings.
  179. *
  180. * @private
  181. * @returns {ReactElement}
  182. */
  183. _renderModeratorSettings() {
  184. const {
  185. followMeActive,
  186. followMeEnabled,
  187. startAudioMuted,
  188. startVideoMuted,
  189. t
  190. } = this.props;
  191. return (
  192. <div
  193. className = 'settings-sub-pane'
  194. key = 'moderator'>
  195. <div className = 'mock-atlaskit-label'>
  196. { t('settings.moderator') }
  197. </div>
  198. <Checkbox
  199. isChecked = { startAudioMuted }
  200. label = { t('settings.startAudioMuted') }
  201. name = 'start-audio-muted'
  202. // eslint-disable-next-line react/jsx-no-bind
  203. onChange = {
  204. ({ target: { checked } }) =>
  205. super._onChange({ startAudioMuted: checked })
  206. } />
  207. <Checkbox
  208. isChecked = { startVideoMuted }
  209. label = { t('settings.startVideoMuted') }
  210. name = 'start-video-muted'
  211. // eslint-disable-next-line react/jsx-no-bind
  212. onChange = {
  213. ({ target: { checked } }) =>
  214. super._onChange({ startVideoMuted: checked })
  215. } />
  216. <Checkbox
  217. isChecked = { followMeEnabled && !followMeActive }
  218. isDisabled = { followMeActive }
  219. label = { t('settings.followMe') }
  220. name = 'follow-me'
  221. // eslint-disable-next-line react/jsx-no-bind
  222. onChange = {
  223. ({ target: { checked } }) =>
  224. super._onChange({ followMeEnabled: checked })
  225. } />
  226. </div>
  227. );
  228. }
  229. /**
  230. * Returns the React Element for modifying prejoin screen settings.
  231. *
  232. * @private
  233. * @returns {ReactElement}
  234. */
  235. _renderPrejoinScreenSettings() {
  236. const { t, showPrejoinPage } = this.props;
  237. return (
  238. <div
  239. className = 'settings-sub-pane'
  240. key = 'prejoin-screen'>
  241. <div className = 'mock-atlaskit-label'>
  242. { t('prejoin.premeeting') }
  243. </div>
  244. <Checkbox
  245. isChecked = { showPrejoinPage }
  246. label = { t('prejoin.showScreen') }
  247. name = 'show-prejoin-page'
  248. // eslint-disable-next-line react/jsx-no-bind
  249. onChange = {
  250. ({ target: { checked } }) =>
  251. super._onChange({ showPrejoinPage: checked })
  252. } />
  253. </div>
  254. );
  255. }
  256. }
  257. export default translate(MoreTab);