From fe5908497982d2114273aae600a3f0fbdeb1e075 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Wed, 26 Jul 2017 15:52:41 -0500 Subject: [PATCH] ref(isButtonEnable): UIUtil -> toolbox --- conference.js | 7 +++++-- modules/UI/side_pannels/SidePanels.js | 10 ++++----- modules/UI/util/UIUtil.js | 21 ------------------- react/features/toolbox/actions.web.js | 18 +++++++++------- .../toolbox/components/ToolbarButton.web.js | 8 ++++--- react/features/toolbox/functions.web.js | 13 ++++++++++++ 6 files changed, 38 insertions(+), 39 deletions(-) diff --git a/conference.js b/conference.js index 4b95f9e43..2c29778f9 100644 --- a/conference.js +++ b/conference.js @@ -64,7 +64,10 @@ import { mediaPermissionPromptVisibilityChanged, suspendDetected } from './react/features/overlay'; -import { showDesktopSharingButton } from './react/features/toolbox'; +import { + isButtonEnabled, + showDesktopSharingButton +} from './react/features/toolbox'; const { participantConnectionStatus } = JitsiMeetJS.constants; @@ -714,7 +717,7 @@ export default { this._createRoom(tracks); APP.remoteControl.init(); - if (UIUtil.isButtonEnabled('contacts') + if (isButtonEnabled('contacts') && !interfaceConfig.filmStripOnly) { APP.UI.ContactList = new ContactList(room); } diff --git a/modules/UI/side_pannels/SidePanels.js b/modules/UI/side_pannels/SidePanels.js index 222b33d63..316c7713f 100644 --- a/modules/UI/side_pannels/SidePanels.js +++ b/modules/UI/side_pannels/SidePanels.js @@ -2,27 +2,27 @@ import Chat from './chat/Chat'; import SettingsMenu from './settings/SettingsMenu'; import Profile from './profile/Profile'; import ContactListView from './contactlist/ContactListView'; -import UIUtil from '../util/UIUtil'; +import { isButtonEnabled } from '../../../react/features/toolbox'; const SidePanels = { init (eventEmitter) { // Initialize chat - if (UIUtil.isButtonEnabled('chat')) { + if (isButtonEnabled('chat')) { Chat.init(eventEmitter); } // Initialize settings - if (UIUtil.isButtonEnabled('settings')) { + if (isButtonEnabled('settings')) { SettingsMenu.init(eventEmitter); } // Initialize profile - if (UIUtil.isButtonEnabled('profile')) { + if (isButtonEnabled('profile')) { Profile.init(eventEmitter); } // Initialize contact list view - if (UIUtil.isButtonEnabled('contacts')) { + if (isButtonEnabled('contacts')) { ContactListView.init(); } } diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.js index 6af9f024f..4beda5e3e 100644 --- a/modules/UI/util/UIUtil.js +++ b/modules/UI/util/UIUtil.js @@ -226,17 +226,6 @@ const IndicatorFontSizes = { } }, - /** - * Indicates if a toolbar button is enabled. - * @param name the name of the setting section as defined in - * interface_config.js and Toolbar.js - * @returns {boolean} {true} to indicate that the given toolbar button - * is enabled, {false} - otherwise - */ - isButtonEnabled(name) { - return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1 - || interfaceConfig.MAIN_TOOLBAR_BUTTONS.indexOf(name) !== -1; - }, /** * Indicates if the setting section is enabled. * @@ -322,16 +311,6 @@ const IndicatorFontSizes = { } }, - hideDisabledButtons(mappings) { - var selector = Object.keys(mappings) - .map(function (buttonName) { - return UIUtil.isButtonEnabled(buttonName) - ? null : "#" + mappings[buttonName].id; }) - .filter(function (item) { return item; }) - .join(','); - $(selector).hide(); - }, - redirect(url) { window.location.href = url; }, diff --git a/react/features/toolbox/actions.web.js b/react/features/toolbox/actions.web.js index 18b53b232..6b226f0f8 100644 --- a/react/features/toolbox/actions.web.js +++ b/react/features/toolbox/actions.web.js @@ -18,7 +18,10 @@ import { toggleToolbarButton } from './actions.native'; import { SET_DEFAULT_TOOLBOX_BUTTONS } from './actionTypes'; -import { getDefaultToolboxButtons } from './functions'; +import { + getDefaultToolboxButtons, + isButtonEnabled +} from './functions'; declare var $: Function; declare var APP: Object; @@ -37,7 +40,7 @@ export function checkAutoEnableDesktopSharing(): Function { return () => { // XXX Should use dispatcher to toggle screensharing but screensharing // hasn't been React-ified yet. - if (UIUtil.isButtonEnabled('desktop') + if (isButtonEnabled('desktop') && config.autoEnableDesktopSharing) { APP.UI.eventEmitter.emit(UIEvents.TOGGLE_SCREENSHARING); } @@ -241,7 +244,7 @@ export function showDesktopSharingButton(): Function { = disabledTooltipText && APP.conference.isDesktopSharingDisabledByConfig; const visible - = UIUtil.isButtonEnabled(buttonName) + = isButtonEnabled(buttonName) && (APP.conference.isDesktopSharingEnabled || showTooltip); const newState = { @@ -264,7 +267,7 @@ export function showDialPadButton(show: boolean): Function { return (dispatch: Dispatch<*>) => { const buttonName = 'dialpad'; - if (show && UIUtil.isButtonEnabled(buttonName)) { + if (show && isButtonEnabled(buttonName)) { dispatch(setToolbarButton(buttonName, { hidden: false })); @@ -296,7 +299,7 @@ export function showSharedVideoButton(): Function { return (dispatch: Dispatch<*>) => { const buttonName = 'sharedvideo'; - if (UIUtil.isButtonEnabled(buttonName) + if (isButtonEnabled(buttonName) && !config.disableThirdPartyRequests) { dispatch(setToolbarButton(buttonName, { hidden: false @@ -318,7 +321,7 @@ export function showDialOutButton(show: boolean): Function { if (show && APP.conference.sipGatewayEnabled() - && UIUtil.isButtonEnabled(buttonName) + && isButtonEnabled(buttonName) && (!config.enableUserRolesBasedOnToken || !getState()['features/jwt'].isGuest)) { dispatch(setToolbarButton(buttonName, { @@ -372,10 +375,9 @@ export function toggleSideToolbarContainer(containerId: string): Function { const { secondaryToolbarButtons } = getState()['features/toolbox']; for (const key of secondaryToolbarButtons.keys()) { - const isButtonEnabled = UIUtil.isButtonEnabled(key); const button = secondaryToolbarButtons.get(key); - if (isButtonEnabled + if (isButtonEnabled(key) && button.sideContainerId && button.sideContainerId === containerId) { dispatch(toggleToolbarButton(key)); diff --git a/react/features/toolbox/components/ToolbarButton.web.js b/react/features/toolbox/components/ToolbarButton.web.js index a3496b364..e639c82df 100644 --- a/react/features/toolbox/components/ToolbarButton.web.js +++ b/react/features/toolbox/components/ToolbarButton.web.js @@ -7,10 +7,12 @@ import { translate } from '../../base/i18n'; import UIUtil from '../../../../modules/UI/util/UIUtil'; import AbstractToolbarButton from './AbstractToolbarButton'; -import { getButtonAttributesByProps } from '../functions'; +import { + getButtonAttributesByProps, + isButtonEnabled +} from '../functions'; declare var APP: Object; -declare var interfaceConfig: Object; /** * Represents a button in Toolbar on React. @@ -208,7 +210,7 @@ class ToolbarButton extends AbstractToolbarButton { const { button, tooltipPosition } = this.props; const name = button.buttonName; - if (UIUtil.isButtonEnabled(name)) { + if (isButtonEnabled(name)) { if (!button.unclickable) { if (button.tooltipText) { diff --git a/react/features/toolbox/functions.web.js b/react/features/toolbox/functions.web.js index 7128af184..354e8a598 100644 --- a/react/features/toolbox/functions.web.js +++ b/react/features/toolbox/functions.web.js @@ -137,6 +137,19 @@ export function getToolbarClassNames(props: Object) { }; } +/** + * Indicates if a toolbar button is enabled. + * + * @param {string} name - The name of the setting section as defined in + * interface_config.js. + * @returns {boolean} - True to indicate that the given toolbar button + * is enabled, false - otherwise. + */ +export function isButtonEnabled(name) { + return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1 + || interfaceConfig.MAIN_TOOLBAR_BUTTONS.indexOf(name) !== -1; +} + /** * Show custom popup/tooltip for a specified button. *