jiti-meet/react/features/video-quality/components/OverflowMenuVideoQualityIte...

115 lines
3.0 KiB
JavaScript
Raw Normal View History

// @flow
import React, { Component } from 'react';
import { translate } from '../../base/i18n';
2019-08-30 16:39:06 +00:00
import {
Icon,
IconVideoQualityAudioOnly,
IconVideoQualityHD,
IconVideoQualityLD,
IconVideoQualitySD
} from '../../base/icons';
2019-03-21 16:38:29 +00:00
import { connect } from '../../base/redux';
import { VIDEO_QUALITY_LEVELS } from '../constants';
2020-09-01 21:45:59 +00:00
import { findNearestQualityLevel } from '../functions';
/**
* A map of of selectable receive resolutions to corresponding icons.
*
* @private
* @type {Object}
*/
const VIDEO_QUALITY_TO_ICON = {
2019-08-30 16:39:06 +00:00
[VIDEO_QUALITY_LEVELS.HIGH]: IconVideoQualityHD,
[VIDEO_QUALITY_LEVELS.STANDARD]: IconVideoQualitySD,
[VIDEO_QUALITY_LEVELS.LOW]: IconVideoQualityLD
};
/**
* The type of the React {@code Component} props of
* {@link OverflowMenuVideoQualityItem}.
*/
type Props = {
/**
* Whether or not audio only mode is currently enabled.
*/
_audioOnly: boolean,
/**
* The currently configured maximum quality resolution to be received from
* and sent to remote participants.
*/
_videoQuality: number,
/**
* Callback to invoke when {@link OverflowMenuVideoQualityItem} is clicked.
*/
onClick: Function,
/**
* Invoked to obtain translated strings.
*/
t: Function
};
/**
* React {@code Component} responsible for displaying a button in the overflow
* menu of the toolbar, including an icon showing the currently selected
* max receive quality.
*
* @extends Component
*/
class OverflowMenuVideoQualityItem extends Component<Props> {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
const { _audioOnly, _videoQuality } = this.props;
2020-09-01 21:45:59 +00:00
const videoQualityLevel = findNearestQualityLevel(_videoQuality);
const icon = _audioOnly || !videoQualityLevel
2019-08-30 16:39:06 +00:00
? IconVideoQualityAudioOnly
2020-09-01 21:45:59 +00:00
: VIDEO_QUALITY_TO_ICON[videoQualityLevel];
return (
<li
fix(i18n) Accessiblity labels translations (#3071) * fix(toolbar): accessibilityLabel should be translatable. This commit adds a helper property to get the accessibilityLabel of an item, providing a translation if one is available. This mimics the behavior of label and tooltip. * fix(toolbar) 'hangup' button accessibilityLabel i18n * fix(toolbar) 'mute' button accessibilityLabel i18n * fix(toolbar) 'videomute' button accessibilityLabel i18n * fix(toolbar) 'moreActions' button accessibilityLabel i18n * fix(toolbar) 'shareRoom' button accessibilityLabel i18n * fix(toolbar) 'audioRoute' button accessibilityLabel i18n * fix(toolbar) 'toggleCamera' button accessibilityLabel i18n * fix(toolbar) 'audioOnly' button accessibilityLabel i18n * fix(toolbar) 'roomLock' button accessibilityLabel i18n * fix(toolbar) 'pip' button accessibilityLabel i18n * fix(toolbar) 'invite' button accessibilityLabel i18n * fix(toolbar) 'raiseHand' button accessibilityLabel i18n * fix(toolbar) 'chat' button accessibilityLabel i18n * fix(toolbar) 'shareYourScreen' button accessibilityLabel i18n * fix(toolbar) 'fullScreen' button accessibilityLabel i18n * fix(toolbar) 'sharedvideo' button accessibilityLabel i18n * fix(toolbar) 'document' button accessibilityLabel i18n * fix(toolbar) 'speakerStats' button accessibilityLabel i18n * fix(toolbar) 'feedback' button accessibilityLabel i18n * fix(toolbar) 'shortcuts' button accessibilityLabel i18n * fix(toolbar) 'recording' button accessibilityLabel i18n * fix(toolbar) 'settings' button accessibilityLabel i18n * fix(welcomepage) accessibilityLabels i18n * fix(toolbar) 'info' button accessibilityLabel i18n * fix(i18n): Add translation to various aria-label property values. * fix(i18n): Differentiate between overflow menu and button.
2018-06-07 20:32:18 +00:00
aria-label =
{ this.props.t('toolbar.accessibilityLabel.callQuality') }
className = 'overflow-menu-item'
onClick = { this.props.onClick }>
<span className = 'overflow-menu-item-icon'>
2019-08-30 16:39:06 +00:00
<Icon src = { icon } />
</span>
<span className = 'profile-text'>
{ this.props.t('toolbar.callQuality') }
</span>
</li>
);
}
}
/**
* Maps (parts of) the Redux state to the associated props for the
* {@code OverflowMenuVideoQualityItem} component.
*
* @param {Object} state - The Redux state.
* @private
* @returns {{
* _audioOnly: boolean,
* _videoQuality: number
* }}
*/
function _mapStateToProps(state) {
return {
_audioOnly: state['features/base/audio-only'].enabled,
_videoQuality: state['features/video-quality'].preferredVideoQuality
};
}
export default translate(
connect(_mapStateToProps)(OverflowMenuVideoQualityItem));