diff options
author | 2021-08-10 10:47:52 +0530 | |
---|---|---|
committer | 2021-08-10 10:47:52 +0530 | |
commit | 1c3527a84c045af62fa9c44c41a8e7f96742358d (patch) | |
tree | 59333df272631a8f5c5a22868ebcc1a19a4713dd | |
parent | doc: Updated CHANGELOG.md [skip ci] (diff) | |
download | ferdium-app-1c3527a84c045af62fa9c44c41a8e7f96742358d.tar.gz ferdium-app-1c3527a84c045af62fa9c44c41a8e7f96742358d.tar.zst ferdium-app-1c3527a84c045af62fa9c44c41a8e7f96742358d.zip |
refactor: Removed duplication and added note about why they were slightly different
(shortcut accelerator vs tooltip text)
-rw-r--r-- | src/components/layout/Sidebar.js | 7 | ||||
-rw-r--r-- | src/environment.js | 6 | ||||
-rw-r--r-- | src/i18n/locales/defaultMessages.json | 36 | ||||
-rw-r--r-- | src/i18n/messages/src/components/layout/Sidebar.json | 36 | ||||
-rw-r--r-- | src/lib/Menu.js | 6 |
5 files changed, 47 insertions, 44 deletions
diff --git a/src/components/layout/Sidebar.js b/src/components/layout/Sidebar.js index 14ab21fb5..a6f5adce8 100644 --- a/src/components/layout/Sidebar.js +++ b/src/components/layout/Sidebar.js | |||
@@ -6,16 +6,13 @@ import { inject, observer } from 'mobx-react'; | |||
6 | import { Link } from 'react-router'; | 6 | import { Link } from 'react-router'; |
7 | 7 | ||
8 | import Tabbar from '../services/tabs/Tabbar'; | 8 | import Tabbar from '../services/tabs/Tabbar'; |
9 | import { ctrlKey, isMac, shiftKey } from '../../environment'; | 9 | import { ctrlKey, shiftKey, settingsShortcutKey } from '../../environment'; |
10 | import { workspaceStore } from '../../features/workspaces'; | 10 | import { workspaceStore } from '../../features/workspaces'; |
11 | import { todosStore } from '../../features/todos'; | 11 | import { todosStore } from '../../features/todos'; |
12 | import { todoActions } from '../../features/todos/actions'; | 12 | import { todoActions } from '../../features/todos/actions'; |
13 | import AppStore from '../../stores/AppStore'; | 13 | import AppStore from '../../stores/AppStore'; |
14 | import SettingsStore from '../../stores/SettingsStore'; | 14 | import SettingsStore from '../../stores/SettingsStore'; |
15 | 15 | ||
16 | // Platform specific shortcut keys | ||
17 | const settingsShortcutKey = isMac ? ',' : 'P'; | ||
18 | |||
19 | const messages = defineMessages({ | 16 | const messages = defineMessages({ |
20 | settings: { | 17 | settings: { |
21 | id: 'sidebar.settings', | 18 | id: 'sidebar.settings', |
@@ -216,7 +213,7 @@ export default @inject('stores', 'actions') @observer class Sidebar extends Comp | |||
216 | type="button" | 213 | type="button" |
217 | onClick={() => openSettings({ path: 'app' })} | 214 | onClick={() => openSettings({ path: 'app' })} |
218 | className="sidebar__button sidebar__button--settings" | 215 | className="sidebar__button sidebar__button--settings" |
219 | data-tip={`${intl.formatMessage(messages.settings)} (${ctrlKey}+${settingsShortcutKey})`} | 216 | data-tip={`${intl.formatMessage(messages.settings)} (${settingsShortcutKey(false)})`} |
220 | > | 217 | > |
221 | {/* TODO: Because of https://github.com/Templarian/MaterialDesign-Webfont/issues/81 bug in @mdi/font in 5.9.55, added `mdi-memory` as a fallback */} | 218 | {/* TODO: Because of https://github.com/Templarian/MaterialDesign-Webfont/issues/81 bug in @mdi/font in 5.9.55, added `mdi-memory` as a fallback */} |
222 | <i className="mdi mdi-settings mdi-memory" /> | 219 | <i className="mdi mdi-settings mdi-memory" /> |
diff --git a/src/environment.js b/src/environment.js index d257a114a..923754048 100644 --- a/src/environment.js +++ b/src/environment.js | |||
@@ -73,11 +73,17 @@ export const osArch = os.arch(); | |||
73 | export const osRelease = os.release(); | 73 | export const osRelease = os.release(); |
74 | export const is64Bit = osArch.match(/64/); | 74 | export const is64Bit = osArch.match(/64/); |
75 | 75 | ||
76 | // for accelerator, show the shortform that electron/OS understands | ||
77 | // for tooltip, show symbol | ||
76 | export const ctrlKey = isMac ? '⌘' : 'Ctrl'; | 78 | export const ctrlKey = isMac ? '⌘' : 'Ctrl'; |
77 | export const cmdKey = isMac ? 'Cmd' : 'Ctrl'; | 79 | export const cmdKey = isMac ? 'Cmd' : 'Ctrl'; |
80 | |||
78 | export const altKey = isMac ? '⌥' : 'Alt'; | 81 | export const altKey = isMac ? '⌥' : 'Alt'; |
79 | export const shiftKey = isMac ? '⇧' : 'Shift'; | 82 | export const shiftKey = isMac ? '⇧' : 'Shift'; |
80 | 83 | ||
84 | // Platform specific shortcut keys | ||
85 | export const settingsShortcutKey = (isAccelerator = true) => `${isAccelerator ? cmdKey : ctrlKey}+${isMac ? ',' : 'P'}`; | ||
86 | |||
81 | let api; | 87 | let api; |
82 | let wsApi; | 88 | let wsApi; |
83 | let web; | 89 | let web; |
diff --git a/src/i18n/locales/defaultMessages.json b/src/i18n/locales/defaultMessages.json index fe98a7ad4..99f450c23 100644 --- a/src/i18n/locales/defaultMessages.json +++ b/src/i18n/locales/defaultMessages.json | |||
@@ -1092,117 +1092,117 @@ | |||
1092 | "defaultMessage": "!!!Settings", | 1092 | "defaultMessage": "!!!Settings", |
1093 | "end": { | 1093 | "end": { |
1094 | "column": 3, | 1094 | "column": 3, |
1095 | "line": 23 | 1095 | "line": 20 |
1096 | }, | 1096 | }, |
1097 | "file": "src/components/layout/Sidebar.js", | 1097 | "file": "src/components/layout/Sidebar.js", |
1098 | "id": "sidebar.settings", | 1098 | "id": "sidebar.settings", |
1099 | "start": { | 1099 | "start": { |
1100 | "column": 12, | 1100 | "column": 12, |
1101 | "line": 20 | 1101 | "line": 17 |
1102 | } | 1102 | } |
1103 | }, | 1103 | }, |
1104 | { | 1104 | { |
1105 | "defaultMessage": "!!!Add new service", | 1105 | "defaultMessage": "!!!Add new service", |
1106 | "end": { | 1106 | "end": { |
1107 | "column": 3, | 1107 | "column": 3, |
1108 | "line": 27 | 1108 | "line": 24 |
1109 | }, | 1109 | }, |
1110 | "file": "src/components/layout/Sidebar.js", | 1110 | "file": "src/components/layout/Sidebar.js", |
1111 | "id": "sidebar.addNewService", | 1111 | "id": "sidebar.addNewService", |
1112 | "start": { | 1112 | "start": { |
1113 | "column": 17, | 1113 | "column": 17, |
1114 | "line": 24 | 1114 | "line": 21 |
1115 | } | 1115 | } |
1116 | }, | 1116 | }, |
1117 | { | 1117 | { |
1118 | "defaultMessage": "!!!Disable notifications & audio", | 1118 | "defaultMessage": "!!!Disable notifications & audio", |
1119 | "end": { | 1119 | "end": { |
1120 | "column": 3, | 1120 | "column": 3, |
1121 | "line": 31 | 1121 | "line": 28 |
1122 | }, | 1122 | }, |
1123 | "file": "src/components/layout/Sidebar.js", | 1123 | "file": "src/components/layout/Sidebar.js", |
1124 | "id": "sidebar.muteApp", | 1124 | "id": "sidebar.muteApp", |
1125 | "start": { | 1125 | "start": { |
1126 | "column": 8, | 1126 | "column": 8, |
1127 | "line": 28 | 1127 | "line": 25 |
1128 | } | 1128 | } |
1129 | }, | 1129 | }, |
1130 | { | 1130 | { |
1131 | "defaultMessage": "!!!Enable notifications & audio", | 1131 | "defaultMessage": "!!!Enable notifications & audio", |
1132 | "end": { | 1132 | "end": { |
1133 | "column": 3, | 1133 | "column": 3, |
1134 | "line": 35 | 1134 | "line": 32 |
1135 | }, | 1135 | }, |
1136 | "file": "src/components/layout/Sidebar.js", | 1136 | "file": "src/components/layout/Sidebar.js", |
1137 | "id": "sidebar.unmuteApp", | 1137 | "id": "sidebar.unmuteApp", |
1138 | "start": { | 1138 | "start": { |
1139 | "column": 10, | 1139 | "column": 10, |
1140 | "line": 32 | 1140 | "line": 29 |
1141 | } | 1141 | } |
1142 | }, | 1142 | }, |
1143 | { | 1143 | { |
1144 | "defaultMessage": "!!!Open workspace drawer", | 1144 | "defaultMessage": "!!!Open workspace drawer", |
1145 | "end": { | 1145 | "end": { |
1146 | "column": 3, | 1146 | "column": 3, |
1147 | "line": 39 | 1147 | "line": 36 |
1148 | }, | 1148 | }, |
1149 | "file": "src/components/layout/Sidebar.js", | 1149 | "file": "src/components/layout/Sidebar.js", |
1150 | "id": "sidebar.openWorkspaceDrawer", | 1150 | "id": "sidebar.openWorkspaceDrawer", |
1151 | "start": { | 1151 | "start": { |
1152 | "column": 23, | 1152 | "column": 23, |
1153 | "line": 36 | 1153 | "line": 33 |
1154 | } | 1154 | } |
1155 | }, | 1155 | }, |
1156 | { | 1156 | { |
1157 | "defaultMessage": "!!!Close workspace drawer", | 1157 | "defaultMessage": "!!!Close workspace drawer", |
1158 | "end": { | 1158 | "end": { |
1159 | "column": 3, | 1159 | "column": 3, |
1160 | "line": 43 | 1160 | "line": 40 |
1161 | }, | 1161 | }, |
1162 | "file": "src/components/layout/Sidebar.js", | 1162 | "file": "src/components/layout/Sidebar.js", |
1163 | "id": "sidebar.closeWorkspaceDrawer", | 1163 | "id": "sidebar.closeWorkspaceDrawer", |
1164 | "start": { | 1164 | "start": { |
1165 | "column": 24, | 1165 | "column": 24, |
1166 | "line": 40 | 1166 | "line": 37 |
1167 | } | 1167 | } |
1168 | }, | 1168 | }, |
1169 | { | 1169 | { |
1170 | "defaultMessage": "!!!Open Franz Todos", | 1170 | "defaultMessage": "!!!Open Franz Todos", |
1171 | "end": { | 1171 | "end": { |
1172 | "column": 3, | 1172 | "column": 3, |
1173 | "line": 47 | 1173 | "line": 44 |
1174 | }, | 1174 | }, |
1175 | "file": "src/components/layout/Sidebar.js", | 1175 | "file": "src/components/layout/Sidebar.js", |
1176 | "id": "sidebar.openTodosDrawer", | 1176 | "id": "sidebar.openTodosDrawer", |
1177 | "start": { | 1177 | "start": { |
1178 | "column": 19, | 1178 | "column": 19, |
1179 | "line": 44 | 1179 | "line": 41 |
1180 | } | 1180 | } |
1181 | }, | 1181 | }, |
1182 | { | 1182 | { |
1183 | "defaultMessage": "!!!Close Franz Todos", | 1183 | "defaultMessage": "!!!Close Franz Todos", |
1184 | "end": { | 1184 | "end": { |
1185 | "column": 3, | 1185 | "column": 3, |
1186 | "line": 51 | 1186 | "line": 48 |
1187 | }, | 1187 | }, |
1188 | "file": "src/components/layout/Sidebar.js", | 1188 | "file": "src/components/layout/Sidebar.js", |
1189 | "id": "sidebar.closeTodosDrawer", | 1189 | "id": "sidebar.closeTodosDrawer", |
1190 | "start": { | 1190 | "start": { |
1191 | "column": 20, | 1191 | "column": 20, |
1192 | "line": 48 | 1192 | "line": 45 |
1193 | } | 1193 | } |
1194 | }, | 1194 | }, |
1195 | { | 1195 | { |
1196 | "defaultMessage": "!!!Lock Ferdi", | 1196 | "defaultMessage": "!!!Lock Ferdi", |
1197 | "end": { | 1197 | "end": { |
1198 | "column": 3, | 1198 | "column": 3, |
1199 | "line": 55 | 1199 | "line": 52 |
1200 | }, | 1200 | }, |
1201 | "file": "src/components/layout/Sidebar.js", | 1201 | "file": "src/components/layout/Sidebar.js", |
1202 | "id": "sidebar.lockFerdi", | 1202 | "id": "sidebar.lockFerdi", |
1203 | "start": { | 1203 | "start": { |
1204 | "column": 13, | 1204 | "column": 13, |
1205 | "line": 52 | 1205 | "line": 49 |
1206 | } | 1206 | } |
1207 | } | 1207 | } |
1208 | ], | 1208 | ], |
diff --git a/src/i18n/messages/src/components/layout/Sidebar.json b/src/i18n/messages/src/components/layout/Sidebar.json index 2d8fe0676..f16baea32 100644 --- a/src/i18n/messages/src/components/layout/Sidebar.json +++ b/src/i18n/messages/src/components/layout/Sidebar.json | |||
@@ -4,11 +4,11 @@ | |||
4 | "defaultMessage": "!!!Settings", | 4 | "defaultMessage": "!!!Settings", |
5 | "file": "src/components/layout/Sidebar.js", | 5 | "file": "src/components/layout/Sidebar.js", |
6 | "start": { | 6 | "start": { |
7 | "line": 20, | 7 | "line": 17, |
8 | "column": 12 | 8 | "column": 12 |
9 | }, | 9 | }, |
10 | "end": { | 10 | "end": { |
11 | "line": 23, | 11 | "line": 20, |
12 | "column": 3 | 12 | "column": 3 |
13 | } | 13 | } |
14 | }, | 14 | }, |
@@ -17,11 +17,11 @@ | |||
17 | "defaultMessage": "!!!Add new service", | 17 | "defaultMessage": "!!!Add new service", |
18 | "file": "src/components/layout/Sidebar.js", | 18 | "file": "src/components/layout/Sidebar.js", |
19 | "start": { | 19 | "start": { |
20 | "line": 24, | 20 | "line": 21, |
21 | "column": 17 | 21 | "column": 17 |
22 | }, | 22 | }, |
23 | "end": { | 23 | "end": { |
24 | "line": 27, | 24 | "line": 24, |
25 | "column": 3 | 25 | "column": 3 |
26 | } | 26 | } |
27 | }, | 27 | }, |
@@ -30,11 +30,11 @@ | |||
30 | "defaultMessage": "!!!Disable notifications & audio", | 30 | "defaultMessage": "!!!Disable notifications & audio", |
31 | "file": "src/components/layout/Sidebar.js", | 31 | "file": "src/components/layout/Sidebar.js", |
32 | "start": { | 32 | "start": { |
33 | "line": 28, | 33 | "line": 25, |
34 | "column": 8 | 34 | "column": 8 |
35 | }, | 35 | }, |
36 | "end": { | 36 | "end": { |
37 | "line": 31, | 37 | "line": 28, |
38 | "column": 3 | 38 | "column": 3 |
39 | } | 39 | } |
40 | }, | 40 | }, |
@@ -43,11 +43,11 @@ | |||
43 | "defaultMessage": "!!!Enable notifications & audio", | 43 | "defaultMessage": "!!!Enable notifications & audio", |
44 | "file": "src/components/layout/Sidebar.js", | 44 | "file": "src/components/layout/Sidebar.js", |
45 | "start": { | 45 | "start": { |
46 | "line": 32, | 46 | "line": 29, |
47 | "column": 10 | 47 | "column": 10 |
48 | }, | 48 | }, |
49 | "end": { | 49 | "end": { |
50 | "line": 35, | 50 | "line": 32, |
51 | "column": 3 | 51 | "column": 3 |
52 | } | 52 | } |
53 | }, | 53 | }, |
@@ -56,11 +56,11 @@ | |||
56 | "defaultMessage": "!!!Open workspace drawer", | 56 | "defaultMessage": "!!!Open workspace drawer", |
57 | "file": "src/components/layout/Sidebar.js", | 57 | "file": "src/components/layout/Sidebar.js", |
58 | "start": { | 58 | "start": { |
59 | "line": 36, | 59 | "line": 33, |
60 | "column": 23 | 60 | "column": 23 |
61 | }, | 61 | }, |
62 | "end": { | 62 | "end": { |
63 | "line": 39, | 63 | "line": 36, |
64 | "column": 3 | 64 | "column": 3 |
65 | } | 65 | } |
66 | }, | 66 | }, |
@@ -69,11 +69,11 @@ | |||
69 | "defaultMessage": "!!!Close workspace drawer", | 69 | "defaultMessage": "!!!Close workspace drawer", |
70 | "file": "src/components/layout/Sidebar.js", | 70 | "file": "src/components/layout/Sidebar.js", |
71 | "start": { | 71 | "start": { |
72 | "line": 40, | 72 | "line": 37, |
73 | "column": 24 | 73 | "column": 24 |
74 | }, | 74 | }, |
75 | "end": { | 75 | "end": { |
76 | "line": 43, | 76 | "line": 40, |
77 | "column": 3 | 77 | "column": 3 |
78 | } | 78 | } |
79 | }, | 79 | }, |
@@ -82,11 +82,11 @@ | |||
82 | "defaultMessage": "!!!Open Franz Todos", | 82 | "defaultMessage": "!!!Open Franz Todos", |
83 | "file": "src/components/layout/Sidebar.js", | 83 | "file": "src/components/layout/Sidebar.js", |
84 | "start": { | 84 | "start": { |
85 | "line": 44, | 85 | "line": 41, |
86 | "column": 19 | 86 | "column": 19 |
87 | }, | 87 | }, |
88 | "end": { | 88 | "end": { |
89 | "line": 47, | 89 | "line": 44, |
90 | "column": 3 | 90 | "column": 3 |
91 | } | 91 | } |
92 | }, | 92 | }, |
@@ -95,11 +95,11 @@ | |||
95 | "defaultMessage": "!!!Close Franz Todos", | 95 | "defaultMessage": "!!!Close Franz Todos", |
96 | "file": "src/components/layout/Sidebar.js", | 96 | "file": "src/components/layout/Sidebar.js", |
97 | "start": { | 97 | "start": { |
98 | "line": 48, | 98 | "line": 45, |
99 | "column": 20 | 99 | "column": 20 |
100 | }, | 100 | }, |
101 | "end": { | 101 | "end": { |
102 | "line": 51, | 102 | "line": 48, |
103 | "column": 3 | 103 | "column": 3 |
104 | } | 104 | } |
105 | }, | 105 | }, |
@@ -108,11 +108,11 @@ | |||
108 | "defaultMessage": "!!!Lock Ferdi", | 108 | "defaultMessage": "!!!Lock Ferdi", |
109 | "file": "src/components/layout/Sidebar.js", | 109 | "file": "src/components/layout/Sidebar.js", |
110 | "start": { | 110 | "start": { |
111 | "line": 52, | 111 | "line": 49, |
112 | "column": 13 | 112 | "column": 13 |
113 | }, | 113 | }, |
114 | "end": { | 114 | "end": { |
115 | "line": 55, | 115 | "line": 52, |
116 | "column": 3 | 116 | "column": 3 |
117 | } | 117 | } |
118 | } | 118 | } |
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 7c69ddea7..e8d3e79b4 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -6,7 +6,7 @@ import { autorun, observable } from 'mobx'; | |||
6 | import { defineMessages } from 'react-intl'; | 6 | import { defineMessages } from 'react-intl'; |
7 | import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; | 7 | import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; |
8 | import { | 8 | import { |
9 | cmdKey, altKey, shiftKey, isLinux, isMac, aboutAppDetails, | 9 | cmdKey, altKey, shiftKey, settingsShortcutKey, isLinux, isMac, aboutAppDetails, |
10 | } from '../environment'; | 10 | } from '../environment'; |
11 | import { announcementsStore } from '../features/announcements'; | 11 | import { announcementsStore } from '../features/announcements'; |
12 | import { announcementActions } from '../features/announcements/actions'; | 12 | import { announcementActions } from '../features/announcements/actions'; |
@@ -727,7 +727,7 @@ export default class FranzMenu { | |||
727 | }, | 727 | }, |
728 | { | 728 | { |
729 | label: intl.formatMessage(menuItems.settings), | 729 | label: intl.formatMessage(menuItems.settings), |
730 | accelerator: `${cmdKey}+,`, | 730 | accelerator: `${settingsShortcutKey()}`, |
731 | click: () => { | 731 | click: () => { |
732 | this.actions.ui.openSettings({ path: 'app' }); | 732 | this.actions.ui.openSettings({ path: 'app' }); |
733 | }, | 733 | }, |
@@ -819,7 +819,7 @@ export default class FranzMenu { | |||
819 | tpl[0].submenu = [ | 819 | tpl[0].submenu = [ |
820 | { | 820 | { |
821 | label: intl.formatMessage(menuItems.settings), | 821 | label: intl.formatMessage(menuItems.settings), |
822 | accelerator: `${cmdKey}+P`, | 822 | accelerator: `${settingsShortcutKey()}`, |
823 | click: () => { | 823 | click: () => { |
824 | this.actions.ui.openSettings({ path: 'app' }); | 824 | this.actions.ui.openSettings({ path: 'app' }); |
825 | }, | 825 | }, |