diff --git a/react/features/toolbox/components/Toolbox.web.js b/react/features/toolbox/components/Toolbox.web.js index cefcdd95f..45f6a5a02 100644 --- a/react/features/toolbox/components/Toolbox.web.js +++ b/react/features/toolbox/components/Toolbox.web.js @@ -18,7 +18,6 @@ import { } from '../../base/participants'; import { getLocalVideoTrack, toggleScreensharing } from '../../base/tracks'; import { ChatCounter } from '../../chat'; -import { openDeviceSelectionDialog } from '../../device-selection'; import { toggleDocument } from '../../etherpad'; import { openFeedbackDialog } from '../../feedback'; import { @@ -30,8 +29,7 @@ import { import { openKeyboardShortcutsDialog } from '../../keyboard-shortcuts'; import { RECORDING_TYPES, toggleRecording } from '../../recording'; import { toggleSharedVideo } from '../../shared-video'; -import { shouldShowOnlyDeviceSelection } from '../../settings'; -import { toggleChat, toggleProfile, toggleSettings } from '../../side-panel'; +import { toggleChat, toggleProfile } from '../../side-panel'; import { SpeakerStats } from '../../speaker-stats'; import { OverflowMenuVideoQualityItem, @@ -44,7 +42,12 @@ import OverflowMenuButton from './OverflowMenuButton'; import OverflowMenuItem from './OverflowMenuItem'; import OverflowMenuProfileItem from './OverflowMenuProfileItem'; import ToolbarButton from './ToolbarButton'; -import { AudioMuteButton, HangupButton, VideoMuteButton } from './buttons'; +import { + AudioMuteButton, + HangupButton, + SettingsButton, + VideoMuteButton +} from './buttons'; type Props = { @@ -227,8 +230,6 @@ class Toolbox extends Component { = this._onToolbarToggleRecording.bind(this); this._onToolbarToggleScreenshare = this._onToolbarToggleScreenshare.bind(this); - this._onToolbarToggleSettings - = this._onToolbarToggleSettings.bind(this); this._onToolbarToggleSharedVideo = this._onToolbarToggleSharedVideo.bind(this); } @@ -509,21 +510,6 @@ class Toolbox extends Component { } } - /** - * Dispatches an action to toggle display of settings, be it the settings - * panel or directly to device selection. - * - * @private - * @returns {void} - */ - _doToggleSettings() { - if (shouldShowOnlyDeviceSelection()) { - this.props.dispatch(openDeviceSelectionDialog()); - } else { - this.props.dispatch(toggleSettings()); - } - } - /** * Dispatches an action to toggle YouTube video sharing. * @@ -862,21 +848,6 @@ class Toolbox extends Component { this._doToggleScreenshare(); } - _onToolbarToggleSettings: () => void; - - /** - * Creates an analytics toolbar event and dispatches an action for toggling - * settings display. - * - * @private - * @returns {void} - */ - _onToolbarToggleSettings() { - sendAnalytics(createToolbarEvent('settings')); - - this._doToggleSettings(); - } - _onToolbarToggleSharedVideo: () => void; /** @@ -993,13 +964,10 @@ class Toolbox extends Component { text = { _editingDocument ? t('toolbar.documentClose') : t('toolbar.documentOpen') } />, - this._shouldShowButton('settings') - && , + , this._shouldShowButton('stats') && , + + /** + * The redux {@code dispatch} function. + */ + dispatch: Function +} + +/** + * An abstract implementation of a button for accessing settings. + */ +class SettingsButton extends AbstractButton { + accessibilityLabel = 'Settings'; + iconName = 'icon-settings'; + label = 'toolbar.Settings'; + tooltip = 'toolbar.Settings'; + + /** + * Handles clicking / pressing the button, and opens the appropriate dialog. + * + * @private + * @returns {void} + */ + _handleClick() { + const { _filmStripOnly, _sections, dispatch } = this.props; + + sendAnalytics(createToolbarEvent('settings')); + if (_filmStripOnly + || (_sections.length === 1 && _sections.includes('devices'))) { + dispatch(openDeviceSelectionDialog()); + } else { + dispatch(toggleSettings()); + } + } + + /** + * Indicates whether this button is disabled or not. + * + * @override + * @private + * @returns {boolean} + */ + _isDisabled() { + return false; + } +} + +/** + * Maps (parts of) the redux state to the associated props for the + * {@code SettingsButton} component. + * + * @param {Object} state - The Redux state. + * @private + * @returns {{ + * _filmStripOnly: boolean + * }} + */ +function _mapStateToProps(state): Object { // eslint-disable-line no-unused-vars + // XXX: We are not currently using state here, but in the future, when + // interfaceConfig is part of redux we will. + + return { + _filmStripOnly: Boolean(interfaceConfig.filmStripOnly), + _sections: interfaceConfig.SETTINGS_SECTIONS || [] + }; +} + +export default translate(connect(_mapStateToProps)(SettingsButton)); diff --git a/react/features/toolbox/components/buttons/web/index.js b/react/features/toolbox/components/buttons/web/index.js new file mode 100644 index 000000000..8bdfbf413 --- /dev/null +++ b/react/features/toolbox/components/buttons/web/index.js @@ -0,0 +1 @@ +export { default as SettingsButton } from './SettingsButton'; diff --git a/react/features/toolbox/components/index.js b/react/features/toolbox/components/index.js index 2ff7d4dd6..78083dfb4 100644 --- a/react/features/toolbox/components/index.js +++ b/react/features/toolbox/components/index.js @@ -1,3 +1,4 @@ export { default as ToolbarButton } from './ToolbarButton'; export { default as ToolboxFilmstrip } from './ToolboxFilmstrip'; export { default as Toolbox } from './Toolbox'; +export * from './buttons';