ref(isButtonEnable): UIUtil -> toolbox

This commit is contained in:
hristoterezov 2017-07-26 15:52:41 -05:00 committed by virtuacoplenny
parent 025f7204d5
commit fe59084979
6 changed files with 38 additions and 39 deletions

View File

@ -64,7 +64,10 @@ import {
mediaPermissionPromptVisibilityChanged, mediaPermissionPromptVisibilityChanged,
suspendDetected suspendDetected
} from './react/features/overlay'; } from './react/features/overlay';
import { showDesktopSharingButton } from './react/features/toolbox'; import {
isButtonEnabled,
showDesktopSharingButton
} from './react/features/toolbox';
const { participantConnectionStatus } = JitsiMeetJS.constants; const { participantConnectionStatus } = JitsiMeetJS.constants;
@ -714,7 +717,7 @@ export default {
this._createRoom(tracks); this._createRoom(tracks);
APP.remoteControl.init(); APP.remoteControl.init();
if (UIUtil.isButtonEnabled('contacts') if (isButtonEnabled('contacts')
&& !interfaceConfig.filmStripOnly) { && !interfaceConfig.filmStripOnly) {
APP.UI.ContactList = new ContactList(room); APP.UI.ContactList = new ContactList(room);
} }

View File

@ -2,27 +2,27 @@ import Chat from './chat/Chat';
import SettingsMenu from './settings/SettingsMenu'; import SettingsMenu from './settings/SettingsMenu';
import Profile from './profile/Profile'; import Profile from './profile/Profile';
import ContactListView from './contactlist/ContactListView'; import ContactListView from './contactlist/ContactListView';
import UIUtil from '../util/UIUtil'; import { isButtonEnabled } from '../../../react/features/toolbox';
const SidePanels = { const SidePanels = {
init (eventEmitter) { init (eventEmitter) {
// Initialize chat // Initialize chat
if (UIUtil.isButtonEnabled('chat')) { if (isButtonEnabled('chat')) {
Chat.init(eventEmitter); Chat.init(eventEmitter);
} }
// Initialize settings // Initialize settings
if (UIUtil.isButtonEnabled('settings')) { if (isButtonEnabled('settings')) {
SettingsMenu.init(eventEmitter); SettingsMenu.init(eventEmitter);
} }
// Initialize profile // Initialize profile
if (UIUtil.isButtonEnabled('profile')) { if (isButtonEnabled('profile')) {
Profile.init(eventEmitter); Profile.init(eventEmitter);
} }
// Initialize contact list view // Initialize contact list view
if (UIUtil.isButtonEnabled('contacts')) { if (isButtonEnabled('contacts')) {
ContactListView.init(); ContactListView.init();
} }
} }

View File

@ -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. * 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) { redirect(url) {
window.location.href = url; window.location.href = url;
}, },

View File

@ -18,7 +18,10 @@ import {
toggleToolbarButton toggleToolbarButton
} from './actions.native'; } from './actions.native';
import { SET_DEFAULT_TOOLBOX_BUTTONS } from './actionTypes'; import { SET_DEFAULT_TOOLBOX_BUTTONS } from './actionTypes';
import { getDefaultToolboxButtons } from './functions'; import {
getDefaultToolboxButtons,
isButtonEnabled
} from './functions';
declare var $: Function; declare var $: Function;
declare var APP: Object; declare var APP: Object;
@ -37,7 +40,7 @@ export function checkAutoEnableDesktopSharing(): Function {
return () => { return () => {
// XXX Should use dispatcher to toggle screensharing but screensharing // XXX Should use dispatcher to toggle screensharing but screensharing
// hasn't been React-ified yet. // hasn't been React-ified yet.
if (UIUtil.isButtonEnabled('desktop') if (isButtonEnabled('desktop')
&& config.autoEnableDesktopSharing) { && config.autoEnableDesktopSharing) {
APP.UI.eventEmitter.emit(UIEvents.TOGGLE_SCREENSHARING); APP.UI.eventEmitter.emit(UIEvents.TOGGLE_SCREENSHARING);
} }
@ -241,7 +244,7 @@ export function showDesktopSharingButton(): Function {
= disabledTooltipText = disabledTooltipText
&& APP.conference.isDesktopSharingDisabledByConfig; && APP.conference.isDesktopSharingDisabledByConfig;
const visible const visible
= UIUtil.isButtonEnabled(buttonName) = isButtonEnabled(buttonName)
&& (APP.conference.isDesktopSharingEnabled || showTooltip); && (APP.conference.isDesktopSharingEnabled || showTooltip);
const newState = { const newState = {
@ -264,7 +267,7 @@ export function showDialPadButton(show: boolean): Function {
return (dispatch: Dispatch<*>) => { return (dispatch: Dispatch<*>) => {
const buttonName = 'dialpad'; const buttonName = 'dialpad';
if (show && UIUtil.isButtonEnabled(buttonName)) { if (show && isButtonEnabled(buttonName)) {
dispatch(setToolbarButton(buttonName, { dispatch(setToolbarButton(buttonName, {
hidden: false hidden: false
})); }));
@ -296,7 +299,7 @@ export function showSharedVideoButton(): Function {
return (dispatch: Dispatch<*>) => { return (dispatch: Dispatch<*>) => {
const buttonName = 'sharedvideo'; const buttonName = 'sharedvideo';
if (UIUtil.isButtonEnabled(buttonName) if (isButtonEnabled(buttonName)
&& !config.disableThirdPartyRequests) { && !config.disableThirdPartyRequests) {
dispatch(setToolbarButton(buttonName, { dispatch(setToolbarButton(buttonName, {
hidden: false hidden: false
@ -318,7 +321,7 @@ export function showDialOutButton(show: boolean): Function {
if (show if (show
&& APP.conference.sipGatewayEnabled() && APP.conference.sipGatewayEnabled()
&& UIUtil.isButtonEnabled(buttonName) && isButtonEnabled(buttonName)
&& (!config.enableUserRolesBasedOnToken && (!config.enableUserRolesBasedOnToken
|| !getState()['features/jwt'].isGuest)) { || !getState()['features/jwt'].isGuest)) {
dispatch(setToolbarButton(buttonName, { dispatch(setToolbarButton(buttonName, {
@ -372,10 +375,9 @@ export function toggleSideToolbarContainer(containerId: string): Function {
const { secondaryToolbarButtons } = getState()['features/toolbox']; const { secondaryToolbarButtons } = getState()['features/toolbox'];
for (const key of secondaryToolbarButtons.keys()) { for (const key of secondaryToolbarButtons.keys()) {
const isButtonEnabled = UIUtil.isButtonEnabled(key);
const button = secondaryToolbarButtons.get(key); const button = secondaryToolbarButtons.get(key);
if (isButtonEnabled if (isButtonEnabled(key)
&& button.sideContainerId && button.sideContainerId
&& button.sideContainerId === containerId) { && button.sideContainerId === containerId) {
dispatch(toggleToolbarButton(key)); dispatch(toggleToolbarButton(key));

View File

@ -7,10 +7,12 @@ import { translate } from '../../base/i18n';
import UIUtil from '../../../../modules/UI/util/UIUtil'; import UIUtil from '../../../../modules/UI/util/UIUtil';
import AbstractToolbarButton from './AbstractToolbarButton'; import AbstractToolbarButton from './AbstractToolbarButton';
import { getButtonAttributesByProps } from '../functions'; import {
getButtonAttributesByProps,
isButtonEnabled
} from '../functions';
declare var APP: Object; declare var APP: Object;
declare var interfaceConfig: Object;
/** /**
* Represents a button in Toolbar on React. * Represents a button in Toolbar on React.
@ -208,7 +210,7 @@ class ToolbarButton extends AbstractToolbarButton {
const { button, tooltipPosition } = this.props; const { button, tooltipPosition } = this.props;
const name = button.buttonName; const name = button.buttonName;
if (UIUtil.isButtonEnabled(name)) { if (isButtonEnabled(name)) {
if (!button.unclickable) { if (!button.unclickable) {
if (button.tooltipText) { if (button.tooltipText) {

View File

@ -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. * Show custom popup/tooltip for a specified button.
* *