diff options
author | 2019-04-11 16:54:01 +0200 | |
---|---|---|
committer | 2019-04-11 16:54:01 +0200 | |
commit | 47c1c99d893517efc679ab29d675cc0bf44be8be (patch) | |
tree | 9cab9697096bef0ce56d8ee8709bc1c2c3a42deb /src/lib/Menu.js | |
parent | test package order (diff) | |
download | ferdium-app-47c1c99d893517efc679ab29d675cc0bf44be8be.tar.gz ferdium-app-47c1c99d893517efc679ab29d675cc0bf44be8be.tar.zst ferdium-app-47c1c99d893517efc679ab29d675cc0bf44be8be.zip |
feat(App): Added Workspaces for all your daily routines 🥳
* merge default and fetched feature configs
* ignore intellij project files
* basic setup for workspaces feature
* define workspaces as premium feature
* add workspaces menu item in settings dialog
* basic setup of workspaces settings screen
* fix eslint error
* assign react key prop to workspace items
* add styles for workspace table
* setup logic to display workspace edit page
* consolidate workspace feature for further development
* prepare basic workspace edit form
* add on enter key handler for form input component
* add form for creating workspaces
* small fixes
* adds flow for deleting workspaces
* stop tracking google analytics in components
* pin gulp-sass-variables version to 1.1.1
* fix merge conflict
* fix bug in form input library
* improve workspace form setup
* finish basic workspace settings
* finish workspaces mvp
* fix eslint issues
* remove dev logs
* detach service when underlying webview unmounts
* disable no-param-reassign eslint rule
* add workspace drawer
* change workspace switch shortcuts to start with zero
* add workspace drawer toggle menu item and shortcut
* improve workspace switching ux
* style add workspace icon in drawer like the sidebar icons
* improve workspace drawer layout
* add i18n messages for service loading and workspace switching
* small fixes
* add tooltip to add workspace button in drawer
* add workspaces count badge in settings navigation
* fix merge conflicts with latest develop
* refactor state management for workspace feature
* reset api requests when workspace feature is stopped
* hide workspace feature if it is disabled
* handle get workspaces request errors in the ui
* show infobox when updating workspaces
* indicate any server interaction with spinners and infoboxes
* add analytic events for workspace actions
* improve styling of workspace switch indicator
* add workspace premium notice to dashboard
* add workspace feature info in drawer for free users
* add workspace premium badge in settings nav
* fix premium workspace badge in settings menu for light theme
* fix active workspaces settings premium badge in light theme
* give upgrade account button a bit more padding
* add open last used workspace logic
* use mobx-localstorage directly in the store
* fix wrong workspace tooltip shortcut in sidebar
* fix bug in workspace feature initialization
* show workspaces intro in drawer when user has none yet
* fix issues for users that have workspace but downgraded to free
* border radius for premium intro in workspace settings
* close workspace drawer after clicking on a workspace
* add hover effect for drawer workspace items
* ensure drawer is open on workspace settings routes
* add small text label for adding new workspace to drawer
* make workspace settings list items taller
* refactor workspace table css away from legacy styles
* render workspace service list like services + toggle
* change plus icon in workspace drawer to settings icon
* autofocus create workspace input field
* add css transition to drawer workspace item hover
* fix drawer add workspace label styles
* refactors workspace theme vars into object structure
* improve contrast of workspace switching indicator
* added generic pro badge component for settings nav
* add premium badge to workspace drawer headline
* add context menu for workspace drawer items
* handle deleted services that are attached to workspaces
Diffstat (limited to 'src/lib/Menu.js')
-rw-r--r-- | src/lib/Menu.js | 94 |
1 files changed, 93 insertions, 1 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 7a60c448f..a4e41c17c 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -3,6 +3,9 @@ import { observable, autorun } from 'mobx'; | |||
3 | import { defineMessages } from 'react-intl'; | 3 | import { defineMessages } from 'react-intl'; |
4 | 4 | ||
5 | import { isMac, ctrlKey, cmdKey } from '../environment'; | 5 | import { isMac, ctrlKey, cmdKey } from '../environment'; |
6 | import { GA_CATEGORY_WORKSPACES, workspaceStore } from '../features/workspaces/index'; | ||
7 | import { workspaceActions } from '../features/workspaces/actions'; | ||
8 | import { gaEvent } from './analytics'; | ||
6 | 9 | ||
7 | const { app, Menu, dialog } = remote; | 10 | const { app, Menu, dialog } = remote; |
8 | 11 | ||
@@ -179,6 +182,18 @@ const menuItems = defineMessages({ | |||
179 | id: 'menu.services.addNewService', | 182 | id: 'menu.services.addNewService', |
180 | defaultMessage: '!!!Add New Service...', | 183 | defaultMessage: '!!!Add New Service...', |
181 | }, | 184 | }, |
185 | addNewWorkspace: { | ||
186 | id: 'menu.workspaces.addNewWorkspace', | ||
187 | defaultMessage: '!!!Add New Workspace...', | ||
188 | }, | ||
189 | openWorkspaceDrawer: { | ||
190 | id: 'menu.workspaces.openWorkspaceDrawer', | ||
191 | defaultMessage: '!!!Open workspace drawer', | ||
192 | }, | ||
193 | closeWorkspaceDrawer: { | ||
194 | id: 'menu.workspaces.closeWorkspaceDrawer', | ||
195 | defaultMessage: '!!!Close workspace drawer', | ||
196 | }, | ||
182 | activateNextService: { | 197 | activateNextService: { |
183 | id: 'menu.services.setNextServiceActive', | 198 | id: 'menu.services.setNextServiceActive', |
184 | defaultMessage: '!!!Activate next service...', | 199 | defaultMessage: '!!!Activate next service...', |
@@ -195,6 +210,14 @@ const menuItems = defineMessages({ | |||
195 | id: 'sidebar.unmuteApp', | 210 | id: 'sidebar.unmuteApp', |
196 | defaultMessage: '!!!Enable notifications & audio', | 211 | defaultMessage: '!!!Enable notifications & audio', |
197 | }, | 212 | }, |
213 | workspaces: { | ||
214 | id: 'menu.workspaces', | ||
215 | defaultMessage: '!!!Workspaces', | ||
216 | }, | ||
217 | defaultWorkspace: { | ||
218 | id: 'menu.workspaces.defaultWorkspace', | ||
219 | defaultMessage: '!!!Default', | ||
220 | }, | ||
198 | }); | 221 | }); |
199 | 222 | ||
200 | function getActiveWebview() { | 223 | function getActiveWebview() { |
@@ -298,6 +321,11 @@ const _templateFactory = intl => [ | |||
298 | submenu: [], | 321 | submenu: [], |
299 | }, | 322 | }, |
300 | { | 323 | { |
324 | label: intl.formatMessage(menuItems.workspaces), | ||
325 | submenu: [], | ||
326 | visible: workspaceStore.isFeatureEnabled, | ||
327 | }, | ||
328 | { | ||
301 | label: intl.formatMessage(menuItems.window), | 329 | label: intl.formatMessage(menuItems.window), |
302 | role: 'window', | 330 | role: 'window', |
303 | submenu: [ | 331 | submenu: [ |
@@ -669,7 +697,7 @@ export default class FranzMenu { | |||
669 | }, | 697 | }, |
670 | ); | 698 | ); |
671 | 699 | ||
672 | tpl[4].submenu.unshift(about, { | 700 | tpl[5].submenu.unshift(about, { |
673 | type: 'separator', | 701 | type: 'separator', |
674 | }); | 702 | }); |
675 | } else { | 703 | } else { |
@@ -704,6 +732,10 @@ export default class FranzMenu { | |||
704 | tpl[3].submenu = serviceTpl; | 732 | tpl[3].submenu = serviceTpl; |
705 | } | 733 | } |
706 | 734 | ||
735 | if (workspaceStore.isFeatureEnabled) { | ||
736 | tpl[4].submenu = this.workspacesMenu(); | ||
737 | } | ||
738 | |||
707 | this.currentTemplate = tpl; | 739 | this.currentTemplate = tpl; |
708 | const menu = Menu.buildFromTemplate(tpl); | 740 | const menu = Menu.buildFromTemplate(tpl); |
709 | Menu.setApplicationMenu(menu); | 741 | Menu.setApplicationMenu(menu); |
@@ -754,6 +786,66 @@ export default class FranzMenu { | |||
754 | return menu; | 786 | return menu; |
755 | } | 787 | } |
756 | 788 | ||
789 | workspacesMenu() { | ||
790 | const { workspaces, activeWorkspace, isWorkspaceDrawerOpen } = workspaceStore; | ||
791 | const { intl } = window.franz; | ||
792 | const menu = []; | ||
793 | |||
794 | // Add new workspace item: | ||
795 | menu.push({ | ||
796 | label: intl.formatMessage(menuItems.addNewWorkspace), | ||
797 | accelerator: `${cmdKey}+Shift+N`, | ||
798 | click: () => { | ||
799 | workspaceActions.openWorkspaceSettings(); | ||
800 | }, | ||
801 | enabled: this.stores.user.isLoggedIn, | ||
802 | }); | ||
803 | |||
804 | // Open workspace drawer: | ||
805 | const drawerLabel = ( | ||
806 | isWorkspaceDrawerOpen ? menuItems.closeWorkspaceDrawer : menuItems.openWorkspaceDrawer | ||
807 | ); | ||
808 | menu.push({ | ||
809 | label: intl.formatMessage(drawerLabel), | ||
810 | accelerator: `${cmdKey}+D`, | ||
811 | click: () => { | ||
812 | workspaceActions.toggleWorkspaceDrawer(); | ||
813 | gaEvent(GA_CATEGORY_WORKSPACES, 'toggleDrawer', 'menu'); | ||
814 | }, | ||
815 | enabled: this.stores.user.isLoggedIn, | ||
816 | }, { | ||
817 | type: 'separator', | ||
818 | }); | ||
819 | |||
820 | // Default workspace | ||
821 | menu.push({ | ||
822 | label: intl.formatMessage(menuItems.defaultWorkspace), | ||
823 | accelerator: `${cmdKey}+Alt+0`, | ||
824 | type: 'radio', | ||
825 | checked: !activeWorkspace, | ||
826 | click: () => { | ||
827 | workspaceActions.deactivate(); | ||
828 | gaEvent(GA_CATEGORY_WORKSPACES, 'switch', 'menu'); | ||
829 | }, | ||
830 | }); | ||
831 | |||
832 | // Workspace items | ||
833 | if (this.stores.user.isPremium) { | ||
834 | workspaces.forEach((workspace, i) => menu.push({ | ||
835 | label: workspace.name, | ||
836 | accelerator: i < 9 ? `${cmdKey}+Alt+${i + 1}` : null, | ||
837 | type: 'radio', | ||
838 | checked: activeWorkspace ? workspace.id === activeWorkspace.id : false, | ||
839 | click: () => { | ||
840 | workspaceActions.activate({ workspace }); | ||
841 | gaEvent(GA_CATEGORY_WORKSPACES, 'switch', 'menu'); | ||
842 | }, | ||
843 | })); | ||
844 | } | ||
845 | |||
846 | return menu; | ||
847 | } | ||
848 | |||
757 | _getServiceName(service) { | 849 | _getServiceName(service) { |
758 | if (service.name) { | 850 | if (service.name) { |
759 | return service.name; | 851 | return service.name; |