You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

defaultToolbarButtons.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /* @flow */
  2. import React from 'react';
  3. import { DEFAULT_AVATAR_RELATIVE_PATH } from '../base/participants';
  4. import { openDeviceSelectionDialog } from '../device-selection';
  5. import { openDialOutDialog } from '../dial-out';
  6. import { openAddPeopleDialog, openInviteDialog } from '../invite';
  7. import { VideoQualityButton } from '../video-quality';
  8. import UIEvents from '../../../service/UI/UIEvents';
  9. declare var APP: Object;
  10. declare var interfaceConfig: Object;
  11. declare var JitsiMeetJS: Object;
  12. /**
  13. * All toolbar buttons' descriptors.
  14. */
  15. const buttons: Object = {
  16. addtocall: {
  17. classNames: [ 'button', 'icon-add' ],
  18. enabled: true,
  19. id: 'toolbar_button_add',
  20. isDisplayed: () => !APP.store.getState()['features/jwt'].isGuest,
  21. onClick(dispatch) {
  22. JitsiMeetJS.analytics.sendEvent('toolbar.add.clicked');
  23. dispatch(openAddPeopleDialog());
  24. },
  25. tooltipKey: 'toolbar.addPeople'
  26. },
  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. className: 'loginmenu',
  47. dataAttr: 'audioOnly.featureToggleDisabled',
  48. dataInterpolate: { feature: 'video mute' },
  49. id: 'unmuteWhileAudioOnly'
  50. }
  51. ],
  52. shortcut: 'V',
  53. shortcutAttr: 'toggleVideoPopover',
  54. shortcutFunc() {
  55. if (APP.conference.isAudioOnly()) {
  56. APP.UI.emitEvent(UIEvents.VIDEO_UNMUTING_WHILE_AUDIO_ONLY);
  57. return;
  58. }
  59. JitsiMeetJS.analytics.sendEvent('shortcut.videomute.toggled');
  60. APP.conference.toggleVideoMuted();
  61. },
  62. shortcutDescription: 'keyboardShortcuts.videoMute',
  63. tooltipKey: 'toolbar.videomute'
  64. },
  65. /**
  66. * The descriptor of the chat toolbar button.
  67. */
  68. chat: {
  69. classNames: [ 'button', 'icon-chat' ],
  70. enabled: true,
  71. html: <span className = 'badge-round'>
  72. <span id = 'unreadMessages' />
  73. </span>,
  74. id: 'toolbar_button_chat',
  75. onClick() {
  76. JitsiMeetJS.analytics.sendEvent('toolbar.chat.toggled');
  77. APP.UI.emitEvent(UIEvents.TOGGLE_CHAT);
  78. },
  79. shortcut: 'C',
  80. shortcutAttr: 'toggleChatPopover',
  81. shortcutFunc() {
  82. JitsiMeetJS.analytics.sendEvent('shortcut.chat.toggled');
  83. APP.UI.toggleChat();
  84. },
  85. shortcutDescription: 'keyboardShortcuts.toggleChat',
  86. sideContainerId: 'chat_container',
  87. tooltipKey: 'toolbar.chat'
  88. },
  89. /**
  90. * The descriptor of the contact list toolbar button.
  91. */
  92. contacts: {
  93. classNames: [ 'button', 'icon-contactList' ],
  94. enabled: true,
  95. // XXX: Hotfix to solve race condition between toolbox rendering and
  96. // contact list view that updates the number of active participants
  97. // via jQuery. There is case when contact list view updates number of
  98. // participants but toolbox has not been rendered yet. Since this issue
  99. // is reproducible only for conferences with the only participant let's
  100. // use 1 participant as a default value for this badge. Later after
  101. // reactification of contact list let's use the value of active
  102. // paricipants from Redux store.
  103. html: <span className = 'badge-round'>
  104. <span id = 'numberOfParticipants'>1</span>
  105. </span>,
  106. id: 'toolbar_contact_list',
  107. onClick() {
  108. JitsiMeetJS.analytics.sendEvent(
  109. 'toolbar.contacts.toggled');
  110. APP.UI.emitEvent(UIEvents.TOGGLE_CONTACT_LIST);
  111. },
  112. sideContainerId: 'contacts_container',
  113. tooltipKey: 'bottomtoolbar.contactlist'
  114. },
  115. /**
  116. * The descriptor of the desktop sharing toolbar button.
  117. */
  118. desktop: {
  119. classNames: [ 'button', 'icon-share-desktop' ],
  120. enabled: true,
  121. id: 'toolbar_button_desktopsharing',
  122. onClick() {
  123. if (APP.conference.isSharingScreen) {
  124. JitsiMeetJS.analytics.sendEvent('toolbar.screen.disabled');
  125. } else {
  126. JitsiMeetJS.analytics.sendEvent('toolbar.screen.enabled');
  127. }
  128. APP.UI.emitEvent(UIEvents.TOGGLE_SCREENSHARING);
  129. },
  130. popups: [
  131. {
  132. className: 'loginmenu',
  133. dataAttr: 'audioOnly.featureToggleDisabled',
  134. dataInterpolate: { feature: 'screen sharing' },
  135. id: 'screenshareWhileAudioOnly'
  136. }
  137. ],
  138. shortcut: 'D',
  139. shortcutAttr: 'toggleDesktopSharingPopover',
  140. shortcutFunc() {
  141. JitsiMeetJS.analytics.sendEvent('shortcut.screen.toggled');
  142. // eslint-disable-next-line no-empty-function
  143. APP.conference.toggleScreenSharing().catch(() => {});
  144. },
  145. shortcutDescription: 'keyboardShortcuts.toggleScreensharing',
  146. tooltipKey: 'toolbar.sharescreen'
  147. },
  148. /**
  149. * The descriptor of the dial out toolbar button.
  150. */
  151. dialout: {
  152. classNames: [ 'button', 'icon-telephone' ],
  153. enabled: true,
  154. // Will be displayed once the SIP calls functionality is detected.
  155. hidden: true,
  156. id: 'toolbar_button_dial_out',
  157. onClick(dispatch) {
  158. JitsiMeetJS.analytics.sendEvent('toolbar.sip.clicked');
  159. dispatch(openDialOutDialog());
  160. },
  161. tooltipKey: 'dialOut.dialOut'
  162. },
  163. /**
  164. * The descriptor of the device selection toolbar button.
  165. */
  166. fodeviceselection: {
  167. classNames: [ 'button', 'icon-settings' ],
  168. enabled: true,
  169. isDisplayed() {
  170. return interfaceConfig.filmStripOnly;
  171. },
  172. id: 'toolbar_button_fodeviceselection',
  173. onClick(dispatch) {
  174. JitsiMeetJS.analytics.sendEvent(
  175. 'toolbar.fodeviceselection.toggled');
  176. dispatch(openDeviceSelectionDialog());
  177. },
  178. sideContainerId: 'settings_container',
  179. tooltipKey: 'toolbar.Settings'
  180. },
  181. /**
  182. * The descriptor of the dialpad toolbar button.
  183. */
  184. dialpad: {
  185. classNames: [ 'button', 'icon-dialpad' ],
  186. enabled: true,
  187. // TODO: remove it after UI.updateDTMFSupport fix
  188. hidden: true,
  189. id: 'toolbar_button_dialpad',
  190. onClick() {
  191. JitsiMeetJS.analytics.sendEvent('toolbar.sip.dialpad.clicked');
  192. },
  193. tooltipKey: 'toolbar.dialpad'
  194. },
  195. /**
  196. * The descriptor of the etherpad toolbar button.
  197. */
  198. etherpad: {
  199. classNames: [ 'button', 'icon-share-doc' ],
  200. enabled: true,
  201. hidden: true,
  202. id: 'toolbar_button_etherpad',
  203. onClick() {
  204. JitsiMeetJS.analytics.sendEvent('toolbar.etherpad.clicked');
  205. APP.UI.emitEvent(UIEvents.ETHERPAD_CLICKED);
  206. },
  207. tooltipKey: 'toolbar.etherpad'
  208. },
  209. /**
  210. * The descriptor of the toolbar button which toggles full-screen mode.
  211. */
  212. fullscreen: {
  213. classNames: [ 'button', 'icon-full-screen' ],
  214. enabled: true,
  215. id: 'toolbar_button_fullScreen',
  216. onClick() {
  217. JitsiMeetJS.analytics.sendEvent('toolbar.fullscreen.enabled');
  218. APP.UI.emitEvent(UIEvents.TOGGLE_FULLSCREEN);
  219. },
  220. shortcut: 'S',
  221. shortcutAttr: 'toggleFullscreenPopover',
  222. shortcutDescription: 'keyboardShortcuts.fullScreen',
  223. shortcutFunc() {
  224. JitsiMeetJS.analytics.sendEvent('shortcut.fullscreen.toggled');
  225. APP.UI.toggleFullScreen();
  226. },
  227. tooltipKey: 'toolbar.fullscreen'
  228. },
  229. /**
  230. * The descriptor of the toolbar button which hangs up the call/conference.
  231. */
  232. hangup: {
  233. classNames: [ 'button', 'icon-hangup', 'button_hangup' ],
  234. enabled: true,
  235. isDisplayed: () => true,
  236. id: 'toolbar_button_hangup',
  237. onClick() {
  238. JitsiMeetJS.analytics.sendEvent('toolbar.hangup');
  239. APP.UI.emitEvent(UIEvents.HANGUP);
  240. },
  241. tooltipKey: 'toolbar.hangup'
  242. },
  243. /**
  244. * The descriptor of the toolbar button which shows the invite user dialog.
  245. */
  246. invite: {
  247. classNames: [ 'button', 'icon-link' ],
  248. enabled: true,
  249. id: 'toolbar_button_link',
  250. onClick(dispatch) {
  251. JitsiMeetJS.analytics.sendEvent('toolbar.invite.clicked');
  252. dispatch(openInviteDialog());
  253. },
  254. tooltipKey: 'toolbar.invite'
  255. },
  256. /**
  257. * The descriptor of the microphone toolbar button.
  258. */
  259. microphone: {
  260. classNames: [ 'button', 'icon-microphone' ],
  261. enabled: true,
  262. isDisplayed: () => true,
  263. id: 'toolbar_button_mute',
  264. onClick() {
  265. const sharedVideoManager = APP.UI.getSharedVideoManager();
  266. if (APP.conference.isLocalAudioMuted()) {
  267. // If there's a shared video with the volume "on" and we aren't
  268. // the video owner, we warn the user
  269. // that currently it's not possible to unmute.
  270. if (sharedVideoManager
  271. && sharedVideoManager.isSharedVideoVolumeOn()
  272. && !sharedVideoManager.isSharedVideoOwner()) {
  273. APP.UI.showCustomToolbarPopup(
  274. '#unableToUnmutePopup', true, 5000);
  275. } else {
  276. JitsiMeetJS.analytics.sendEvent('toolbar.audio.unmuted');
  277. APP.UI.emitEvent(UIEvents.AUDIO_MUTED, false, true);
  278. }
  279. } else {
  280. JitsiMeetJS.analytics.sendEvent('toolbar.audio.muted');
  281. APP.UI.emitEvent(UIEvents.AUDIO_MUTED, true, true);
  282. }
  283. },
  284. popups: [
  285. {
  286. className: 'loginmenu',
  287. dataAttr: 'toolbar.micMutedPopup',
  288. id: 'micMutedPopup'
  289. },
  290. {
  291. className: 'loginmenu',
  292. dataAttr: 'toolbar.unableToUnmutePopup',
  293. id: 'unableToUnmutePopup'
  294. },
  295. {
  296. className: 'loginmenu',
  297. dataAttr: 'toolbar.talkWhileMutedPopup',
  298. id: 'talkWhileMutedPopup'
  299. }
  300. ],
  301. shortcut: 'M',
  302. shortcutAttr: 'mutePopover',
  303. shortcutFunc() {
  304. JitsiMeetJS.analytics.sendEvent('shortcut.audiomute.toggled');
  305. APP.conference.toggleAudioMuted();
  306. },
  307. shortcutDescription: 'keyboardShortcuts.mute',
  308. tooltipKey: 'toolbar.mute'
  309. },
  310. /**
  311. * The descriptor of the profile toolbar button.
  312. */
  313. profile: {
  314. classNames: [ 'button' ],
  315. enabled: true,
  316. html: <img
  317. id = 'avatar'
  318. src = { DEFAULT_AVATAR_RELATIVE_PATH } />,
  319. id: 'toolbar_button_profile',
  320. onClick() {
  321. JitsiMeetJS.analytics.sendEvent('toolbar.profile.toggled');
  322. APP.UI.emitEvent(UIEvents.TOGGLE_PROFILE);
  323. },
  324. sideContainerId: 'profile_container',
  325. tooltipKey: 'profile.setDisplayNameLabel'
  326. },
  327. /**
  328. * The descriptor of the "Raise hand" toolbar button.
  329. */
  330. raisehand: {
  331. classNames: [ 'button', 'icon-raised-hand' ],
  332. enabled: true,
  333. id: 'toolbar_button_raisehand',
  334. onClick() {
  335. JitsiMeetJS.analytics.sendEvent('toolbar.raiseHand.clicked');
  336. APP.conference.maybeToggleRaisedHand();
  337. },
  338. shortcut: 'R',
  339. shortcutAttr: 'raiseHandPopover',
  340. shortcutDescription: 'keyboardShortcuts.raiseHand',
  341. shortcutFunc() {
  342. JitsiMeetJS.analytics.sendEvent('shortcut.raisehand.clicked');
  343. APP.conference.maybeToggleRaisedHand();
  344. },
  345. tooltipKey: 'toolbar.raiseHand'
  346. },
  347. /**
  348. * The descriptor of the recording toolbar button. Requires additional
  349. * initialization in the recording module.
  350. */
  351. recording: {
  352. classNames: [ 'button' ],
  353. enabled: true,
  354. // will be displayed once the recording functionality is detected
  355. hidden: true,
  356. id: 'toolbar_button_record',
  357. tooltipKey: 'liveStreaming.buttonTooltip'
  358. },
  359. /**
  360. * The descriptor of the settings toolbar button.
  361. */
  362. settings: {
  363. classNames: [ 'button', 'icon-settings' ],
  364. enabled: true,
  365. id: 'toolbar_button_settings',
  366. onClick() {
  367. JitsiMeetJS.analytics.sendEvent('toolbar.settings.toggled');
  368. APP.UI.emitEvent(UIEvents.TOGGLE_SETTINGS);
  369. },
  370. sideContainerId: 'settings_container',
  371. tooltipKey: 'toolbar.Settings'
  372. },
  373. /**
  374. * The descriptor of the "Share YouTube video" toolbar button.
  375. */
  376. sharedvideo: {
  377. classNames: [ 'button', 'icon-shared-video' ],
  378. enabled: true,
  379. id: 'toolbar_button_sharedvideo',
  380. onClick() {
  381. JitsiMeetJS.analytics.sendEvent('toolbar.sharedvideo.clicked');
  382. APP.UI.emitEvent(UIEvents.SHARED_VIDEO_CLICKED);
  383. },
  384. popups: [
  385. {
  386. className: 'loginmenu extendedToolbarPopup',
  387. dataAttr: 'toolbar.sharedVideoMutedPopup',
  388. dataAttrPosition: 'w',
  389. id: 'sharedVideoMutedPopup'
  390. }
  391. ],
  392. tooltipKey: 'toolbar.sharedvideo'
  393. },
  394. videoquality: {
  395. component: VideoQualityButton
  396. }
  397. };
  398. Object.keys(buttons).forEach(name => {
  399. const button = buttons[name];
  400. if (!button.isDisplayed) {
  401. button.isDisplayed = () => !interfaceConfig.filmStripOnly;
  402. }
  403. });
  404. export default buttons;