From b84e910086ae20db19d8dac7bea43d9f6f4ffe82 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Fri, 14 Jul 2017 11:25:28 +0200 Subject: [PATCH] feat: add option to disable desktop sharing config.disableDesktopSharing - when set to false will disable desktop sharing interfaceConfig.DESKTOP_SHARING_BUTTON_DISABLED_TOOLTIP - when value is assigned, will not hide the desktop sharing button completely, but show as disabled with this value used as the tooltip text. --- conference.js | 31 +++++++++++++++++-- config.js | 5 ++- interface_config.js | 6 ++++ modules/UI/util/UIUtil.js | 17 ++++++++++ react/features/toolbox/actions.web.js | 19 +++++++++--- .../toolbox/components/ToolbarButton.web.js | 12 +++++-- react/features/toolbox/functions.web.js | 4 +++ 7 files changed, 83 insertions(+), 11 deletions(-) diff --git a/conference.js b/conference.js index d46c43dba..8b46a51d9 100644 --- a/conference.js +++ b/conference.js @@ -544,7 +544,27 @@ export default { audioMuted: false, videoMuted: false, isSharingScreen: false, + /** + * Indicates if the desktop sharing functionality has been enabled. + * It takes into consideration {@link isDesktopSharingDisabledByConfig} + * as well as the status returned by + * {@link JitsiMeetJS.isDesktopSharingEnabled()}. The latter can be false + * either if the desktop sharing is not supported by the current browser + * or if it was disabled through lib-jitsi-meet specific options (check + * config.js for listed options). + */ isDesktopSharingEnabled: false, + /** + * Set to true if the desktop sharing functionality has been + * explicitly disabled in the config. + */ + isDesktopSharingDisabledByConfig: false, + /** + * The text displayed when the desktop sharing button is disabled through + * the config. The value is set through + * {@link interfaceConfig.DESKTOP_SHARING_BUTTON_DISABLED_TOOLTIP}. + */ + desktopSharingDisabledTooltip: null, /* * Whether the local "raisedHand" flag is on. */ @@ -601,8 +621,15 @@ export default { ConnectionEvents.CONNECTION_FAILED, _connectionFailedHandler); APP.connection = connection = con; - this.isDesktopSharingEnabled = - JitsiMeetJS.isDesktopSharingEnabled(); + + // Desktop sharing related stuff: + this.isDesktopSharingDisabledByConfig + = config.disableDesktopSharing; + this.isDesktopSharingEnabled + = !this.isDesktopSharingDisabledByConfig + && JitsiMeetJS.isDesktopSharingEnabled(); + this.desktopSharingDisabledTooltip + = interfaceConfig.DESKTOP_SHARING_BUTTON_DISABLED_TOOLTIP; eventEmitter.emit( JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED, this.isDesktopSharingEnabled); diff --git a/config.js b/config.js index 9d1c41367..ff19c56de 100644 --- a/config.js +++ b/config.js @@ -26,7 +26,10 @@ var config = { // eslint-disable-line no-unused-vars clientNode: 'http://jitsi.org/jitsimeet', // The name of client node advertised in XEP-0115 'c' stanza //focusUserJid: 'focus@auth.jitsi-meet.example.com', // The real JID of focus participant - can be overridden here //defaultSipNumber: '', // Default SIP number - + /** + * Disables desktop sharing functionality. + */ + disableDesktopSharing: false, // The ID of the jidesha extension for Chrome. desktopSharingChromeExtId: null, // Whether desktop sharing should be disabled on Chrome. diff --git a/interface_config.js b/interface_config.js index d3be670a0..4025536c5 100644 --- a/interface_config.js +++ b/interface_config.js @@ -2,6 +2,12 @@ var interfaceConfig = { // eslint-disable-line no-unused-vars // TO FIX: this needs to be handled from SASS variables. There are some // methods allowing to use variables both in css and js. DEFAULT_BACKGROUND: '#474747', + /** + * In case the desktop sharing is disabled through the config the button + * will not be hidden, but displayed as disabled with this text us as + * a tooltip. + */ + DESKTOP_SHARING_BUTTON_DISABLED_TOOLTIP: null, INITIAL_TOOLBAR_TIMEOUT: 20000, TOOLBAR_TIMEOUT: 4000, DEFAULT_REMOTE_DISPLAY_NAME: "Fellow Jitster", diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.js index 05fbcc65c..6af9f024f 100644 --- a/modules/UI/util/UIUtil.js +++ b/modules/UI/util/UIUtil.js @@ -167,6 +167,23 @@ const IndicatorFontSizes = { } }, + /** + * Sets the tooltip to the given element, but instead of using translation + * key uses text value. + * + * @param element the element to set the tooltip to + * @param text the tooltip text + * @param position the position of the tooltip in relation to the element + */ + setTooltipText(element, text, position) { + if (element) { + UIUtil.removeTooltip(element); + + element.setAttribute('data-tooltip', TOOLTIP_POSITIONS[position]); + element.setAttribute('content', text); + } + }, + /** * Removes the tooltip to the given element. * diff --git a/react/features/toolbox/actions.web.js b/react/features/toolbox/actions.web.js index cb754a37a..18b53b232 100644 --- a/react/features/toolbox/actions.web.js +++ b/react/features/toolbox/actions.web.js @@ -235,13 +235,22 @@ export function setProfileButtonUnclickable(unclickable: boolean): Function { export function showDesktopSharingButton(): Function { return (dispatch: Dispatch<*>) => { const buttonName = 'desktop'; + const disabledTooltipText + = APP.conference.desktopSharingDisabledTooltip; + const showTooltip + = disabledTooltipText + && APP.conference.isDesktopSharingDisabledByConfig; const visible - = APP.conference.isDesktopSharingEnabled - && UIUtil.isButtonEnabled(buttonName); + = UIUtil.isButtonEnabled(buttonName) + && (APP.conference.isDesktopSharingEnabled || showTooltip); - dispatch(setToolbarButton(buttonName, { - hidden: !visible - })); + const newState = { + enabled: APP.conference.isDesktopSharingEnabled, + hidden: !visible, + tooltipText: showTooltip ? disabledTooltipText : undefined + }; + + dispatch(setToolbarButton(buttonName, newState)); }; } diff --git a/react/features/toolbox/components/ToolbarButton.web.js b/react/features/toolbox/components/ToolbarButton.web.js index 7a3091221..6c38c884e 100644 --- a/react/features/toolbox/components/ToolbarButton.web.js +++ b/react/features/toolbox/components/ToolbarButton.web.js @@ -221,9 +221,15 @@ class ToolbarButton extends AbstractToolbarButton { if (UIUtil.isButtonEnabled(name)) { if (!button.unclickable) { - UIUtil.setTooltip(this.button, - button.tooltipKey, - tooltipPosition); + if (button.tooltipText) { + UIUtil.setTooltipText(this.button, + button.tooltipText, + tooltipPosition); + } else { + UIUtil.setTooltip(this.button, + button.tooltipKey, + tooltipPosition); + } } if (button.shortcut) { diff --git a/react/features/toolbox/functions.web.js b/react/features/toolbox/functions.web.js index 9269785b1..7128af184 100644 --- a/react/features/toolbox/functions.web.js +++ b/react/features/toolbox/functions.web.js @@ -43,6 +43,10 @@ export function getButtonAttributesByProps(props: Object = {}) result.style = { display: 'none' }; } + if (props.tooltipText) { + result.content = props.tooltipText; + } + return result; }