Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. import { IReduxState } from '../app/types';
  2. import { getToolbarButtons } from '../base/config/functions.web';
  3. import { hasAvailableDevices } from '../base/devices/functions';
  4. import { MEET_FEATURES } from '../base/jwt/constants';
  5. import { isJwtFeatureEnabled } from '../base/jwt/functions';
  6. import { IGUMPendingState } from '../base/media/types';
  7. import ChatButton from '../chat/components/web/ChatButton';
  8. import EmbedMeetingButton from '../embed-meeting/components/EmbedMeetingButton';
  9. import SharedDocumentButton from '../etherpad/components/SharedDocumentButton.web';
  10. import FeedbackButton from '../feedback/components/FeedbackButton.web';
  11. import InviteButton from '../invite/components/add-people-dialog/web/InviteButton';
  12. import KeyboardShortcutsButton from '../keyboard-shortcuts/components/web/KeyboardShortcutsButton';
  13. import NoiseSuppressionButton from '../noise-suppression/components/NoiseSuppressionButton';
  14. import ParticipantsPaneButton from '../participants-pane/components/web/ParticipantsPaneButton';
  15. import RaiseHandContainerButton from '../reactions/components/web/RaiseHandContainerButtons';
  16. import ReactionsMenuButton from '../reactions/components/web/ReactionsMenuButton';
  17. import LiveStreamButton from '../recording/components/LiveStream/web/LiveStreamButton';
  18. import RecordButton from '../recording/components/Recording/web/RecordButton';
  19. import ShareAudioButton from '../screen-share/components/web/ShareAudioButton';
  20. import { isScreenMediaShared } from '../screen-share/functions';
  21. import SecurityDialogButton from '../security/components/security-dialog/web/SecurityDialogButton';
  22. import SettingsButton from '../settings/components/web/SettingsButton';
  23. import SharedVideoButton from '../shared-video/components/web/SharedVideoButton';
  24. import SpeakerStatsButton from '../speaker-stats/components/web/SpeakerStatsButton';
  25. import ClosedCaptionButton from '../subtitles/components/web/ClosedCaptionButton';
  26. import TileViewButton from '../video-layout/components/TileViewButton';
  27. import VideoQualityButton from '../video-quality/components/VideoQualityButton.web';
  28. import VideoBackgroundButton from '../virtual-background/components/VideoBackgroundButton';
  29. import WhiteboardButton from '../whiteboard/components/web/WhiteboardButton';
  30. import { isWhiteboardVisible } from '../whiteboard/functions';
  31. import DownloadButton from './components/DownloadButton';
  32. import HelpButton from './components/HelpButton';
  33. import AudioSettingsButton from './components/web/AudioSettingsButton';
  34. import CustomOptionButton from './components/web/CustomOptionButton';
  35. import FullscreenButton from './components/web/FullscreenButton';
  36. import LinkToSalesforceButton from './components/web/LinkToSalesforceButton';
  37. import ProfileButton from './components/web/ProfileButton';
  38. import ShareDesktopButton from './components/web/ShareDesktopButton';
  39. import ToggleCameraButton from './components/web/ToggleCameraButton';
  40. import VideoSettingsButton from './components/web/VideoSettingsButton';
  41. import { TOOLBAR_TIMEOUT } from './constants';
  42. import { IToolboxButton } from './types';
  43. export * from './functions.any';
  44. /**
  45. * Helper for getting the height of the toolbox.
  46. *
  47. * @returns {number} The height of the toolbox.
  48. */
  49. export function getToolboxHeight() {
  50. const toolbox = document.getElementById('new-toolbox');
  51. return toolbox?.clientHeight || 0;
  52. }
  53. /**
  54. * Indicates if a toolbar button is enabled.
  55. *
  56. * @param {string} name - The name of the setting section as defined in
  57. * interface_config.js.
  58. * @param {IReduxState} state - The redux state.
  59. * @returns {boolean|undefined} - True to indicate that the given toolbar button
  60. * is enabled, false - otherwise.
  61. */
  62. export function isButtonEnabled(name: string, state: IReduxState) {
  63. const toolbarButtons = getToolbarButtons(state);
  64. return toolbarButtons.indexOf(name) !== -1;
  65. }
  66. /**
  67. * Indicates if the toolbox is visible or not.
  68. *
  69. * @param {IReduxState} state - The state from the Redux store.
  70. * @returns {boolean} - True to indicate that the toolbox is visible, false -
  71. * otherwise.
  72. */
  73. export function isToolboxVisible(state: IReduxState) {
  74. const { iAmRecorder, iAmSipGateway, toolbarConfig } = state['features/base/config'];
  75. const { alwaysVisible } = toolbarConfig || {};
  76. const {
  77. timeoutID,
  78. visible
  79. } = state['features/toolbox'];
  80. const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
  81. const whiteboardVisible = isWhiteboardVisible(state);
  82. return Boolean(!iAmRecorder && !iAmSipGateway
  83. && (
  84. timeoutID
  85. || visible
  86. || alwaysVisible
  87. || audioSettingsVisible
  88. || videoSettingsVisible
  89. || whiteboardVisible
  90. ));
  91. }
  92. /**
  93. * Indicates if the audio settings button is disabled or not.
  94. *
  95. * @param {IReduxState} state - The state from the Redux store.
  96. * @returns {boolean}
  97. */
  98. export function isAudioSettingsButtonDisabled(state: IReduxState) {
  99. return !(hasAvailableDevices(state, 'audioInput')
  100. || hasAvailableDevices(state, 'audioOutput'))
  101. || state['features/base/config'].startSilent;
  102. }
  103. /**
  104. * Indicates if the desktop share button is disabled or not.
  105. *
  106. * @param {IReduxState} state - The state from the Redux store.
  107. * @returns {boolean}
  108. */
  109. export function isDesktopShareButtonDisabled(state: IReduxState) {
  110. const { muted, unmuteBlocked } = state['features/base/media'].video;
  111. const videoOrShareInProgress = !muted || isScreenMediaShared(state);
  112. const enabledInJwt = isJwtFeatureEnabled(state, MEET_FEATURES.SCREEN_SHARING, true, true);
  113. return !enabledInJwt || (unmuteBlocked && !videoOrShareInProgress);
  114. }
  115. /**
  116. * Indicates if the video settings button is disabled or not.
  117. *
  118. * @param {IReduxState} state - The state from the Redux store.
  119. * @returns {boolean}
  120. */
  121. export function isVideoSettingsButtonDisabled(state: IReduxState) {
  122. return !hasAvailableDevices(state, 'videoInput');
  123. }
  124. /**
  125. * Indicates if the video mute button is disabled or not.
  126. *
  127. * @param {IReduxState} state - The state from the Redux store.
  128. * @returns {boolean}
  129. */
  130. export function isVideoMuteButtonDisabled(state: IReduxState) {
  131. const { muted, unmuteBlocked, gumPending } = state['features/base/media'].video;
  132. return !hasAvailableDevices(state, 'videoInput')
  133. || (unmuteBlocked && Boolean(muted))
  134. || gumPending !== IGUMPendingState.NONE;
  135. }
  136. /**
  137. * If an overflow drawer should be displayed or not.
  138. * This is usually done for mobile devices or on narrow screens.
  139. *
  140. * @param {IReduxState} state - The state from the Redux store.
  141. * @returns {boolean}
  142. */
  143. export function showOverflowDrawer(state: IReduxState) {
  144. return state['features/toolbox'].overflowDrawer;
  145. }
  146. /**
  147. * Returns true if the overflow menu button is displayed and false otherwise.
  148. *
  149. * @param {IReduxState} state - The state from the Redux store.
  150. * @returns {boolean} - True if the overflow menu button is displayed and false otherwise.
  151. */
  152. export function showOverflowMenu(state: IReduxState) {
  153. return state['features/toolbox'].overflowMenuVisible;
  154. }
  155. /**
  156. * Indicates whether the toolbox is enabled or not.
  157. *
  158. * @param {IReduxState} state - The state from the Redux store.
  159. * @returns {boolean}
  160. */
  161. export function isToolboxEnabled(state: IReduxState) {
  162. return state['features/toolbox'].enabled;
  163. }
  164. /**
  165. * Returns the toolbar timeout from config or the default value.
  166. *
  167. * @param {IReduxState} state - The state from the Redux store.
  168. * @returns {number} - Toolbar timeout in milliseconds.
  169. */
  170. export function getToolbarTimeout(state: IReduxState) {
  171. const { toolbarConfig } = state['features/base/config'];
  172. return toolbarConfig?.timeout || TOOLBAR_TIMEOUT;
  173. }
  174. /**
  175. * Returns all buttons that could be rendered.
  176. *
  177. * @param {Object} _customToolbarButtons - An array containing custom buttons objects.
  178. * @returns {Object} The button maps mainMenuButtons and overflowMenuButtons.
  179. */
  180. export function getAllToolboxButtons(_customToolbarButtons?: {
  181. backgroundColor?: string;
  182. icon: string;
  183. id: string;
  184. text: string;
  185. }[]): { [key: string]: IToolboxButton; } {
  186. const microphone = {
  187. key: 'microphone',
  188. Content: AudioSettingsButton,
  189. group: 0
  190. };
  191. const camera = {
  192. key: 'camera',
  193. Content: VideoSettingsButton,
  194. group: 0
  195. };
  196. const profile = {
  197. key: 'profile',
  198. Content: ProfileButton,
  199. group: 1
  200. };
  201. const chat = {
  202. key: 'chat',
  203. Content: ChatButton,
  204. group: 2
  205. };
  206. const desktop = {
  207. key: 'desktop',
  208. Content: ShareDesktopButton,
  209. group: 2
  210. };
  211. // In Narrow layout and mobile web we are using drawer for popups and that is why it is better to include
  212. // all forms of reactions in the overflow menu. Otherwise the toolbox will be hidden and the reactions popup
  213. // misaligned.
  214. const raisehand = {
  215. key: 'raisehand',
  216. Content: RaiseHandContainerButton,
  217. group: 2
  218. };
  219. const reactions = {
  220. key: 'reactions',
  221. Content: ReactionsMenuButton,
  222. group: 2
  223. };
  224. const participants = {
  225. key: 'participants-pane',
  226. Content: ParticipantsPaneButton,
  227. group: 2
  228. };
  229. const invite = {
  230. key: 'invite',
  231. Content: InviteButton,
  232. group: 2
  233. };
  234. const tileview = {
  235. key: 'tileview',
  236. Content: TileViewButton,
  237. group: 2
  238. };
  239. const toggleCamera = {
  240. key: 'toggle-camera',
  241. Content: ToggleCameraButton,
  242. group: 2
  243. };
  244. const videoQuality = {
  245. key: 'videoquality',
  246. Content: VideoQualityButton,
  247. group: 2
  248. };
  249. const fullscreen = {
  250. key: 'fullscreen',
  251. Content: FullscreenButton,
  252. group: 2
  253. };
  254. const security = {
  255. key: 'security',
  256. alias: 'info',
  257. Content: SecurityDialogButton,
  258. group: 2
  259. };
  260. const cc = {
  261. key: 'closedcaptions',
  262. Content: ClosedCaptionButton,
  263. group: 2
  264. };
  265. const recording = {
  266. key: 'recording',
  267. Content: RecordButton,
  268. group: 2
  269. };
  270. const livestreaming = {
  271. key: 'livestreaming',
  272. Content: LiveStreamButton,
  273. group: 2
  274. };
  275. const linkToSalesforce = {
  276. key: 'linktosalesforce',
  277. Content: LinkToSalesforceButton,
  278. group: 2
  279. };
  280. const shareVideo = {
  281. key: 'sharedvideo',
  282. Content: SharedVideoButton,
  283. group: 3
  284. };
  285. const shareAudio = {
  286. key: 'shareaudio',
  287. Content: ShareAudioButton,
  288. group: 3
  289. };
  290. const noiseSuppression = {
  291. key: 'noisesuppression',
  292. Content: NoiseSuppressionButton,
  293. group: 3
  294. };
  295. const whiteboard = {
  296. key: 'whiteboard',
  297. Content: WhiteboardButton,
  298. group: 3
  299. };
  300. const etherpad = {
  301. key: 'etherpad',
  302. Content: SharedDocumentButton,
  303. group: 3
  304. };
  305. const virtualBackground = {
  306. key: 'select-background',
  307. Content: VideoBackgroundButton,
  308. group: 3
  309. };
  310. const speakerStats = {
  311. key: 'stats',
  312. Content: SpeakerStatsButton,
  313. group: 3
  314. };
  315. const settings = {
  316. key: 'settings',
  317. Content: SettingsButton,
  318. group: 4
  319. };
  320. const shortcuts = {
  321. key: 'shortcuts',
  322. Content: KeyboardShortcutsButton,
  323. group: 4
  324. };
  325. const embed = {
  326. key: 'embedmeeting',
  327. Content: EmbedMeetingButton,
  328. group: 4
  329. };
  330. const feedback = {
  331. key: 'feedback',
  332. Content: FeedbackButton,
  333. group: 4
  334. };
  335. const download = {
  336. key: 'download',
  337. Content: DownloadButton,
  338. group: 4
  339. };
  340. const help = {
  341. key: 'help',
  342. Content: HelpButton,
  343. group: 4
  344. };
  345. const customButtons = _customToolbarButtons?.reduce((prev, { backgroundColor, icon, id, text }) => {
  346. return {
  347. ...prev,
  348. [id]: {
  349. backgroundColor,
  350. key: id,
  351. Content: CustomOptionButton,
  352. group: 4,
  353. icon,
  354. text
  355. }
  356. };
  357. }, {});
  358. return {
  359. microphone,
  360. camera,
  361. profile,
  362. desktop,
  363. chat,
  364. raisehand,
  365. reactions,
  366. participants,
  367. invite,
  368. tileview,
  369. toggleCamera,
  370. videoQuality,
  371. fullscreen,
  372. security,
  373. cc,
  374. recording,
  375. livestreaming,
  376. linkToSalesforce,
  377. shareVideo,
  378. shareAudio,
  379. noiseSuppression,
  380. whiteboard,
  381. etherpad,
  382. virtualBackground,
  383. speakerStats,
  384. settings,
  385. shortcuts,
  386. embed,
  387. feedback,
  388. download,
  389. help,
  390. ...customButtons
  391. };
  392. }