aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/Menu.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Menu.js')
-rw-r--r--src/lib/Menu.js191
1 files changed, 152 insertions, 39 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js
index cda33baef..f223283f9 100644
--- a/src/lib/Menu.js
+++ b/src/lib/Menu.js
@@ -3,12 +3,11 @@ import { observable, autorun } from 'mobx';
3import { defineMessages } from 'react-intl'; 3import { defineMessages } from 'react-intl';
4 4
5import { isMac, ctrlKey, cmdKey } from '../environment'; 5import { isMac, ctrlKey, cmdKey } from '../environment';
6import { GA_CATEGORY_WORKSPACES, workspaceStore } from '../features/workspaces/index'; 6import { workspaceStore } from '../features/workspaces/index';
7import { workspaceActions } from '../features/workspaces/actions'; 7import { workspaceActions } from '../features/workspaces/actions';
8import { gaEvent } from './analytics';
9import { announcementActions } from '../features/announcements/actions'; 8import { announcementActions } from '../features/announcements/actions';
10import { announcementsStore } from '../features/announcements'; 9import { announcementsStore } from '../features/announcements';
11import { GA_CATEGORY_TODOS, todosStore } from '../features/todos'; 10import { todosStore } from '../features/todos';
12import { todoActions } from '../features/todos/actions'; 11import { todoActions } from '../features/todos/actions';
13import { CUSTOM_WEBSITE_ID } from '../features/webControls/constants'; 12import { CUSTOM_WEBSITE_ID } from '../features/webControls/constants';
14 13
@@ -71,6 +70,18 @@ const menuItems = defineMessages({
71 id: 'menu.edit.emojiSymbols', 70 id: 'menu.edit.emojiSymbols',
72 defaultMessage: '!!!Emoji & Symbols', 71 defaultMessage: '!!!Emoji & Symbols',
73 }, 72 },
73 openQuickSwitch: {
74 id: 'menu.view.openQuickSwitch',
75 defaultMessage: '!!!Open Quick Switch',
76 },
77 back: {
78 id: 'menu.view.back',
79 defaultMessage: '!!!Back',
80 },
81 forward: {
82 id: 'menu.view.forward',
83 defaultMessage: '!!!Forward',
84 },
74 resetZoom: { 85 resetZoom: {
75 id: 'menu.view.resetZoom', 86 id: 'menu.view.resetZoom',
76 defaultMessage: '!!!Actual Size', 87 defaultMessage: '!!!Actual Size',
@@ -113,7 +124,11 @@ const menuItems = defineMessages({
113 }, 124 },
114 reloadFranz: { 125 reloadFranz: {
115 id: 'menu.view.reloadFranz', 126 id: 'menu.view.reloadFranz',
116 defaultMessage: '!!!Reload Franz', 127 defaultMessage: '!!!Reload Ferdi',
128 },
129 lockFerdi: {
130 id: 'menu.view.lockFerdi',
131 defaultMessage: '!!!Lock Ferdi',
117 }, 132 },
118 minimize: { 133 minimize: {
119 id: 'menu.window.minimize', 134 id: 'menu.window.minimize',
@@ -141,7 +156,7 @@ const menuItems = defineMessages({
141 }, 156 },
142 debugInfoCopiedHeadline: { 157 debugInfoCopiedHeadline: {
143 id: 'menu.help.debugInfoCopiedHeadline', 158 id: 'menu.help.debugInfoCopiedHeadline',
144 defaultMessage: '!!!Franz Debug Information', 159 defaultMessage: '!!!Ferdi Debug Information',
145 }, 160 },
146 debugInfoCopiedBody: { 161 debugInfoCopiedBody: {
147 id: 'menu.help.debugInfoCopiedBody', 162 id: 'menu.help.debugInfoCopiedBody',
@@ -177,7 +192,7 @@ const menuItems = defineMessages({
177 }, 192 },
178 about: { 193 about: {
179 id: 'menu.app.about', 194 id: 'menu.app.about',
180 defaultMessage: '!!!About Franz', 195 defaultMessage: '!!!About Ferdi',
181 }, 196 },
182 announcement: { 197 announcement: {
183 id: 'menu.app.announcement', 198 id: 'menu.app.announcement',
@@ -203,6 +218,10 @@ const menuItems = defineMessages({
203 id: 'menu.app.unhide', 218 id: 'menu.app.unhide',
204 defaultMessage: '!!!Unhide', 219 defaultMessage: '!!!Unhide',
205 }, 220 },
221 autohideMenuBar: {
222 id: 'menu.app.autohideMenuBar',
223 defaultMessage: '!!!Auto-hide menu bar',
224 },
206 quit: { 225 quit: {
207 id: 'menu.app.quit', 226 id: 'menu.app.quit',
208 defaultMessage: '!!!Quit', 227 defaultMessage: '!!!Quit',
@@ -270,7 +289,11 @@ const menuItems = defineMessages({
270}); 289});
271 290
272function getActiveWebview() { 291function getActiveWebview() {
273 return window.franz.stores.services.active.webview; 292 return window.ferdi.stores.services.active.webview;
293}
294
295function termsBase() {
296 return window.ferdi.stores.settings.all.app.server !== 'https://api.franzinfra.com' ? window.ferdi.stores.settings.all.app.server : 'https://meetfranz.com';
274} 297}
275 298
276const _templateFactory = intl => [ 299const _templateFactory = intl => [
@@ -329,6 +352,35 @@ const _templateFactory = intl => [
329 type: 'separator', 352 type: 'separator',
330 }, 353 },
331 { 354 {
355 label: intl.formatMessage(menuItems.openQuickSwitch),
356 accelerator: 'CmdOrCtrl+S',
357 click() {
358 window.ferdi.features.quickSwitch.state.isModalVisible = true;
359 },
360 },
361 {
362 type: 'separator',
363 },
364 {
365 label: intl.formatMessage(menuItems.back),
366 accelerator: 'CmdOrCtrl+Left',
367 click() {
368 const activeService = getActiveWebview();
369 activeService.goBack();
370 },
371 },
372 {
373 label: intl.formatMessage(menuItems.forward),
374 accelerator: 'CmdOrCtrl+Right',
375 click() {
376 const activeService = getActiveWebview();
377 activeService.goForward();
378 },
379 },
380 {
381 type: 'separator',
382 },
383 {
332 label: intl.formatMessage(menuItems.resetZoom), 384 label: intl.formatMessage(menuItems.resetZoom),
333 accelerator: 'Cmd+0', 385 accelerator: 'Cmd+0',
334 click() { 386 click() {
@@ -402,32 +454,32 @@ const _templateFactory = intl => [
402 submenu: [ 454 submenu: [
403 { 455 {
404 label: intl.formatMessage(menuItems.learnMore), 456 label: intl.formatMessage(menuItems.learnMore),
405 click() { shell.openExternal('https://meetfranz.com'); }, 457 click() { shell.openExternal('https://getferdi.com'); },
406 }, 458 },
407 { 459 {
408 label: intl.formatMessage(menuItems.announcement), 460 label: intl.formatMessage(menuItems.announcement),
409 click: () => { 461 click: () => {
410 announcementActions.show(); 462 announcementActions.show();
411 }, 463 },
412 visible: window.franz.stores.user.isLoggedIn && announcementsStore.areNewsAvailable, 464 visible: window.ferdi.stores.user.isLoggedIn && announcementsStore.areNewsAvailable,
413 }, 465 },
414 { 466 {
415 type: 'separator', 467 type: 'separator',
416 }, 468 },
417 { 469 {
418 label: intl.formatMessage(menuItems.support), 470 label: intl.formatMessage(menuItems.support),
419 click() { shell.openExternal('https://meetfranz.com/support'); }, 471 click() { shell.openExternal('https://getferdi.com/contact'); },
420 }, 472 },
421 { 473 {
422 type: 'separator', 474 type: 'separator',
423 }, 475 },
424 { 476 {
425 label: intl.formatMessage(menuItems.tos), 477 label: intl.formatMessage(menuItems.tos),
426 click() { shell.openExternal('https://meetfranz.com/terms'); }, 478 click() { shell.openExternal(`${termsBase()}/terms`); },
427 }, 479 },
428 { 480 {
429 label: intl.formatMessage(menuItems.privacy), 481 label: intl.formatMessage(menuItems.privacy),
430 click() { shell.openExternal('https://meetfranz.com/privacy'); }, 482 click() { shell.openExternal(`${termsBase()}/privacy`); },
431 }, 483 },
432 ], 484 ],
433 }, 485 },
@@ -435,7 +487,7 @@ const _templateFactory = intl => [
435 487
436const _titleBarTemplateFactory = intl => [ 488const _titleBarTemplateFactory = intl => [
437 { 489 {
438 label: intl.formatMessage(menuItems.edit), 490 label: `&${intl.formatMessage(menuItems.edit)}`,
439 submenu: [ 491 submenu: [
440 { 492 {
441 label: intl.formatMessage(menuItems.undo), 493 label: intl.formatMessage(menuItems.undo),
@@ -498,12 +550,41 @@ const _titleBarTemplateFactory = intl => [
498 ], 550 ],
499 }, 551 },
500 { 552 {
501 label: intl.formatMessage(menuItems.view), 553 label: `&${intl.formatMessage(menuItems.view)}`,
502 submenu: [ 554 submenu: [
503 { 555 {
504 type: 'separator', 556 type: 'separator',
505 }, 557 },
506 { 558 {
559 label: intl.formatMessage(menuItems.openQuickSwitch),
560 accelerator: 'CmdOrCtrl+S',
561 click() {
562 window.ferdi.features.quickSwitch.state.isModalVisible = true;
563 },
564 },
565 {
566 type: 'separator',
567 },
568 {
569 label: intl.formatMessage(menuItems.back),
570 accelerator: 'CmdOrCtrl+Left',
571 click() {
572 const activeService = getActiveWebview();
573 activeService.goBack();
574 },
575 },
576 {
577 label: intl.formatMessage(menuItems.forward),
578 accelerator: 'CmdOrCtrl+Right',
579 click() {
580 const activeService = getActiveWebview();
581 activeService.goForward();
582 },
583 },
584 {
585 type: 'separator',
586 },
587 {
507 label: intl.formatMessage(menuItems.resetZoom), 588 label: intl.formatMessage(menuItems.resetZoom),
508 accelerator: `${ctrlKey}+0`, 589 accelerator: `${ctrlKey}+0`,
509 click() { 590 click() {
@@ -544,14 +625,27 @@ const _titleBarTemplateFactory = intl => [
544 browserWindow.setFullScreen(!browserWindow.isFullScreen()); 625 browserWindow.setFullScreen(!browserWindow.isFullScreen());
545 }, 626 },
546 }, 627 },
628 {
629 label: intl.formatMessage(menuItems.autohideMenuBar),
630 type: 'checkbox',
631 checked: window.ferdi.stores.settings.app.autohideMenuBar,
632 click: () => {
633 window.ferdi.actions.settings.update({
634 type: 'app',
635 data: {
636 autohideMenuBar: !window.ferdi.stores.settings.app.autohideMenuBar,
637 },
638 });
639 },
640 },
547 ], 641 ],
548 }, 642 },
549 { 643 {
550 label: intl.formatMessage(menuItems.services), 644 label: `&${intl.formatMessage(menuItems.services)}`,
551 submenu: [], 645 submenu: [],
552 }, 646 },
553 { 647 {
554 label: intl.formatMessage(menuItems.workspaces), 648 label: `&${intl.formatMessage(menuItems.workspaces)}`,
555 submenu: [], 649 submenu: [],
556 visible: workspaceStore.isFeatureEnabled, 650 visible: workspaceStore.isFeatureEnabled,
557 }, 651 },
@@ -580,33 +674,33 @@ const _titleBarTemplateFactory = intl => [
580 ], 674 ],
581 }, 675 },
582 { 676 {
583 label: '?', 677 label: '&?',
584 submenu: [ 678 submenu: [
585 { 679 {
586 label: intl.formatMessage(menuItems.learnMore), 680 label: intl.formatMessage(menuItems.learnMore),
587 click() { shell.openExternal('https://meetfranz.com'); }, 681 click() { shell.openExternal('https://getferdi.com'); },
588 }, 682 },
589 { 683 {
590 label: intl.formatMessage(menuItems.changelog), 684 label: intl.formatMessage(menuItems.changelog),
591 click() { shell.openExternal('https://github.com/meetfranz/franz/blob/master/CHANGELOG.md'); }, 685 click() { shell.openExternal('https://github.com/getferdi/ferdi/blob/master/CHANGELOG.md'); },
592 }, 686 },
593 { 687 {
594 type: 'separator', 688 type: 'separator',
595 }, 689 },
596 { 690 {
597 label: intl.formatMessage(menuItems.support), 691 label: intl.formatMessage(menuItems.support),
598 click() { shell.openExternal('https://meetfranz.com/support'); }, 692 click() { shell.openExternal('https://getferdi.com/contact'); },
599 }, 693 },
600 { 694 {
601 type: 'separator', 695 type: 'separator',
602 }, 696 },
603 { 697 {
604 label: intl.formatMessage(menuItems.tos), 698 label: intl.formatMessage(menuItems.tos),
605 click() { shell.openExternal('https://meetfranz.com/terms'); }, 699 click() { shell.openExternal(`${termsBase()}/terms`); },
606 }, 700 },
607 { 701 {
608 label: intl.formatMessage(menuItems.privacy), 702 label: intl.formatMessage(menuItems.privacy),
609 click() { shell.openExternal('https://meetfranz.com/privacy'); }, 703 click() { shell.openExternal(`${termsBase()}/privacy`); },
610 }, 704 },
611 ], 705 ],
612 }, 706 },
@@ -636,12 +730,13 @@ export default class FranzMenu {
636 // need to clone object so we don't modify computed (cached) object 730 // need to clone object so we don't modify computed (cached) object
637 const serviceTpl = Object.assign([], this.serviceTpl()); 731 const serviceTpl = Object.assign([], this.serviceTpl());
638 732
639 if (window.franz === undefined) { 733 if (window.ferdi === undefined) {
640 return; 734 return;
641 } 735 }
642 736
643 const { intl } = window.franz; 737 const { intl } = window.ferdi;
644 const tpl = isMac ? _templateFactory(intl) : _titleBarTemplateFactory(intl); 738 const tpl = isMac ? _templateFactory(intl) : _titleBarTemplateFactory(intl);
739 const { actions } = this;
645 740
646 tpl[1].submenu.push({ 741 tpl[1].submenu.push({
647 type: 'separator', 742 type: 'separator',
@@ -693,10 +788,33 @@ export default class FranzMenu {
693 click: () => { 788 click: () => {
694 window.location.reload(); 789 window.location.reload();
695 }, 790 },
791 }, {
792 type: 'separator',
793 }, {
794 label: intl.formatMessage(menuItems.lockFerdi),
795 accelerator: 'CmdOrCtrl+Shift+L',
796 enabled: this.stores.settings.app.lockingFeatureEnabled,
797 click() {
798 // Disable lock first - otherwise the application might not update correctly
799 actions.settings.update({
800 type: 'app',
801 data: {
802 locked: false,
803 },
804 });
805 setTimeout(() => {
806 actions.settings.update({
807 type: 'app',
808 data: {
809 locked: true,
810 },
811 });
812 }, 0);
813 },
696 }); 814 });
697 815
698 tpl.unshift({ 816 tpl.unshift({
699 label: isMac ? app.getName() : intl.formatMessage(menuItems.file), 817 label: isMac ? app.getName() : `&${intl.formatMessage(menuItems.file)}`,
700 submenu: [ 818 submenu: [
701 { 819 {
702 label: intl.formatMessage(menuItems.about), 820 label: intl.formatMessage(menuItems.about),
@@ -760,9 +878,9 @@ export default class FranzMenu {
760 click: () => { 878 click: () => {
761 dialog.showMessageBox({ 879 dialog.showMessageBox({
762 type: 'info', 880 type: 'info',
763 title: 'Franz', 881 title: 'Franz Ferdinand',
764 message: 'Franz', 882 message: 'Ferdi',
765 detail: `Version: ${remote.app.getVersion()}\nRelease: ${process.versions.electron} / ${process.platform} / ${process.arch}`, 883 detail: `Version: ${remote.app.getVersion()} (${process.arch})\nElectron: ${process.versions.electron}\nNode.js: ${process.version}\nPlatform: ${process.platform}`,
766 }); 884 });
767 }, 885 },
768 }; 886 };
@@ -814,7 +932,7 @@ export default class FranzMenu {
814 }, 932 },
815 ]; 933 ];
816 934
817 tpl[5].submenu.push({ 935 tpl[tpl.length - 1].submenu.push({
818 type: 'separator', 936 type: 'separator',
819 }, about); 937 }, about);
820 } 938 }
@@ -841,7 +959,7 @@ export default class FranzMenu {
841 } 959 }
842 960
843 serviceTpl() { 961 serviceTpl() {
844 const { intl } = window.franz; 962 const { intl } = window.ferdi;
845 const { user, services, settings } = this.stores; 963 const { user, services, settings } = this.stores;
846 if (!user.isLoggedIn) return []; 964 if (!user.isLoggedIn) return [];
847 const menu = []; 965 const menu = [];
@@ -901,7 +1019,7 @@ export default class FranzMenu {
901 1019
902 workspacesMenu() { 1020 workspacesMenu() {
903 const { workspaces, activeWorkspace, isWorkspaceDrawerOpen } = workspaceStore; 1021 const { workspaces, activeWorkspace, isWorkspaceDrawerOpen } = workspaceStore;
904 const { intl } = window.franz; 1022 const { intl } = window.ferdi;
905 const menu = []; 1023 const menu = [];
906 1024
907 // Add new workspace item: 1025 // Add new workspace item:
@@ -923,7 +1041,6 @@ export default class FranzMenu {
923 accelerator: `${cmdKey}+D`, 1041 accelerator: `${cmdKey}+D`,
924 click: () => { 1042 click: () => {
925 workspaceActions.toggleWorkspaceDrawer(); 1043 workspaceActions.toggleWorkspaceDrawer();
926 gaEvent(GA_CATEGORY_WORKSPACES, 'toggleDrawer', 'menu');
927 }, 1044 },
928 enabled: this.stores.user.isLoggedIn, 1045 enabled: this.stores.user.isLoggedIn,
929 }, { 1046 }, {
@@ -938,7 +1055,6 @@ export default class FranzMenu {
938 checked: !activeWorkspace, 1055 checked: !activeWorkspace,
939 click: () => { 1056 click: () => {
940 workspaceActions.deactivate(); 1057 workspaceActions.deactivate();
941 gaEvent(GA_CATEGORY_WORKSPACES, 'switch', 'menu');
942 }, 1058 },
943 }); 1059 });
944 1060
@@ -951,7 +1067,6 @@ export default class FranzMenu {
951 checked: activeWorkspace ? workspace.id === activeWorkspace.id : false, 1067 checked: activeWorkspace ? workspace.id === activeWorkspace.id : false,
952 click: () => { 1068 click: () => {
953 workspaceActions.activate({ workspace }); 1069 workspaceActions.activate({ workspace });
954 gaEvent(GA_CATEGORY_WORKSPACES, 'switch', 'menu');
955 }, 1070 },
956 })); 1071 }));
957 } 1072 }
@@ -961,7 +1076,7 @@ export default class FranzMenu {
961 1076
962 todosMenu() { 1077 todosMenu() {
963 const { isTodosPanelVisible, isFeatureEnabledByUser } = this.stores.todos; 1078 const { isTodosPanelVisible, isFeatureEnabledByUser } = this.stores.todos;
964 const { intl } = window.franz; 1079 const { intl } = window.ferdi;
965 const menu = []; 1080 const menu = [];
966 1081
967 const drawerLabel = isTodosPanelVisible ? menuItems.closeTodosDrawer : menuItems.openTodosDrawer; 1082 const drawerLabel = isTodosPanelVisible ? menuItems.closeTodosDrawer : menuItems.openTodosDrawer;
@@ -971,7 +1086,6 @@ export default class FranzMenu {
971 accelerator: `${cmdKey}+T`, 1086 accelerator: `${cmdKey}+T`,
972 click: () => { 1087 click: () => {
973 todoActions.toggleTodosPanel(); 1088 todoActions.toggleTodosPanel();
974 gaEvent(GA_CATEGORY_TODOS, 'toggleDrawer', 'menu');
975 }, 1089 },
976 enabled: this.stores.user.isLoggedIn && isFeatureEnabledByUser, 1090 enabled: this.stores.user.isLoggedIn && isFeatureEnabledByUser,
977 }); 1091 });
@@ -983,7 +1097,6 @@ export default class FranzMenu {
983 label: intl.formatMessage(menuItems.enableTodos), 1097 label: intl.formatMessage(menuItems.enableTodos),
984 click: () => { 1098 click: () => {
985 todoActions.toggleTodosFeatureVisibility(); 1099 todoActions.toggleTodosFeatureVisibility();
986 gaEvent(GA_CATEGORY_TODOS, 'enable', 'menu');
987 }, 1100 },
988 }); 1101 });
989 } 1102 }
@@ -993,7 +1106,7 @@ export default class FranzMenu {
993 1106
994 1107
995 debugMenu() { 1108 debugMenu() {
996 const { intl } = window.franz; 1109 const { intl } = window.ferdi;
997 1110
998 return { 1111 return {
999 label: intl.formatMessage(menuItems.debugInfo), 1112 label: intl.formatMessage(menuItems.debugInfo),
@@ -1019,7 +1132,7 @@ export default class FranzMenu {
1019 return service.name; 1132 return service.name;
1020 } 1133 }
1021 1134
1022 let name = service.recipe.name; 1135 let { name } = service.recipe;
1023 1136
1024 if (service.team) { 1137 if (service.team) {
1025 name = `${name} (${service.team})`; 1138 name = `${name} (${service.team})`;