aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Amine Mouafik <amine@mouafik.fr>2020-02-28 03:29:23 +0100
committerLibravatar Amine Mouafik <amine@mouafik.fr>2020-02-28 03:29:23 +0100
commitd98d728612c3db75ddf15cc24e93e121a7a91fb1 (patch)
treef054f8decec93f702453072c13ee1d99b8799fd7
parentDo not include debug menu items when locked (diff)
parentMerge pull request #393 from getferdi/refactor/lock (diff)
downloadferdium-app-d98d728612c3db75ddf15cc24e93e121a7a91fb1.tar.gz
ferdium-app-d98d728612c3db75ddf15cc24e93e121a7a91fb1.tar.zst
ferdium-app-d98d728612c3db75ddf15cc24e93e121a7a91fb1.zip
Merge branch 'develop' into fix/lock-menu
# Conflicts: # src/lib/Menu.js
-rw-r--r--src/components/layout/Sidebar.js11
-rw-r--r--src/components/services/content/ServiceView.js6
-rw-r--r--src/components/settings/settings/EditSettingsForm.js2
-rw-r--r--src/config.js7
-rw-r--r--src/containers/settings/EditSettingsScreen.js24
-rw-r--r--src/i18n/locales/defaultMessages.json6
-rw-r--r--src/i18n/locales/en-US.json2
-rw-r--r--src/i18n/messages/src/containers/settings/EditSettingsScreen.json6
-rw-r--r--src/lib/Menu.js27
-rw-r--r--src/stores/SettingsStore.js88
10 files changed, 93 insertions, 86 deletions
diff --git a/src/components/layout/Sidebar.js b/src/components/layout/Sidebar.js
index 48a83c5a1..bd10ccb4a 100644
--- a/src/components/layout/Sidebar.js
+++ b/src/components/layout/Sidebar.js
@@ -118,21 +118,12 @@ export default @inject('stores', 'actions') @observer class Sidebar extends Comp
118 type="button" 118 type="button"
119 className="sidebar__button" 119 className="sidebar__button"
120 onClick={() => { 120 onClick={() => {
121 // Disable lock first - otherwise the application might not update correctly
122 actions.settings.update({ 121 actions.settings.update({
123 type: 'app', 122 type: 'app',
124 data: { 123 data: {
125 locked: false, 124 locked: true,
126 }, 125 },
127 }); 126 });
128 setTimeout(() => {
129 actions.settings.update({
130 type: 'app',
131 data: {
132 locked: true,
133 },
134 });
135 }, 0);
136 }} 127 }}
137 data-tip={`${intl.formatMessage(messages.lockFerdi)} (${ctrlKey}+Shift+L)`} 128 data-tip={`${intl.formatMessage(messages.lockFerdi)} (${ctrlKey}+Shift+L)`}
138 > 129 >
diff --git a/src/components/services/content/ServiceView.js b/src/components/services/content/ServiceView.js
index 860863d26..f6832038a 100644
--- a/src/components/services/content/ServiceView.js
+++ b/src/components/services/content/ServiceView.js
@@ -135,9 +135,11 @@ export default @inject('stores', 'actions') @observer class ServiceView extends
135 } = this.props; 135 } = this.props;
136 136
137 const { 137 const {
138 showServiceNavigationBar, 138 navigationBarBehaviour,
139 } = stores.settings.app; 139 } = stores.settings.app;
140 140
141 const showNavBar = navigationBarBehaviour === 'always' || (navigationBarBehaviour === 'custom' && service.recipe.id === CUSTOM_WEBSITE_ID);
142
141 const webviewClasses = classnames({ 143 const webviewClasses = classnames({
142 services__webview: true, 144 services__webview: true,
143 'services__webview-wrapper': true, 145 'services__webview-wrapper': true,
@@ -193,7 +195,7 @@ export default @inject('stores', 'actions') @observer class ServiceView extends
193 <> 195 <>
194 {!service.isHibernating ? ( 196 {!service.isHibernating ? (
195 <> 197 <>
196 {(service.recipe.id === CUSTOM_WEBSITE_ID || showServiceNavigationBar) && ( 198 {showNavBar && (
197 <WebControlsScreen service={service} /> 199 <WebControlsScreen service={service} />
198 )} 200 )}
199 <ServiceWebview 201 <ServiceWebview
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js
index 432a546d9..f41c7db8e 100644
--- a/src/components/settings/settings/EditSettingsForm.js
+++ b/src/components/settings/settings/EditSettingsForm.js
@@ -256,7 +256,7 @@ export default @observer class EditSettingsForm extends Component {
256 <Toggle field={form.$('minimizeToSystemTray')} /> 256 <Toggle field={form.$('minimizeToSystemTray')} />
257 )} 257 )}
258 <Toggle field={form.$('privateNotifications')} /> 258 <Toggle field={form.$('privateNotifications')} />
259 <Toggle field={form.$('showServiceNavigationBar')} /> 259 <Select field={form.$('navigationBarBehaviour')} />
260 260
261 <Hr /> 261 <Hr />
262 262
diff --git a/src/config.js b/src/config.js
index 9b77aa9a5..283c20f84 100644
--- a/src/config.js
+++ b/src/config.js
@@ -45,6 +45,12 @@ export const HIBERNATION_STRATEGIES = {
45 3600: 'Extemely Slow Hibernation (1hour)', 45 3600: 'Extemely Slow Hibernation (1hour)',
46}; 46};
47 47
48export const NAVIGATION_BAR_BEHAVIOURS = {
49 custom: 'Show navigation bar on custom websites only',
50 always: 'Show navigation bar on all services',
51 never: 'Never show navigation bar',
52};
53
48export const SIDEBAR_WIDTH = { 54export const SIDEBAR_WIDTH = {
49 35: 'Extemely slim sidebar', 55 35: 'Extemely slim sidebar',
50 45: 'Very slim sidebar', 56 45: 'Very slim sidebar',
@@ -107,6 +113,7 @@ export const DEFAULT_APP_SETTINGS = {
107 serviceRibbonWidth: 68, 113 serviceRibbonWidth: 68,
108 iconSize: iconSizeBias, 114 iconSize: iconSizeBias,
109 sentry: false, 115 sentry: false,
116 navigationBarBehaviour: 'custom',
110}; 117};
111 118
112export const DEFAULT_FEATURES_CONFIG = { 119export const DEFAULT_FEATURES_CONFIG = {
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js
index ee5e3615c..6dd21f961 100644
--- a/src/containers/settings/EditSettingsScreen.js
+++ b/src/containers/settings/EditSettingsScreen.js
@@ -11,7 +11,7 @@ import TodosStore from '../../features/todos/store';
11import Form from '../../lib/Form'; 11import Form from '../../lib/Form';
12import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages'; 12import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages';
13import { 13import {
14 DEFAULT_APP_SETTINGS, HIBERNATION_STRATEGIES, SIDEBAR_WIDTH, ICON_SIZES, 14 DEFAULT_APP_SETTINGS, HIBERNATION_STRATEGIES, SIDEBAR_WIDTH, ICON_SIZES, NAVIGATION_BAR_BEHAVIOURS,
15} from '../../config'; 15} from '../../config';
16import { config as spellcheckerConfig } from '../../features/spellchecker'; 16import { config as spellcheckerConfig } from '../../features/spellchecker';
17 17
@@ -56,9 +56,9 @@ const messages = defineMessages({
56 id: 'settings.app.form.privateNotifications', 56 id: 'settings.app.form.privateNotifications',
57 defaultMessage: '!!!Don\'t show message content in notifications', 57 defaultMessage: '!!!Don\'t show message content in notifications',
58 }, 58 },
59 showServiceNavigationBar: { 59 navigationBarBehaviour: {
60 id: 'settings.app.form.showServiceNavigationBar', 60 id: 'settings.app.form.navigationBarBehaviour',
61 defaultMessage: '!!!Always show service navigation bar', 61 defaultMessage: '!!!Navigation bar behaviour',
62 }, 62 },
63 sentry: { 63 sentry: {
64 id: 'settings.app.form.sentry', 64 id: 'settings.app.form.sentry',
@@ -194,7 +194,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
194 startMinimized: settingsData.startMinimized, 194 startMinimized: settingsData.startMinimized,
195 minimizeToSystemTray: settingsData.minimizeToSystemTray, 195 minimizeToSystemTray: settingsData.minimizeToSystemTray,
196 privateNotifications: settingsData.privateNotifications, 196 privateNotifications: settingsData.privateNotifications,
197 showServiceNavigationBar: settingsData.showServiceNavigationBar, 197 navigationBarBehaviour: settingsData.navigationBarBehaviour,
198 sentry: settingsData.sentry, 198 sentry: settingsData.sentry,
199 hibernate: settingsData.hibernate, 199 hibernate: settingsData.hibernate,
200 hibernationStrategy: settingsData.hibernationStrategy, 200 hibernationStrategy: settingsData.hibernationStrategy,
@@ -260,6 +260,11 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
260 locales: APP_LOCALES, 260 locales: APP_LOCALES,
261 }); 261 });
262 262
263 const navigationBarBehaviours = getSelectOptions({
264 locales: NAVIGATION_BAR_BEHAVIOURS,
265 sort: false,
266 });
267
263 const hibernationStrategies = getSelectOptions({ 268 const hibernationStrategies = getSelectOptions({
264 locales: HIBERNATION_STRATEGIES, 269 locales: HIBERNATION_STRATEGIES,
265 sort: false, 270 sort: false,
@@ -317,10 +322,11 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
317 value: settings.all.app.privateNotifications, 322 value: settings.all.app.privateNotifications,
318 default: DEFAULT_APP_SETTINGS.privateNotifications, 323 default: DEFAULT_APP_SETTINGS.privateNotifications,
319 }, 324 },
320 showServiceNavigationBar: { 325 navigationBarBehaviour: {
321 label: intl.formatMessage(messages.showServiceNavigationBar), 326 label: intl.formatMessage(messages.navigationBarBehaviour),
322 value: settings.all.app.showServiceNavigationBar, 327 value: settings.all.app.navigationBarBehaviour,
323 default: DEFAULT_APP_SETTINGS.showServiceNavigationBar, 328 default: DEFAULT_APP_SETTINGS.navigationBarBehaviour,
329 options: navigationBarBehaviours,
324 }, 330 },
325 sentry: { 331 sentry: {
326 label: intl.formatMessage(messages.sentry), 332 label: intl.formatMessage(messages.sentry),
diff --git a/src/i18n/locales/defaultMessages.json b/src/i18n/locales/defaultMessages.json
index 0ea45b977..211214d93 100644
--- a/src/i18n/locales/defaultMessages.json
+++ b/src/i18n/locales/defaultMessages.json
@@ -4214,15 +4214,15 @@
4214 } 4214 }
4215 }, 4215 },
4216 { 4216 {
4217 "defaultMessage": "!!!Always show service navigation bar", 4217 "defaultMessage": "!!!Navigation bar behaviour",
4218 "end": { 4218 "end": {
4219 "column": 3, 4219 "column": 3,
4220 "line": 62 4220 "line": 62
4221 }, 4221 },
4222 "file": "src/containers/settings/EditSettingsScreen.js", 4222 "file": "src/containers/settings/EditSettingsScreen.js",
4223 "id": "settings.app.form.showServiceNavigationBar", 4223 "id": "settings.app.form.navigationBarBehaviour",
4224 "start": { 4224 "start": {
4225 "column": 28, 4225 "column": 26,
4226 "line": 59 4226 "line": 59
4227 } 4227 }
4228 }, 4228 },
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index 935b8550c..36494724b 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -284,6 +284,7 @@
284 "settings.app.form.language": "Language", 284 "settings.app.form.language": "Language",
285 "settings.app.form.lockPassword": "Password", 285 "settings.app.form.lockPassword": "Password",
286 "settings.app.form.minimizeToSystemTray": "Minimize Ferdi to system tray", 286 "settings.app.form.minimizeToSystemTray": "Minimize Ferdi to system tray",
287 "settings.app.form.navigationBarBehaviour": "Navigation bar behaviour",
287 "settings.app.form.noUpdates": "Disable updates", 288 "settings.app.form.noUpdates": "Disable updates",
288 "settings.app.form.privateNotifications": "Don't show message content in notifications", 289 "settings.app.form.privateNotifications": "Don't show message content in notifications",
289 "settings.app.form.runInBackground": "Keep Ferdi in background when closing the window", 290 "settings.app.form.runInBackground": "Keep Ferdi in background when closing the window",
@@ -295,7 +296,6 @@
295 "settings.app.form.serviceRibbonWidth": "Sidebar width", 296 "settings.app.form.serviceRibbonWidth": "Sidebar width",
296 "settings.app.form.showDisabledServices": "Display disabled services tabs", 297 "settings.app.form.showDisabledServices": "Display disabled services tabs",
297 "settings.app.form.showMessagesBadgesWhenMuted": "Show unread message badge when notifications are disabled", 298 "settings.app.form.showMessagesBadgesWhenMuted": "Show unread message badge when notifications are disabled",
298 "settings.app.form.showServiceNavigationBar": "Always show service navigation bar",
299 "settings.app.form.startMinimized": "Start minimized in tray", 299 "settings.app.form.startMinimized": "Start minimized in tray",
300 "settings.app.form.todoServer": "Todo Server", 300 "settings.app.form.todoServer": "Todo Server",
301 "settings.app.form.universalDarkMode": "Enable universal Dark Mode", 301 "settings.app.form.universalDarkMode": "Enable universal Dark Mode",
diff --git a/src/i18n/messages/src/containers/settings/EditSettingsScreen.json b/src/i18n/messages/src/containers/settings/EditSettingsScreen.json
index 98abb0f2b..fdf49bbb6 100644
--- a/src/i18n/messages/src/containers/settings/EditSettingsScreen.json
+++ b/src/i18n/messages/src/containers/settings/EditSettingsScreen.json
@@ -91,12 +91,12 @@
91 } 91 }
92 }, 92 },
93 { 93 {
94 "id": "settings.app.form.showServiceNavigationBar", 94 "id": "settings.app.form.navigationBarBehaviour",
95 "defaultMessage": "!!!Always show service navigation bar", 95 "defaultMessage": "!!!Navigation bar behaviour",
96 "file": "src/containers/settings/EditSettingsScreen.js", 96 "file": "src/containers/settings/EditSettingsScreen.js",
97 "start": { 97 "start": {
98 "line": 59, 98 "line": 59,
99 "column": 28 99 "column": 26
100 }, 100 },
101 "end": { 101 "end": {
102 "line": 62, 102 "line": 62,
diff --git a/src/lib/Menu.js b/src/lib/Menu.js
index 56276ce2d..2ac7e4465 100644
--- a/src/lib/Menu.js
+++ b/src/lib/Menu.js
@@ -1,15 +1,15 @@
1import { remote, shell, clipboard } from 'electron'; 1import { clipboard, remote, shell } from 'electron';
2import { observable, autorun } from 'mobx'; 2import { autorun, observable } from 'mobx';
3import { defineMessages } from 'react-intl'; 3import { defineMessages } from 'react-intl';
4 4import { cmdKey, ctrlKey, isMac } from '../environment';
5import { isMac, ctrlKey, cmdKey } from '../environment';
6import { workspaceStore } from '../features/workspaces/index';
7import { workspaceActions } from '../features/workspaces/actions';
8import { announcementActions } from '../features/announcements/actions';
9import { announcementsStore } from '../features/announcements'; 5import { announcementsStore } from '../features/announcements';
6import { announcementActions } from '../features/announcements/actions';
10import { todosStore } from '../features/todos'; 7import { todosStore } from '../features/todos';
11import { todoActions } from '../features/todos/actions'; 8import { todoActions } from '../features/todos/actions';
12import { CUSTOM_WEBSITE_ID } from '../features/webControls/constants'; 9import { CUSTOM_WEBSITE_ID } from '../features/webControls/constants';
10import { workspaceActions } from '../features/workspaces/actions';
11import { workspaceStore } from '../features/workspaces/index';
12
13 13
14const { app, Menu, dialog } = remote; 14const { app, Menu, dialog } = remote;
15 15
@@ -811,22 +811,13 @@ export default class FranzMenu {
811 accelerator: 'CmdOrCtrl+Shift+L', 811 accelerator: 'CmdOrCtrl+Shift+L',
812 enabled: this.stores.user.isLoggedIn && this.stores.settings.app.lockingFeatureEnabled, 812 enabled: this.stores.user.isLoggedIn && this.stores.settings.app.lockingFeatureEnabled,
813 click() { 813 click() {
814 // Disable lock first - otherwise the application might not update correctly
815 actions.settings.update({ 814 actions.settings.update({
816 type: 'app', 815 type: 'app',
817 data: { 816 data: {
818 locked: false, 817 locked: true,
819 }, 818 },
820 }); 819 });
821 setTimeout(() => { 820 }
822 actions.settings.update({
823 type: 'app',
824 data: {
825 locked: true,
826 },
827 });
828 }, 0);
829 },
830 }); 821 });
831 822
832 if (serviceTpl.length > 0) { 823 if (serviceTpl.length > 0) {
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index da63bc972..26e83b725 100644
--- a/src/stores/SettingsStore.js
+++ b/src/stores/SettingsStore.js
@@ -1,21 +1,18 @@
1import { ipcRenderer, remote } from 'electron'; 1import { ipcRenderer, remote } from 'electron';
2import { 2import { action, computed, observable, reaction } from 'mobx';
3 action, computed, observable, reaction,
4} from 'mobx';
5import localStorage from 'mobx-localstorage'; 3import localStorage from 'mobx-localstorage';
6
7import Store from './lib/Store';
8import Request from './lib/Request';
9import { getLocale } from '../helpers/i18n-helpers';
10import { API } from '../environment';
11
12import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config'; 4import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config';
5import { API } from '../environment';
6import { getLocale } from '../helpers/i18n-helpers';
13import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 7import { SPELLCHECKER_LOCALES } from '../i18n/languages';
8import Request from './lib/Request';
9import Store from './lib/Store';
14 10
15const debug = require('debug')('Ferdi:SettingsStore'); 11const debug = require('debug')('Ferdi:SettingsStore');
16 12
17export default class SettingsStore extends Store { 13export default class SettingsStore extends Store {
18 @observable updateAppSettingsRequest = new Request(this.api.local, 'updateAppSettings'); 14 @observable updateAppSettingsRequest = new Request(this.api.local, 'updateAppSettings');
15 startup = true;
19 16
20 fileSystemSettingsTypes = FILE_SYSTEM_SETTINGS_TYPES; 17 fileSystemSettingsTypes = FILE_SYSTEM_SETTINGS_TYPES;
21 18
@@ -30,16 +27,6 @@ export default class SettingsStore extends Store {
30 // Register action handlers 27 // Register action handlers
31 this.actions.settings.update.listen(this._update.bind(this)); 28 this.actions.settings.update.listen(this._update.bind(this));
32 this.actions.settings.remove.listen(this._remove.bind(this)); 29 this.actions.settings.remove.listen(this._remove.bind(this));
33
34 ipcRenderer.on('appSettings', (event, resp) => {
35 debug('Get appSettings resolves', resp.type, resp.data);
36
37 Object.assign(this._fileSystemSettingsCache[resp.type], resp.data);
38 });
39
40 this.fileSystemSettingsTypes.forEach((type) => {
41 ipcRenderer.send('getAppSettings', type);
42 });
43 } 30 }
44 31
45 async setup() { 32 async setup() {
@@ -101,27 +88,30 @@ export default class SettingsStore extends Store {
101 } 88 }
102 }); 89 });
103 90
104 // Make sure to lock app on launch if locking feature is enabled 91 ipcRenderer.on('appSettings', (event, resp) => {
105 setTimeout(() => { 92 // Lock on startup if enabled in settings
106 const isLoggedIn = Boolean(localStorage.getItem('authToken')); 93 if (this.startup && resp.type === 'app' && resp.data.lockingFeatureEnabled) {
107 if (isLoggedIn && this.all.app.lockingFeatureEnabled) { 94 this.startup = false;
108 // Disable lock first - otherwise the lock might not get activated corrently 95 process.nextTick(() => {
109 this.actions.settings.update({ 96 // If the app was previously closed unlocked
110 type: 'app', 97 // we can update the `locked` setting and rely on the reaction to lock at startup
111 data: { 98 if (!this.all.app.locked) {
112 locked: false, 99 this.all.app.locked = true;
113 }, 100 } else {
114 }); 101 // Otherwise the app previously closed in a locked state
115 setTimeout(() => { 102 // We can't rely on updating the locked setting for the reaction to be triggered
116 this.actions.settings.update({ 103 // So we lock manually
117 type: 'app', 104 window.ferdi.stores.router.push('/auth/locked');
118 data: { 105 }
119 locked: true, 106 })
120 },
121 });
122 }, 0);
123 } 107 }
124 }, 1000); 108 debug('Get appSettings resolves', resp.type, resp.data);
109 Object.assign(this._fileSystemSettingsCache[resp.type], resp.data);
110 });
111
112 this.fileSystemSettingsTypes.forEach((type) => {
113 ipcRenderer.send('getAppSettings', type);
114 });
125 } 115 }
126 116
127 @computed get app() { 117 @computed get app() {
@@ -250,5 +240,25 @@ export default class SettingsStore extends Store {
250 }, 240 },
251 }); 241 });
252 } 242 }
243
244 if (!this.all.migration['5.4.4-beta.2-settings']) {
245 const {
246 showServiceNavigationBar,
247 } = this.all.app;
248
249 this.actions.settings.update({
250 type: 'app',
251 data: {
252 navigationBarBehaviour: showServiceNavigationBar ? 'custom' : 'never',
253 },
254 });
255
256 this.actions.settings.update({
257 type: 'migration',
258 data: {
259 '5.4.4-beta.2-settings': true,
260 },
261 });
262 }
253 } 263 }
254} 264}