diff options
author | 2022-07-15 14:50:34 +0530 | |
---|---|---|
committer | 2022-07-15 14:50:34 +0530 | |
commit | a6a4bb4d0ad584936297d2413ab6f4c156ccdf0c (patch) | |
tree | 4ec1caa1e92bdb0531aa4f03e67dc9574d7ead0c | |
parent | Use defaults defined in one place instead of hardcoding in multiple places (diff) | |
download | ferdium-app-a6a4bb4d0ad584936297d2413ab6f4c156ccdf0c.tar.gz ferdium-app-a6a4bb4d0ad584936297d2413ab6f4c156ccdf0c.tar.zst ferdium-app-a6a4bb4d0ad584936297d2413ab6f4c156ccdf0c.zip |
fix: enable/disable todos menu (#485)
Co-authored-by: Ricardo Cino <ricardo@cino.io>
-rw-r--r-- | src/i18n/locales/en-US.json | 1 | ||||
-rw-r--r-- | src/lib/Menu.js | 36 |
2 files changed, 21 insertions, 16 deletions
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json index 8c9eba56b..3c3beea6f 100644 --- a/src/i18n/locales/en-US.json +++ b/src/i18n/locales/en-US.json | |||
@@ -119,6 +119,7 @@ | |||
119 | "menu.services.goHome": "Home", | 119 | "menu.services.goHome": "Home", |
120 | "menu.services.setNextServiceActive": "Activate next service", | 120 | "menu.services.setNextServiceActive": "Activate next service", |
121 | "menu.todos": "Todos", | 121 | "menu.todos": "Todos", |
122 | "menu.todos.disableTodos": "Disable Todos", | ||
122 | "menu.todos.enableTodos": "Enable Todos", | 123 | "menu.todos.enableTodos": "Enable Todos", |
123 | "menu.view": "View", | 124 | "menu.view": "View", |
124 | "menu.view.back": "Back", | 125 | "menu.view.back": "Back", |
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index e0a5a5bcd..8fd3e9e01 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -333,6 +333,10 @@ const menuItems = defineMessages({ | |||
333 | id: 'menu.todos.enableTodos', | 333 | id: 'menu.todos.enableTodos', |
334 | defaultMessage: 'Enable Todos', | 334 | defaultMessage: 'Enable Todos', |
335 | }, | 335 | }, |
336 | disableTodos: { | ||
337 | id: 'menu.todos.disableTodos', | ||
338 | defaultMessage: 'Disable Todos', | ||
339 | }, | ||
336 | serviceGoHome: { | 340 | serviceGoHome: { |
337 | id: 'menu.services.goHome', | 341 | id: 'menu.services.goHome', |
338 | defaultMessage: 'Home', | 342 | defaultMessage: 'Home', |
@@ -1158,30 +1162,30 @@ class FranzMenu { | |||
1158 | const { intl } = window['ferdium']; | 1162 | const { intl } = window['ferdium']; |
1159 | const menu = []; | 1163 | const menu = []; |
1160 | 1164 | ||
1161 | const drawerLabel = isTodosPanelVisible | 1165 | menu.push({ |
1162 | ? menuItems.closeTodosDrawer | 1166 | label: intl.formatMessage( |
1163 | : menuItems.openTodosDrawer; | 1167 | isFeatureEnabledByUser ? menuItems.disableTodos : menuItems.enableTodos, |
1168 | ), | ||
1169 | click: () => { | ||
1170 | todoActions.toggleTodosFeatureVisibility(); | ||
1171 | }, | ||
1172 | enabled: this.stores.user.isLoggedIn, | ||
1173 | }); | ||
1164 | 1174 | ||
1165 | if (isFeatureEnabledByUser) { | 1175 | if (isFeatureEnabledByUser) { |
1166 | menu.push({ | ||
1167 | label: intl.formatMessage(drawerLabel), | ||
1168 | accelerator: `${todosToggleShortcutKey()}`, | ||
1169 | click: () => { | ||
1170 | todoActions.toggleTodosPanel(); | ||
1171 | }, | ||
1172 | enabled: this.stores.user.isLoggedIn && isFeatureEnabledByUser, | ||
1173 | }); | ||
1174 | } | ||
1175 | |||
1176 | if (!isFeatureEnabledByUser) { | ||
1177 | menu.push( | 1176 | menu.push( |
1178 | { | 1177 | { |
1179 | type: 'separator', | 1178 | type: 'separator', |
1180 | }, | 1179 | }, |
1181 | { | 1180 | { |
1182 | label: intl.formatMessage(menuItems.enableTodos), | 1181 | label: intl.formatMessage( |
1182 | isTodosPanelVisible | ||
1183 | ? menuItems.closeTodosDrawer | ||
1184 | : menuItems.openTodosDrawer, | ||
1185 | ), | ||
1186 | accelerator: `${todosToggleShortcutKey()}`, | ||
1183 | click: () => { | 1187 | click: () => { |
1184 | todoActions.toggleTodosFeatureVisibility(); | 1188 | todoActions.toggleTodosPanel(); |
1185 | }, | 1189 | }, |
1186 | enabled: this.stores.user.isLoggedIn, | 1190 | enabled: this.stores.user.isLoggedIn, |
1187 | }, | 1191 | }, |