diff options
author | 2019-03-07 16:47:32 +0100 | |
---|---|---|
committer | 2019-03-07 16:47:32 +0100 | |
commit | a73e6bd9814d49eeb1cc7ff350cb5e4a621fd4ad (patch) | |
tree | 904fa0385c9b68d426bddae3b88ab81c07439633 /src/lib | |
parent | Merge branch 'chore/react-intl-manager' into develop (diff) | |
download | ferdium-app-a73e6bd9814d49eeb1cc7ff350cb5e4a621fd4ad.tar.gz ferdium-app-a73e6bd9814d49eeb1cc7ff350cb5e4a621fd4ad.tar.zst ferdium-app-a73e6bd9814d49eeb1cc7ff350cb5e4a621fd4ad.zip |
fix(Service) shortcuts for activating prev/next service fixes #1298
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Menu.js | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index dce8ab969..7bdbd9159 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -179,6 +179,14 @@ const menuItems = defineMessages({ | |||
179 | id: 'menu.services.addNewService', | 179 | id: 'menu.services.addNewService', |
180 | defaultMessage: '!!!Add New Service...', | 180 | defaultMessage: '!!!Add New Service...', |
181 | }, | 181 | }, |
182 | activateNextService: { | ||
183 | id: 'menu.services.setNextServiceActive', | ||
184 | defaultMessage: '!!!Activate next service...', | ||
185 | }, | ||
186 | activatePreviousService: { | ||
187 | id: 'menu.services.activatePreviousService', | ||
188 | defaultMessage: '!!!Activate previous service...', | ||
189 | }, | ||
182 | }); | 190 | }); |
183 | 191 | ||
184 | function getActiveWebview() { | 192 | function getActiveWebview() { |
@@ -525,7 +533,7 @@ export default class FranzMenu { | |||
525 | return; | 533 | return; |
526 | } | 534 | } |
527 | 535 | ||
528 | const intl = window.franz.intl; | 536 | const { intl } = window.franz; |
529 | const tpl = isMac ? _templateFactory(intl) : _titleBarTemplateFactory(intl); | 537 | const tpl = isMac ? _templateFactory(intl) : _titleBarTemplateFactory(intl); |
530 | 538 | ||
531 | tpl[1].submenu.push({ | 539 | tpl[1].submenu.push({ |
@@ -683,17 +691,6 @@ export default class FranzMenu { | |||
683 | }, about); | 691 | }, about); |
684 | } | 692 | } |
685 | 693 | ||
686 | serviceTpl.unshift({ | ||
687 | label: intl.formatMessage(menuItems.addNewService), | ||
688 | accelerator: `${cmdKey}+N`, | ||
689 | click: () => { | ||
690 | this.actions.ui.openSettings({ path: 'recipes' }); | ||
691 | }, | ||
692 | enabled: this.stores.user.isLoggedIn, | ||
693 | }, { | ||
694 | type: 'separator', | ||
695 | }); | ||
696 | |||
697 | if (serviceTpl.length > 0) { | 694 | if (serviceTpl.length > 0) { |
698 | tpl[3].submenu = serviceTpl; | 695 | tpl[3].submenu = serviceTpl; |
699 | } | 696 | } |
@@ -704,10 +701,35 @@ export default class FranzMenu { | |||
704 | } | 701 | } |
705 | 702 | ||
706 | @computed get serviceTpl() { | 703 | @computed get serviceTpl() { |
704 | const { intl } = window.franz; | ||
707 | const services = this.stores.services.allDisplayed; | 705 | const services = this.stores.services.allDisplayed; |
706 | const menu = [{ | ||
707 | label: intl.formatMessage(menuItems.addNewService), | ||
708 | accelerator: `${cmdKey}+N`, | ||
709 | click: () => { | ||
710 | this.actions.ui.openSettings({ path: 'recipes' }); | ||
711 | }, | ||
712 | enabled: this.stores.user.isLoggedIn, | ||
713 | }, { | ||
714 | type: 'separator', | ||
715 | }, { | ||
716 | label: intl.formatMessage(menuItems.activateNextService), | ||
717 | accelerator: `${cmdKey}+alt+right`, | ||
718 | click: () => this.actions.service.setActiveNext(), | ||
719 | enabled: this.stores.user.isLoggedIn, | ||
720 | }, { | ||
721 | label: intl.formatMessage(menuItems.activatePreviousService), | ||
722 | accelerator: `${cmdKey}+alt+left`, | ||
723 | click: () => this.actions.service.setActivePrev(), | ||
724 | enabled: this.stores.user.isLoggedIn, | ||
725 | }, { | ||
726 | type: 'separator', | ||
727 | }]; | ||
728 | |||
729 | menu.push(); | ||
708 | 730 | ||
709 | if (this.stores.user.isLoggedIn) { | 731 | if (this.stores.user.isLoggedIn) { |
710 | return services.map((service, i) => ({ | 732 | services.forEach((service, i) => (menu.push({ |
711 | label: this._getServiceName(service), | 733 | label: this._getServiceName(service), |
712 | accelerator: i < 9 ? `${cmdKey}+${i + 1}` : null, | 734 | accelerator: i < 9 ? `${cmdKey}+${i + 1}` : null, |
713 | type: 'radio', | 735 | type: 'radio', |
@@ -715,10 +737,10 @@ export default class FranzMenu { | |||
715 | click: () => { | 737 | click: () => { |
716 | this.actions.service.setActive({ serviceId: service.id }); | 738 | this.actions.service.setActive({ serviceId: service.id }); |
717 | }, | 739 | }, |
718 | })); | 740 | }))); |
719 | } | 741 | } |
720 | 742 | ||
721 | return []; | 743 | return menu; |
722 | } | 744 | } |
723 | 745 | ||
724 | _getServiceName(service) { | 746 | _getServiceName(service) { |