Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

defaultToolbarButtons.web.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. /* @flow */
  2. import React from 'react';
  3. import _ from 'lodash';
  4. import { ParticipantCounter } from '../contact-list';
  5. import { openDeviceSelectionDialog } from '../device-selection';
  6. import {
  7. InfoDialogButton,
  8. openInviteDialog
  9. } from '../invite';
  10. import { VideoQualityButton } from '../video-quality';
  11. import UIEvents from '../../../service/UI/UIEvents';
  12. import ProfileButton from './components/ProfileButton';
  13. declare var APP: Object;
  14. declare var interfaceConfig: Object;
  15. declare var JitsiMeetJS: Object;
  16. let buttons: Object = {};
  17. /**
  18. * Returns a map of all button descriptors and according properties.
  19. *
  20. * @returns {*} - The maps of default button descriptors.
  21. */
  22. function getDefaultButtons() {
  23. if (!_.isEmpty(buttons)) {
  24. return buttons;
  25. }
  26. buttons = {
  27. /**
  28. * The descriptor of the camera toolbar button.
  29. */
  30. camera: {
  31. classNames: [ 'button', 'icon-camera' ],
  32. enabled: true,
  33. isDisplayed: () => true,
  34. id: 'toolbar_button_camera',
  35. onClick() {
  36. const newVideoMutedState = !APP.conference.isLocalVideoMuted();
  37. if (newVideoMutedState) {
  38. JitsiMeetJS.analytics.sendEvent('toolbar.video.enabled');
  39. } else {
  40. JitsiMeetJS.analytics.sendEvent('toolbar.video.disabled');
  41. }
  42. APP.UI.emitEvent(UIEvents.VIDEO_MUTED, newVideoMutedState);
  43. },
  44. popups: [
  45. {
  46. dataAttr: 'audioOnly.featureToggleDisabled',
  47. dataInterpolate: { feature: 'video mute' },
  48. id: 'unmuteWhileAudioOnly'
  49. }
  50. ],
  51. shortcut: 'V',
  52. shortcutAttr: 'toggleVideoPopover',
  53. shortcutFunc() {
  54. if (APP.conference.isAudioOnly()) {
  55. APP.UI.emitEvent(UIEvents.VIDEO_UNMUTING_WHILE_AUDIO_ONLY);
  56. return;
  57. }
  58. JitsiMeetJS.analytics.sendEvent('shortcut.videomute.toggled');
  59. APP.conference.toggleVideoMuted();
  60. },
  61. shortcutDescription: 'keyboardShortcuts.videoMute',
  62. tooltipKey: 'toolbar.videomute'
  63. },
  64. /**
  65. * The descriptor of the chat toolbar button.
  66. */
  67. chat: {
  68. classNames: [ 'button', 'icon-chat' ],
  69. enabled: true,
  70. html: <span className = 'badge-round'>
  71. <span id = 'unreadMessages' /></span>,
  72. id: 'toolbar_button_chat',
  73. onClick() {
  74. JitsiMeetJS.analytics.sendEvent('toolbar.chat.toggled');
  75. APP.UI.emitEvent(UIEvents.TOGGLE_CHAT);
  76. },
  77. shortcut: 'C',
  78. shortcutAttr: 'toggleChatPopover',
  79. shortcutFunc() {
  80. JitsiMeetJS.analytics.sendEvent('shortcut.chat.toggled');
  81. APP.UI.toggleChat();
  82. },
  83. shortcutDescription: 'keyboardShortcuts.toggleChat',
  84. sideContainerId: 'chat_container',
  85. tooltipKey: 'toolbar.chat'
  86. },
  87. /**
  88. * The descriptor of the contact list toolbar button.
  89. */
  90. contacts: {
  91. childComponent: ParticipantCounter,
  92. classNames: [ 'button', 'icon-contactList' ],
  93. enabled: true,
  94. id: 'toolbar_contact_list',
  95. onClick() {
  96. JitsiMeetJS.analytics.sendEvent(
  97. 'toolbar.contacts.toggled');
  98. APP.UI.emitEvent(UIEvents.TOGGLE_CONTACT_LIST);
  99. },
  100. sideContainerId: 'contacts_container',
  101. tooltipKey: 'bottomtoolbar.contactlist'
  102. },
  103. /**
  104. * The descriptor of the desktop sharing toolbar button.
  105. */
  106. desktop: {
  107. classNames: [ 'button', 'icon-share-desktop' ],
  108. enabled: true,
  109. id: 'toolbar_button_desktopsharing',
  110. onClick() {
  111. if (APP.conference.isSharingScreen) {
  112. JitsiMeetJS.analytics.sendEvent('toolbar.screen.disabled');
  113. } else {
  114. JitsiMeetJS.analytics.sendEvent('toolbar.screen.enabled');
  115. }
  116. APP.UI.emitEvent(UIEvents.TOGGLE_SCREENSHARING);
  117. },
  118. popups: [
  119. {
  120. dataAttr: 'audioOnly.featureToggleDisabled',
  121. dataInterpolate: { feature: 'screen sharing' },
  122. id: 'screenshareWhileAudioOnly'
  123. }
  124. ],
  125. shortcut: 'D',
  126. shortcutAttr: 'toggleDesktopSharingPopover',
  127. shortcutFunc() {
  128. JitsiMeetJS.analytics.sendEvent('shortcut.screen.toggled');
  129. // eslint-disable-next-line no-empty-function
  130. APP.conference.toggleScreenSharing().catch(() => {});
  131. },
  132. shortcutDescription: 'keyboardShortcuts.toggleScreensharing',
  133. tooltipKey: 'toolbar.sharescreen'
  134. },
  135. /**
  136. * The descriptor of the device selection toolbar button.
  137. */
  138. fodeviceselection: {
  139. classNames: [ 'button', 'icon-settings' ],
  140. enabled: true,
  141. isDisplayed() {
  142. return interfaceConfig.filmStripOnly;
  143. },
  144. id: 'toolbar_button_fodeviceselection',
  145. onClick(dispatch: Function) {
  146. JitsiMeetJS.analytics.sendEvent(
  147. 'toolbar.fodeviceselection.toggled');
  148. dispatch(openDeviceSelectionDialog());
  149. },
  150. sideContainerId: 'settings_container',
  151. tooltipKey: 'toolbar.Settings'
  152. },
  153. /**
  154. * The descriptor of the dialpad toolbar button.
  155. */
  156. dialpad: {
  157. classNames: [ 'button', 'icon-dialpad' ],
  158. enabled: true,
  159. // TODO: remove it after UI.updateDTMFSupport fix
  160. hidden: true,
  161. id: 'toolbar_button_dialpad',
  162. onClick() {
  163. JitsiMeetJS.analytics.sendEvent('toolbar.sip.dialpad.clicked');
  164. },
  165. tooltipKey: 'toolbar.dialpad'
  166. },
  167. /**
  168. * The descriptor of the etherpad toolbar button.
  169. */
  170. etherpad: {
  171. classNames: [ 'button', 'icon-share-doc' ],
  172. enabled: true,
  173. hidden: true,
  174. id: 'toolbar_button_etherpad',
  175. onClick() {
  176. JitsiMeetJS.analytics.sendEvent('toolbar.etherpad.clicked');
  177. APP.UI.emitEvent(UIEvents.ETHERPAD_CLICKED);
  178. },
  179. tooltipKey: 'toolbar.etherpad'
  180. },
  181. /**
  182. * The descriptor of the toolbar button which toggles full-screen mode.
  183. */
  184. fullscreen: {
  185. classNames: [ 'button', 'icon-full-screen' ],
  186. enabled: true,
  187. id: 'toolbar_button_fullScreen',
  188. onClick() {
  189. JitsiMeetJS.analytics.sendEvent('toolbar.fullscreen.enabled');
  190. APP.UI.emitEvent(UIEvents.TOGGLE_FULLSCREEN);
  191. },
  192. shortcut: 'S',
  193. shortcutAttr: 'toggleFullscreenPopover',
  194. shortcutDescription: 'keyboardShortcuts.fullScreen',
  195. shortcutFunc() {
  196. JitsiMeetJS.analytics.sendEvent('shortcut.fullscreen.toggled');
  197. APP.UI.toggleFullScreen();
  198. },
  199. tooltipKey: 'toolbar.fullscreen'
  200. },
  201. /**
  202. * The descriptor of the toolbar button which hangs up the
  203. * call/conference.
  204. */
  205. hangup: {
  206. classNames: [ 'button', 'icon-hangup', 'button_hangup' ],
  207. enabled: true,
  208. isDisplayed: () => true,
  209. id: 'toolbar_button_hangup',
  210. onClick() {
  211. JitsiMeetJS.analytics.sendEvent('toolbar.hangup');
  212. APP.UI.emitEvent(UIEvents.HANGUP);
  213. },
  214. tooltipKey: 'toolbar.hangup'
  215. },
  216. /**
  217. * The descriptor of the toolbar button which opens a dialog for the
  218. * conference URL and inviting others.
  219. */
  220. info: {
  221. component: InfoDialogButton
  222. },
  223. /**
  224. * The descriptor of the toolbar button which shows the invite user
  225. * dialog.
  226. */
  227. invite: {
  228. classNames: [ 'button', 'icon-link' ],
  229. enabled: true,
  230. id: 'toolbar_button_link',
  231. onClick(dispatch: Function) {
  232. JitsiMeetJS.analytics.sendEvent('toolbar.invite.clicked');
  233. dispatch(openInviteDialog());
  234. },
  235. tooltipKey: 'toolbar.invite'
  236. },
  237. /**
  238. * The descriptor of the microphone toolbar button.
  239. */
  240. microphone: {
  241. classNames: [ 'button', 'icon-microphone' ],
  242. enabled: true,
  243. isDisplayed: () => true,
  244. id: 'toolbar_button_mute',
  245. onClick() {
  246. const sharedVideoManager = APP.UI.getSharedVideoManager();
  247. if (APP.conference.isLocalAudioMuted()) {
  248. // If there's a shared video with the volume "on" and we
  249. // aren't the video owner, we warn the user
  250. // that currently it's not possible to unmute.
  251. if (sharedVideoManager
  252. && sharedVideoManager.isSharedVideoVolumeOn()
  253. && !sharedVideoManager.isSharedVideoOwner()) {
  254. APP.UI.showCustomToolbarPopup(
  255. '#unableToUnmutePopup', true, 5000);
  256. } else {
  257. JitsiMeetJS.analytics
  258. .sendEvent('toolbar.audio.unmuted');
  259. APP.UI.emitEvent(UIEvents.AUDIO_MUTED, false, true);
  260. }
  261. } else {
  262. JitsiMeetJS.analytics.sendEvent('toolbar.audio.muted');
  263. APP.UI.emitEvent(UIEvents.AUDIO_MUTED, true, true);
  264. }
  265. },
  266. popups: [
  267. {
  268. dataAttr: 'toolbar.micMutedPopup',
  269. id: 'micMutedPopup'
  270. },
  271. {
  272. dataAttr: 'toolbar.unableToUnmutePopup',
  273. id: 'unableToUnmutePopup'
  274. },
  275. {
  276. dataAttr: 'toolbar.talkWhileMutedPopup',
  277. id: 'talkWhileMutedPopup'
  278. }
  279. ],
  280. shortcut: 'M',
  281. shortcutAttr: 'mutePopover',
  282. shortcutFunc() {
  283. JitsiMeetJS.analytics.sendEvent('shortcut.audiomute.toggled');
  284. APP.conference.toggleAudioMuted();
  285. },
  286. shortcutDescription: 'keyboardShortcuts.mute',
  287. tooltipKey: 'toolbar.mute'
  288. },
  289. /**
  290. * The descriptor of the profile toolbar button.
  291. */
  292. profile: {
  293. component: ProfileButton,
  294. sideContainerId: 'profile_container'
  295. },
  296. /**
  297. * The descriptor of the "Raise hand" toolbar button.
  298. */
  299. raisehand: {
  300. classNames: [ 'button', 'icon-raised-hand' ],
  301. enabled: true,
  302. id: 'toolbar_button_raisehand',
  303. onClick() {
  304. JitsiMeetJS.analytics.sendEvent('toolbar.raiseHand.clicked');
  305. APP.conference.maybeToggleRaisedHand();
  306. },
  307. shortcut: 'R',
  308. shortcutAttr: 'raiseHandPopover',
  309. shortcutDescription: 'keyboardShortcuts.raiseHand',
  310. shortcutFunc() {
  311. JitsiMeetJS.analytics.sendEvent('shortcut.raisehand.clicked');
  312. APP.conference.maybeToggleRaisedHand();
  313. },
  314. tooltipKey: 'toolbar.raiseHand'
  315. },
  316. /**
  317. * The descriptor of the recording toolbar button. Requires additional
  318. * initialization in the recording module.
  319. */
  320. recording: {
  321. classNames: [ 'button' ],
  322. enabled: true,
  323. // will be displayed once the recording functionality is detected
  324. hidden: true,
  325. id: 'toolbar_button_record',
  326. tooltipKey: 'liveStreaming.buttonTooltip'
  327. },
  328. /**
  329. * The descriptor of the settings toolbar button.
  330. */
  331. settings: {
  332. classNames: [ 'button', 'icon-settings' ],
  333. enabled: true,
  334. id: 'toolbar_button_settings',
  335. onClick() {
  336. JitsiMeetJS.analytics.sendEvent('toolbar.settings.toggled');
  337. APP.UI.emitEvent(UIEvents.TOGGLE_SETTINGS);
  338. },
  339. sideContainerId: 'settings_container',
  340. tooltipKey: 'toolbar.Settings'
  341. },
  342. /**
  343. * The descriptor of the "Share YouTube video" toolbar button.
  344. */
  345. sharedvideo: {
  346. classNames: [ 'button', 'icon-shared-video' ],
  347. enabled: true,
  348. id: 'toolbar_button_sharedvideo',
  349. onClick() {
  350. JitsiMeetJS.analytics.sendEvent('toolbar.sharedvideo.clicked');
  351. APP.UI.emitEvent(UIEvents.SHARED_VIDEO_CLICKED);
  352. },
  353. popups: [
  354. {
  355. dataAttr: 'toolbar.sharedVideoMutedPopup',
  356. id: 'sharedVideoMutedPopup'
  357. }
  358. ],
  359. tooltipKey: 'toolbar.sharedvideo'
  360. },
  361. videoquality: {
  362. component: VideoQualityButton
  363. }
  364. };
  365. Object.keys(buttons).forEach(name => {
  366. const button = buttons[name];
  367. if (!button.isDisplayed) {
  368. button.isDisplayed = () => !interfaceConfig.filmStripOnly;
  369. }
  370. });
  371. return buttons;
  372. }
  373. export default getDefaultButtons;