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.web.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. // @flow
  2. import React from 'react';
  3. import { sendAnalyticsEvent } from '../analytics';
  4. import { ParticipantCounter } from '../contact-list';
  5. import { openDeviceSelectionDialog } from '../device-selection';
  6. import { InfoDialogButton, openInviteDialog } from '../invite';
  7. import UIEvents from '../../../service/UI/UIEvents';
  8. import { VideoQualityButton } from '../video-quality';
  9. import ProfileButton from './components/ProfileButton';
  10. declare var APP: Object;
  11. declare var interfaceConfig: 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. sendAnalyticsEvent('toolbar.video.enabled');
  38. } else {
  39. sendAnalyticsEvent('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. sendAnalyticsEvent('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. sendAnalyticsEvent('toolbar.chat.toggled');
  74. APP.UI.emitEvent(UIEvents.TOGGLE_CHAT);
  75. },
  76. shortcut: 'C',
  77. shortcutAttr: 'toggleChatPopover',
  78. shortcutFunc() {
  79. sendAnalyticsEvent('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. sendAnalyticsEvent(
  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. sendAnalyticsEvent('toolbar.screen.disabled');
  112. } else {
  113. sendAnalyticsEvent('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. sendAnalyticsEvent('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. sendAnalyticsEvent(
  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. sendAnalyticsEvent('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. sendAnalyticsEvent('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. sendAnalyticsEvent('toolbar.fullscreen.enabled');
  189. APP.UI.emitEvent(UIEvents.TOGGLE_FULLSCREEN);
  190. },
  191. shortcut: 'S',
  192. shortcutAttr: 'toggleFullscreenPopover',
  193. shortcutDescription: 'keyboardShortcuts.fullScreen',
  194. shortcutFunc() {
  195. sendAnalyticsEvent('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. sendAnalyticsEvent('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. sendAnalyticsEvent('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. sendAnalyticsEvent('toolbar.audio.unmuted');
  257. APP.UI.emitEvent(UIEvents.AUDIO_MUTED, false, true);
  258. }
  259. } else {
  260. sendAnalyticsEvent('toolbar.audio.muted');
  261. APP.UI.emitEvent(UIEvents.AUDIO_MUTED, true, true);
  262. }
  263. },
  264. popups: [
  265. {
  266. dataAttr: 'toolbar.micMutedPopup',
  267. id: 'micMutedPopup'
  268. },
  269. {
  270. dataAttr: 'toolbar.unableToUnmutePopup',
  271. id: 'unableToUnmutePopup'
  272. },
  273. {
  274. dataAttr: 'toolbar.talkWhileMutedPopup',
  275. id: 'talkWhileMutedPopup'
  276. }
  277. ],
  278. shortcut: 'M',
  279. shortcutAttr: 'mutePopover',
  280. shortcutFunc() {
  281. sendAnalyticsEvent('shortcut.audiomute.toggled');
  282. APP.conference.toggleAudioMuted();
  283. },
  284. shortcutDescription: 'keyboardShortcuts.mute',
  285. tooltipKey: 'toolbar.mute'
  286. },
  287. /**
  288. * The descriptor of the profile toolbar button.
  289. */
  290. profile: {
  291. component: ProfileButton,
  292. sideContainerId: 'profile_container'
  293. },
  294. /**
  295. * The descriptor of the "Raise hand" toolbar button.
  296. */
  297. raisehand: {
  298. classNames: [ 'button', 'icon-raised-hand' ],
  299. enabled: true,
  300. id: 'toolbar_button_raisehand',
  301. onClick() {
  302. sendAnalyticsEvent('toolbar.raiseHand.clicked');
  303. APP.conference.maybeToggleRaisedHand();
  304. },
  305. shortcut: 'R',
  306. shortcutAttr: 'raiseHandPopover',
  307. shortcutDescription: 'keyboardShortcuts.raiseHand',
  308. shortcutFunc() {
  309. sendAnalyticsEvent('shortcut.raisehand.clicked');
  310. APP.conference.maybeToggleRaisedHand();
  311. },
  312. tooltipKey: 'toolbar.raiseHand'
  313. },
  314. /**
  315. * The descriptor of the recording toolbar button. Requires additional
  316. * initialization in the recording module.
  317. */
  318. recording: {
  319. classNames: [ 'button' ],
  320. enabled: true,
  321. // will be displayed once the recording functionality is detected
  322. hidden: true,
  323. id: 'toolbar_button_record',
  324. tooltipKey: 'liveStreaming.buttonTooltip'
  325. },
  326. /**
  327. * The descriptor of the settings toolbar button.
  328. */
  329. settings: {
  330. classNames: [ 'button', 'icon-settings' ],
  331. enabled: true,
  332. id: 'toolbar_button_settings',
  333. onClick() {
  334. sendAnalyticsEvent('toolbar.settings.toggled');
  335. APP.UI.emitEvent(UIEvents.TOGGLE_SETTINGS);
  336. },
  337. sideContainerId: 'settings_container',
  338. tooltipKey: 'toolbar.Settings'
  339. },
  340. /**
  341. * The descriptor of the "Share YouTube video" toolbar button.
  342. */
  343. sharedvideo: {
  344. classNames: [ 'button', 'icon-shared-video' ],
  345. enabled: true,
  346. id: 'toolbar_button_sharedvideo',
  347. onClick() {
  348. sendAnalyticsEvent('toolbar.sharedvideo.clicked');
  349. APP.UI.emitEvent(UIEvents.SHARED_VIDEO_CLICKED);
  350. },
  351. popups: [
  352. {
  353. dataAttr: 'toolbar.sharedVideoMutedPopup',
  354. id: 'sharedVideoMutedPopup'
  355. }
  356. ],
  357. tooltipKey: 'toolbar.sharedvideo'
  358. },
  359. videoquality: {
  360. component: VideoQualityButton
  361. }
  362. };
  363. Object.keys(defaultButtons).forEach(name => {
  364. const button = defaultButtons[name];
  365. if (!button.isDisplayed) {
  366. button.isDisplayed = _isDisplayed;
  367. }
  368. });
  369. return defaultButtons;
  370. }
  371. /**
  372. * The default implementation of the {@code isDisplayed} method of the toolbar
  373. * button definition returned by {@link getDefaultButtons()}.
  374. *
  375. * @returns {boolean} If the user intarface is full i.e. not filmstrip-only,
  376. * then {@code true}; otherwise, {@code false}.
  377. */
  378. function _isDisplayed() {
  379. return !interfaceConfig.filmStripOnly;
  380. }