2017-10-03 19:24:00 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-03-10 15:39:35 +00:00
|
|
|
import { getToolbarButtons } from '../base/config';
|
2020-05-20 10:57:03 +00:00
|
|
|
import { hasAvailableDevices } from '../base/devices';
|
2020-04-16 10:47:10 +00:00
|
|
|
|
2021-02-23 11:09:22 +00:00
|
|
|
const WIDTH = {
|
2021-03-12 12:19:04 +00:00
|
|
|
FIT_9_ICONS: 520,
|
|
|
|
FIT_8_ICONS: 470,
|
|
|
|
FIT_7_ICONS: 420,
|
|
|
|
FIT_6_ICONS: 370,
|
|
|
|
FIT_5_ICONS: 320,
|
|
|
|
FIT_4_ICONS: 280
|
2021-02-23 11:09:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-03-12 12:19:04 +00:00
|
|
|
* Returns a set of button names to be displayed in the toolbox, based on the screen width and platform.
|
2021-02-23 11:09:22 +00:00
|
|
|
*
|
|
|
|
* @param {number} width - The width of the screen.
|
2021-03-12 12:19:04 +00:00
|
|
|
* @param {number} isMobile - The device is a mobile one.
|
2021-02-23 11:09:22 +00:00
|
|
|
* @returns {Set} The button set.
|
|
|
|
*/
|
2021-03-12 12:19:04 +00:00
|
|
|
export function getToolbarAdditionalButtons(width: number, isMobile: boolean): Set<string> {
|
|
|
|
let buttons = [];
|
2021-02-23 11:09:22 +00:00
|
|
|
|
2021-03-12 12:19:04 +00:00
|
|
|
switch (true) {
|
|
|
|
case width >= WIDTH.FIT_9_ICONS: {
|
|
|
|
buttons = isMobile
|
2021-04-21 13:48:05 +00:00
|
|
|
? [ 'chat', 'raisehand', 'tileview', 'participants-pane', 'overflow' ]
|
|
|
|
: [ 'desktop', 'chat', 'raisehand', 'tileview', 'participants-pane', 'overflow' ];
|
2021-03-12 12:19:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case width >= WIDTH.FIT_8_ICONS: {
|
2021-04-21 13:48:05 +00:00
|
|
|
buttons = [ 'desktop', 'chat', 'raisehand', 'participants-pane', 'overflow' ];
|
2021-03-12 12:19:04 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-02-23 11:09:22 +00:00
|
|
|
|
2021-03-12 12:19:04 +00:00
|
|
|
case width >= WIDTH.FIT_7_ICONS: {
|
2021-04-21 13:48:05 +00:00
|
|
|
buttons = [ 'desktop', 'chat', 'participants-pane', 'overflow' ];
|
2021-03-12 12:19:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case width >= WIDTH.FIT_6_ICONS: {
|
2021-04-21 13:48:05 +00:00
|
|
|
buttons = [ 'chat', 'participants-pane', 'overflow' ];
|
2021-03-12 12:19:04 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-02-23 11:09:22 +00:00
|
|
|
|
2021-03-12 12:19:04 +00:00
|
|
|
case width >= WIDTH.FIT_5_ICONS: {
|
|
|
|
buttons = [ 'chat', 'overflow' ];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case width >= WIDTH.FIT_4_ICONS: {
|
|
|
|
buttons = isMobile
|
|
|
|
? [ 'chat', 'overflow' ]
|
|
|
|
: [ 'overflow' ];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
buttons = isMobile
|
|
|
|
? [ 'chat', 'overflow' ]
|
|
|
|
: [];
|
|
|
|
}
|
2021-02-23 11:09:22 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:19:04 +00:00
|
|
|
return new Set(buttons);
|
2021-02-23 11:09:22 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
/**
|
|
|
|
* Helper for getting the height of the toolbox.
|
|
|
|
*
|
|
|
|
* @returns {number} The height of the toolbox.
|
|
|
|
*/
|
|
|
|
export function getToolboxHeight() {
|
|
|
|
const toolbox = document.getElementById('new-toolbox');
|
|
|
|
|
|
|
|
return (toolbox && toolbox.clientHeight) || 0;
|
|
|
|
}
|
|
|
|
|
2017-07-26 20:52:41 +00:00
|
|
|
/**
|
|
|
|
* Indicates if a toolbar button is enabled.
|
|
|
|
*
|
|
|
|
* @param {string} name - The name of the setting section as defined in
|
|
|
|
* interface_config.js.
|
2021-03-10 15:39:35 +00:00
|
|
|
* @param {Object} state - The redux state.
|
2020-08-04 22:25:16 +00:00
|
|
|
* @returns {boolean|undefined} - True to indicate that the given toolbar button
|
2021-03-10 15:39:35 +00:00
|
|
|
* is enabled, false - otherwise.
|
2017-07-26 20:52:41 +00:00
|
|
|
*/
|
2021-03-10 15:39:35 +00:00
|
|
|
export function isButtonEnabled(name: string, state: Object) {
|
|
|
|
const toolbarButtons = getToolbarButtons(state);
|
2020-08-04 22:25:16 +00:00
|
|
|
|
2021-03-10 15:39:35 +00:00
|
|
|
return toolbarButtons.indexOf(name) !== -1;
|
2017-07-26 20:52:41 +00:00
|
|
|
}
|
2019-03-12 17:45:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the toolbox is visible or not.
|
|
|
|
*
|
|
|
|
* @param {string} state - The state from the Redux store.
|
|
|
|
* @returns {boolean} - True to indicate that the toolbox is visible, false -
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
export function isToolboxVisible(state: Object) {
|
2020-02-25 10:49:49 +00:00
|
|
|
const { iAmSipGateway } = state['features/base/config'];
|
2019-03-12 17:45:53 +00:00
|
|
|
const {
|
|
|
|
alwaysVisible,
|
|
|
|
timeoutID,
|
|
|
|
visible
|
|
|
|
} = state['features/toolbox'];
|
2020-03-30 14:17:18 +00:00
|
|
|
const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
|
2019-03-12 17:45:53 +00:00
|
|
|
|
2021-01-12 13:24:55 +00:00
|
|
|
return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
|
2020-03-30 14:17:18 +00:00
|
|
|
|| audioSettingsVisible || videoSettingsVisible));
|
2019-03-12 17:45:53 +00:00
|
|
|
}
|
2020-04-16 10:47:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the audio settings button is disabled or not.
|
|
|
|
*
|
|
|
|
* @param {string} state - The state from the Redux store.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isAudioSettingsButtonDisabled(state: Object) {
|
2020-06-19 07:03:26 +00:00
|
|
|
return (!hasAvailableDevices(state, 'audioInput')
|
|
|
|
&& !hasAvailableDevices(state, 'audioOutput'))
|
|
|
|
|| state['features/base/config'].startSilent;
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the video settings button is disabled or not.
|
|
|
|
*
|
|
|
|
* @param {string} state - The state from the Redux store.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isVideoSettingsButtonDisabled(state: Object) {
|
2020-06-19 07:03:26 +00:00
|
|
|
return !hasAvailableDevices(state, 'videoInput');
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
2020-11-04 08:32:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the video mute button is disabled or not.
|
|
|
|
*
|
|
|
|
* @param {string} state - The state from the Redux store.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isVideoMuteButtonDisabled(state: Object) {
|
|
|
|
return !hasAvailableDevices(state, 'videoInput');
|
|
|
|
}
|