123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- import { Theme } from '@mui/material';
- import clsx from 'clsx';
- import React from 'react';
- import { WithTranslation } from 'react-i18next';
- import { withStyles } from 'tss-react/mui';
-
- import AbstractDialogTab, {
- IProps as AbstractDialogTabProps
- } from '../../../base/dialog/components/web/AbstractDialogTab';
- import { translate } from '../../../base/i18n/functions';
- import Checkbox from '../../../base/ui/components/web/Checkbox';
- import Select from '../../../base/ui/components/web/Select';
- import { MAX_ACTIVE_PARTICIPANTS } from '../../../filmstrip/constants';
-
- /**
- * The type of the React {@code Component} props of {@link MoreTab}.
- */
- export interface IProps extends AbstractDialogTabProps, WithTranslation {
-
- /**
- * CSS classes object.
- */
- classes?: Partial<Record<keyof ReturnType<typeof styles>, string>>;
-
- /**
- * The currently selected language to display in the language select
- * dropdown.
- */
- currentLanguage: string;
-
- /**
- * Whether to show hide self view setting.
- */
- disableHideSelfView: boolean;
-
- /**
- * Whether or not follow me is currently active (enabled by some other participant).
- */
- followMeActive: boolean;
-
- /**
- * Whether or not to hide self-view screen.
- */
- hideSelfView: boolean;
-
- /**
- * Whether we are in visitors mode.
- */
- iAmVisitor: boolean;
-
- /**
- * All available languages to display in the language select dropdown.
- */
- languages: Array<string>;
-
- /**
- * The number of max participants to display on stage.
- */
- maxStageParticipants: number;
-
- /**
- * Whether or not to display the language select dropdown.
- */
- showLanguageSettings: boolean;
-
- /**
- * Whether or not to display moderator-only settings.
- */
- showModeratorSettings: boolean;
-
- /**
- * Whether or not to show prejoin screen.
- */
- showPrejoinPage: boolean;
-
- /**
- * Whether or not to display the prejoin settings section.
- */
- showPrejoinSettings: boolean;
-
- /**
- * Whether or not the stage filmstrip is enabled.
- */
- stageFilmstripEnabled: boolean;
- }
-
- const styles = (theme: Theme) => {
- return {
- container: {
- display: 'flex',
- flexDirection: 'column' as const,
- padding: '0 2px'
- },
-
- divider: {
- margin: `${theme.spacing(4)} 0`,
- width: '100%',
- height: '1px',
- border: 0,
- backgroundColor: theme.palette.ui03
- },
-
- checkbox: {
- margin: `${theme.spacing(3)} 0`
- }
- };
- };
-
- /**
- * React {@code Component} for modifying language and moderator settings.
- *
- * @augments Component
- */
- class MoreTab extends AbstractDialogTab<IProps, any> {
- /**
- * Initializes a new {@code MoreTab} instance.
- *
- * @param {Object} props - The read-only properties with which the new
- * instance is to be initialized.
- */
- constructor(props: IProps) {
- super(props);
-
- // Bind event handler so it is only bound once for every instance.
- this._onShowPrejoinPageChanged = this._onShowPrejoinPageChanged.bind(this);
- this._renderMaxStageParticipantsSelect = this._renderMaxStageParticipantsSelect.bind(this);
- this._onMaxStageParticipantsSelect = this._onMaxStageParticipantsSelect.bind(this);
- this._onHideSelfViewChanged = this._onHideSelfViewChanged.bind(this);
- this._onLanguageItemSelect = this._onLanguageItemSelect.bind(this);
- }
-
- /**
- * Implements React's {@link Component#render()}.
- *
- * @inheritdoc
- * @returns {ReactElement}
- */
- render() {
- const {
- showPrejoinSettings,
- disableHideSelfView,
- iAmVisitor,
- hideSelfView,
- showLanguageSettings,
- t
- } = this.props;
- const classes = withStyles.getClasses(this.props);
-
- return (
- <div
- className = { clsx('more-tab', classes.container) }
- key = 'more'>
- {showPrejoinSettings && <>
- {this._renderPrejoinScreenSettings()}
- <hr className = { classes.divider } />
- </>}
- {this._renderMaxStageParticipantsSelect()}
- {!disableHideSelfView && !iAmVisitor && (
- <Checkbox
- checked = { hideSelfView }
- className = { classes.checkbox }
- label = { t('videothumbnail.hideSelfView') }
- name = 'hide-self-view'
- onChange = { this._onHideSelfViewChanged } />
- )}
- {showLanguageSettings && this._renderLanguageSelect()}
- </div>
- );
- }
-
- /**
- * Callback invoked to select if the lobby
- * should be shown.
- *
- * @param {Object} e - The key event to handle.
- *
- * @returns {void}
- */
- _onShowPrejoinPageChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
- super._onChange({ showPrejoinPage: checked });
- }
-
- /**
- * Callback invoked to select a max number of stage participants from the select dropdown.
- *
- * @param {Object} e - The key event to handle.
- * @private
- * @returns {void}
- */
- _onMaxStageParticipantsSelect(e: React.ChangeEvent<HTMLSelectElement>) {
- const maxParticipants = Number(e.target.value);
-
- super._onChange({ maxStageParticipants: maxParticipants });
- }
-
- /**
- * Callback invoked to select if hide self view should be enabled.
- *
- * @param {Object} e - The key event to handle.
- *
- * @returns {void}
- */
- _onHideSelfViewChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
- super._onChange({ hideSelfView: checked });
- }
-
- /**
- * Callback invoked to select a language from select dropdown.
- *
- * @param {Object} e - The key event to handle.
- *
- * @returns {void}
- */
- _onLanguageItemSelect(e: React.ChangeEvent<HTMLSelectElement>) {
- const language = e.target.value;
-
- super._onChange({ currentLanguage: language });
- }
-
- /**
- * Returns the React Element for modifying prejoin screen settings.
- *
- * @private
- * @returns {ReactElement}
- */
- _renderPrejoinScreenSettings() {
- const { t, showPrejoinPage } = this.props;
-
- return (
- <Checkbox
- checked = { showPrejoinPage }
- label = { t('prejoin.showScreen') }
- name = 'show-prejoin-page'
- onChange = { this._onShowPrejoinPageChanged } />
- );
- }
-
- /**
- * Returns the React Element for the max stage participants dropdown.
- *
- * @returns {ReactElement}
- */
- _renderMaxStageParticipantsSelect() {
- const { maxStageParticipants, t, stageFilmstripEnabled } = this.props;
-
- if (!stageFilmstripEnabled) {
- return null;
- }
- const maxParticipantsItems = Array(MAX_ACTIVE_PARTICIPANTS).fill(0)
- .map((no, index) => {
- return {
- value: index + 1,
- label: `${index + 1}`
- };
- });
-
- return (
- <Select
- id = 'more-maxStageParticipants-select'
- label = { t('settings.maxStageParticipants') }
- onChange = { this._onMaxStageParticipantsSelect }
- options = { maxParticipantsItems }
- value = { maxStageParticipants } />
- );
- }
-
- /**
- * Returns the menu item for changing displayed language.
- *
- * @private
- * @returns {ReactElement}
- */
- _renderLanguageSelect() {
- const {
- currentLanguage,
- languages,
- t
- } = this.props;
-
- const languageItems
- = languages.map((language: string) => {
- return {
- value: language,
- label: t(`languages:${language}`)
- };
- });
-
- return (
- <Select
- id = 'more-language-select'
- label = { t('settings.language') }
- onChange = { this._onLanguageItemSelect }
- options = { languageItems }
- value = { currentLanguage } />
- );
- }
- }
-
- export default withStyles(translate(MoreTab), styles);
|