Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(toolbox): create SettingsButton
Saúl Ibarra Corretgéc7d72ee3f607
diff --git a/react/features/toolbox/components/Toolbox.web.js b/react/features/toolbox/components/Toolbox.web.jsindex cefcdd95f4..45f6a5a025 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<Props, State> {= 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<Props, State> {}}- /**- * 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<Props, State> {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<Props, State> {text = { _editingDocument? t('toolbar.documentClose'): t('toolbar.documentOpen') } />,- this._shouldShowButton('settings')- && <OverflowMenuItem- accessibilityLabel = 'Settings'- icon = 'icon-settings'- key = 'settings'- onClick = { this._onToolbarToggleSettings }- text = { t('toolbar.Settings') } />,+ <SettingsButton+ key = 'settings'+ showLabel = { true }+ visible = { this._shouldShowButton('settings') } />,this._shouldShowButton('stats')&& <OverflowMenuItemaccessibilityLabel = 'Speaker stats'diff --git a/react/features/toolbox/components/buttons/_.native.js b/react/features/toolbox/components/buttons/_.native.jsnew file mode 100644index 0000000000..738c4d2b8a--- /dev/null+++ b/react/features/toolbox/components/buttons/_.native.js@@ -0,0 +1 @@+export * from './native';diff --git a/react/features/toolbox/components/buttons/_.web.js b/react/features/toolbox/components/buttons/_.web.jsnew file mode 100644index 0000000000..b80c83af34--- /dev/null+++ b/react/features/toolbox/components/buttons/_.web.js@@ -0,0 +1 @@+export * from './web';diff --git a/react/features/toolbox/components/buttons/index.js b/react/features/toolbox/components/buttons/index.jsindex fb4d9d3274..5b22811567 100644--- a/react/features/toolbox/components/buttons/index.js+++ b/react/features/toolbox/components/buttons/index.js@@ -1,3 +1,5 @@+export * from './_';+export { default as AudioMuteButton } from './AudioMuteButton';export { default as HangupButton } from './HangupButton';export { default as VideoMuteButton } from './VideoMuteButton';diff --git a/react/features/toolbox/components/buttons/native/index.js b/react/features/toolbox/components/buttons/native/index.jsnew file mode 100644index 0000000000..e69de29bb2diff --git a/react/features/toolbox/components/buttons/web/SettingsButton.js b/react/features/toolbox/components/buttons/web/SettingsButton.jsnew file mode 100644index 0000000000..575deefd17--- /dev/null+++ b/react/features/toolbox/components/buttons/web/SettingsButton.js@@ -0,0 +1,92 @@+// @flow++import { connect } from 'react-redux';++import { createToolbarEvent, sendAnalytics } from '../../../../analytics';+import { translate } from '../../../../base/i18n';+import { openDeviceSelectionDialog } from '../../../../device-selection';+import { toggleSettings } from '../../../../side-panel';++import AbstractButton from '../AbstractButton';+import type { Props as AbstractButtonProps } from '../AbstractButton';++declare var interfaceConfig: Object;++type Props = AbstractButtonProps & {++ /**+ * Whether we are in filmstrip only mode or not.+ */+ _filmStripOnly: boolean,++ /**+ * Array containing the enabled settings sections.+ */+ _sections: Array<string>,++ /**+ * The redux {@code dispatch} function.+ */+ dispatch: Function+}++/**+ * An abstract implementation of a button for accessing settings.+ */+class SettingsButton extends AbstractButton<Props, *> {+ 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.jsnew file mode 100644index 0000000000..8bdfbf413e--- /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.jsindex 2ff7d4dd6a..78083dfb44 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';