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

defaultToolbarButtons.web.js 14KB

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