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.js55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js
index b1cbaf992..7d4c228f5 100644
--- a/src/lib/Menu.js
+++ b/src/lib/Menu.js
@@ -21,7 +21,6 @@ import {
21 muteFerdiShortcutKey, 21 muteFerdiShortcutKey,
22} from '../environment'; 22} from '../environment';
23import { aboutAppDetails, ferdiVersion } from '../environment-remote'; 23import { aboutAppDetails, ferdiVersion } from '../environment-remote';
24import { todosStore } from '../features/todos';
25import { todoActions } from '../features/todos/actions'; 24import { todoActions } from '../features/todos/actions';
26import { workspaceActions } from '../features/workspaces/actions'; 25import { workspaceActions } from '../features/workspaces/actions';
27import { workspaceStore } from '../features/workspaces/index'; 26import { workspaceStore } from '../features/workspaces/index';
@@ -313,7 +312,7 @@ const menuItems = defineMessages({
313}); 312});
314 313
315function getActiveService() { 314function getActiveService() {
316 return window.ferdi.stores.services.active; 315 return window['ferdi'].stores.services.active;
317} 316}
318 317
319const _titleBarTemplateFactory = (intl, locked) => [ 318const _titleBarTemplateFactory = (intl, locked) => [
@@ -375,7 +374,7 @@ const _titleBarTemplateFactory = (intl, locked) => [
375 label: intl.formatMessage(menuItems.openQuickSwitch), 374 label: intl.formatMessage(menuItems.openQuickSwitch),
376 accelerator: `${cmdOrCtrlShortcutKey()}+S`, 375 accelerator: `${cmdOrCtrlShortcutKey()}+S`,
377 click() { 376 click() {
378 window.ferdi.features.quickSwitch.state.isModalVisible = true; 377 window['ferdi'].features.quickSwitch.state.isModalVisible = true;
379 }, 378 },
380 }, 379 },
381 { 380 {
@@ -391,7 +390,7 @@ const _titleBarTemplateFactory = (intl, locked) => [
391 // Focus webview so find in page popup gets focused 390 // Focus webview so find in page popup gets focused
392 service.webview.focus(); 391 service.webview.focus();
393 392
394 window.ferdi.actions.service.sendIPCMessage({ 393 window['ferdi'].actions.service.sendIPCMessage({
395 serviceId: service.id, 394 serviceId: service.id,
396 channel: 'find-in-page', 395 channel: 'find-in-page',
397 args: {}, 396 args: {},
@@ -457,12 +456,12 @@ const _titleBarTemplateFactory = (intl, locked) => [
457 label: intl.formatMessage(menuItems.toggleDarkMode), 456 label: intl.formatMessage(menuItems.toggleDarkMode),
458 type: 'checkbox', 457 type: 'checkbox',
459 accelerator: `${cmdOrCtrlShortcutKey()}+${shiftKey()}+D`, 458 accelerator: `${cmdOrCtrlShortcutKey()}+${shiftKey()}+D`,
460 checked: window.ferdi.stores.settings.app.darkMode, 459 checked: window['ferdi'].stores.settings.app.darkMode,
461 click: () => { 460 click: () => {
462 window.ferdi.actions.settings.update({ 461 window['ferdi'].actions.settings.update({
463 type: 'app', 462 type: 'app',
464 data: { 463 data: {
465 darkMode: !window.ferdi.stores.settings.app.darkMode, 464 darkMode: !window['ferdi'].stores.settings.app.darkMode,
466 }, 465 },
467 }); 466 });
468 }, 467 },
@@ -479,12 +478,12 @@ const _titleBarTemplateFactory = (intl, locked) => [
479 label: intl.formatMessage(menuItems.workspaces), 478 label: intl.formatMessage(menuItems.workspaces),
480 accelerator: `${altKey()}+W`, 479 accelerator: `${altKey()}+W`,
481 submenu: [], 480 submenu: [],
482 visible: !locked && workspaceStore.isFeatureEnabled, 481 visible: !locked,
483 }, 482 },
484 { 483 {
485 label: intl.formatMessage(menuItems.todos), 484 label: intl.formatMessage(menuItems.todos),
486 submenu: [], 485 submenu: [],
487 visible: !locked && todosStore.isFeatureEnabled, 486 visible: !locked,
488 }, 487 },
489 { 488 {
490 label: intl.formatMessage(menuItems.window), 489 label: intl.formatMessage(menuItems.window),
@@ -579,13 +578,13 @@ class FranzMenu {
579 // need to clone object so we don't modify computed (cached) object 578 // need to clone object so we don't modify computed (cached) object
580 const serviceTpl = Object.assign([], this.serviceTpl()); 579 const serviceTpl = Object.assign([], this.serviceTpl());
581 580
582 // Don't initialize when window.ferdi is undefined 581 // Don't initialize when window['ferdi'] is undefined
583 if (window.ferdi === undefined) { 582 if (window['ferdi'] === undefined) {
584 console.log('skipping menu init'); 583 console.log('skipping menu init');
585 return; 584 return;
586 } 585 }
587 586
588 const { intl } = window.ferdi; 587 const { intl } = window['ferdi'];
589 const tpl = _titleBarTemplateFactory(intl, this.stores.settings.app.locked); 588 const tpl = _titleBarTemplateFactory(intl, this.stores.settings.app.locked);
590 const { actions } = this; 589 const { actions } = this;
591 590
@@ -593,13 +592,13 @@ class FranzMenu {
593 tpl[1].submenu.push({ 592 tpl[1].submenu.push({
594 label: intl.formatMessage(menuItems.autohideMenuBar), 593 label: intl.formatMessage(menuItems.autohideMenuBar),
595 type: 'checkbox', 594 type: 'checkbox',
596 checked: window.ferdi.stores.settings.app.autohideMenuBar, 595 checked: window['ferdi'].stores.settings.app.autohideMenuBar,
597 click: () => { 596 click: () => {
598 window.ferdi.actions.settings.update({ 597 window['ferdi'].actions.settings.update({
599 type: 'app', 598 type: 'app',
600 data: { 599 data: {
601 autohideMenuBar: 600 autohideMenuBar:
602 !window.ferdi.stores.settings.app.autohideMenuBar, 601 !window['ferdi'].stores.settings.app.autohideMenuBar,
603 }, 602 },
604 }); 603 });
605 }, 604 },
@@ -698,13 +697,9 @@ class FranzMenu {
698 tpl[2].submenu = serviceTpl; 697 tpl[2].submenu = serviceTpl;
699 } 698 }
700 699
701 if (workspaceStore.isFeatureEnabled) { 700 tpl[3].submenu = this.workspacesMenu();
702 tpl[3].submenu = this.workspacesMenu();
703 }
704 701
705 if (todosStore.isFeatureEnabled) { 702 tpl[4].submenu = this.todosMenu();
706 tpl[4].submenu = this.todosMenu();
707 }
708 } else { 703 } else {
709 const touchIdEnabled = isMac 704 const touchIdEnabled = isMac
710 ? this.stores.settings.app.useTouchIdToUnlock && 705 ? this.stores.settings.app.useTouchIdToUnlock &&
@@ -872,13 +867,9 @@ class FranzMenu {
872 tpl[3].submenu = serviceTpl; 867 tpl[3].submenu = serviceTpl;
873 } 868 }
874 869
875 if (workspaceStore.isFeatureEnabled) { 870 tpl[4].submenu = this.workspacesMenu();
876 tpl[4].submenu = this.workspacesMenu();
877 }
878 871
879 if (todosStore.isFeatureEnabled) { 872 tpl[5].submenu = this.todosMenu();
880 tpl[5].submenu = this.todosMenu();
881 }
882 873
883 tpl[tpl.length - 1].submenu.push( 874 tpl[tpl.length - 1].submenu.push(
884 { 875 {
@@ -893,7 +884,7 @@ class FranzMenu {
893 } 884 }
894 885
895 serviceTpl() { 886 serviceTpl() {
896 const { intl } = window.ferdi; 887 const { intl } = window['ferdi'];
897 const { user, services, settings } = this.stores; 888 const { user, services, settings } = this.stores;
898 if (!user.isLoggedIn) return []; 889 if (!user.isLoggedIn) return [];
899 const menu = []; 890 const menu = [];
@@ -988,7 +979,7 @@ class FranzMenu {
988 workspacesMenu() { 979 workspacesMenu() {
989 const { workspaces, activeWorkspace, isWorkspaceDrawerOpen } = 980 const { workspaces, activeWorkspace, isWorkspaceDrawerOpen } =
990 workspaceStore; 981 workspaceStore;
991 const { intl } = window.ferdi; 982 const { intl } = window['ferdi'];
992 const menu = []; 983 const menu = [];
993 984
994 // Add new workspace item: 985 // Add new workspace item:
@@ -1050,7 +1041,7 @@ class FranzMenu {
1050 1041
1051 todosMenu() { 1042 todosMenu() {
1052 const { isTodosPanelVisible, isFeatureEnabledByUser } = this.stores.todos; 1043 const { isTodosPanelVisible, isFeatureEnabledByUser } = this.stores.todos;
1053 const { intl } = window.ferdi; 1044 const { intl } = window['ferdi'];
1054 const menu = []; 1045 const menu = [];
1055 1046
1056 const drawerLabel = isTodosPanelVisible 1047 const drawerLabel = isTodosPanelVisible
@@ -1084,7 +1075,7 @@ class FranzMenu {
1084 } 1075 }
1085 1076
1086 debugMenu() { 1077 debugMenu() {
1087 const { intl } = window.ferdi; 1078 const { intl } = window['ferdi'];
1088 1079
1089 return [ 1080 return [
1090 { 1081 {
@@ -1107,7 +1098,7 @@ class FranzMenu {
1107 { 1098 {
1108 label: intl.formatMessage(menuItems.publishDebugInfo), 1099 label: intl.formatMessage(menuItems.publishDebugInfo),
1109 click: () => { 1100 click: () => {
1110 window.ferdi.features.publishDebugInfo.state.isModalVisible = true; 1101 window['ferdi'].features.publishDebugInfo.state.isModalVisible = true;
1111 }, 1102 },
1112 }, 1103 },
1113 ]; 1104 ];