aboutsummaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/features')
-rw-r--r--src/features/serviceProxy/index.ts8
-rw-r--r--src/features/webControls/containers/WebControlsScreen.jsx (renamed from src/features/webControls/containers/WebControlsScreen.js)20
-rw-r--r--src/features/workspaces/store.js100
3 files changed, 80 insertions, 48 deletions
diff --git a/src/features/serviceProxy/index.ts b/src/features/serviceProxy/index.ts
index 51e67feca..eb3b89ece 100644
--- a/src/features/serviceProxy/index.ts
+++ b/src/features/serviceProxy/index.ts
@@ -1,4 +1,4 @@
1import { autorun, observable } from 'mobx'; 1import { autorun, action, observable } from 'mobx';
2import { session } from '@electron/remote'; 2import { session } from '@electron/remote';
3 3
4const debug = require('../../preload-safe-debug')( 4const debug = require('../../preload-safe-debug')(
@@ -15,8 +15,12 @@ export default function init(stores: {
15}) { 15}) {
16 debug('Initializing `serviceProxy` feature'); 16 debug('Initializing `serviceProxy` feature');
17 17
18 const setIsEnabled = action((value: boolean) => {
19 config.isEnabled = value;
20 });
21
18 autorun(() => { 22 autorun(() => {
19 config.isEnabled = true; 23 setIsEnabled(true);
20 24
21 const services = stores.services.enabled; 25 const services = stores.services.enabled;
22 const proxySettings = stores.settings.proxy; 26 const proxySettings = stores.settings.proxy;
diff --git a/src/features/webControls/containers/WebControlsScreen.js b/src/features/webControls/containers/WebControlsScreen.jsx
index e5567eec5..25e14060d 100644
--- a/src/features/webControls/containers/WebControlsScreen.js
+++ b/src/features/webControls/containers/WebControlsScreen.jsx
@@ -2,7 +2,7 @@ import { Component } from 'react';
2import { observer, inject } from 'mobx-react'; 2import { observer, inject } from 'mobx-react';
3import PropTypes from 'prop-types'; 3import PropTypes from 'prop-types';
4 4
5import { autorun, makeObservable, observable } from 'mobx'; 5import { autorun, action, makeObservable, observable } from 'mobx';
6import WebControls from '../components/WebControls'; 6import WebControls from '../components/WebControls';
7import ServicesStore from '../../../stores/ServicesStore'; 7import ServicesStore from '../../../stores/ServicesStore';
8import Service from '../../../models/Service'; 8import Service from '../../../models/Service';
@@ -27,6 +27,16 @@ class WebControlsScreen extends Component {
27 27
28 autorunDisposer = null; 28 autorunDisposer = null;
29 29
30 @action _setUrl(value) {
31 this.url = value;
32 }
33
34 @action _setUrlAndHistory(value) {
35 this._setUrl(value);
36 this.canGoBack = this.webview.canGoBack();
37 this.canGoForward = this.webview.canGoForward();
38 }
39
30 constructor(props) { 40 constructor(props) {
31 super(props); 41 super(props);
32 42
@@ -39,15 +49,13 @@ class WebControlsScreen extends Component {
39 this.autorunDisposer = autorun(() => { 49 this.autorunDisposer = autorun(() => {
40 if (service.isAttached) { 50 if (service.isAttached) {
41 this.webview = service.webview; 51 this.webview = service.webview;
42 this.url = this.webview.getURL(); 52 this._setUrl(this.webview.getURL());
43 53
44 for (const event of URL_EVENTS) { 54 for (const event of URL_EVENTS) {
45 this.webview.addEventListener(event, e => { 55 this.webview.addEventListener(event, e => {
46 if (!e.isMainFrame) return; 56 if (!e.isMainFrame) return;
47 57
48 this.url = e.url; 58 this._setUrlAndHistory(e.url);
49 this.canGoBack = this.webview.canGoBack();
50 this.canGoForward = this.webview.canGoForward();
51 }); 59 });
52 } 60 }
53 } 61 }
@@ -101,7 +109,7 @@ class WebControlsScreen extends Component {
101 } 109 }
102 110
103 this.webview.loadURL(url); 111 this.webview.loadURL(url);
104 this.url = url; 112 this._setUrl(url);
105 } 113 }
106 114
107 openInBrowser() { 115 openInBrowser() {
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js
index a8fb493df..2323019fe 100644
--- a/src/features/workspaces/store.js
+++ b/src/features/workspaces/store.js
@@ -90,7 +90,7 @@ export default class WorkspacesStore extends FeatureStore {
90 [workspaceActions.create, this._create], 90 [workspaceActions.create, this._create],
91 [workspaceActions.delete, this._delete], 91 [workspaceActions.delete, this._delete],
92 [workspaceActions.update, this._update], 92 [workspaceActions.update, this._update],
93 [workspaceActions.activate, this._setActiveWorkspace], 93 [workspaceActions.activate, this._setActivateWorkspace],
94 [workspaceActions.deactivate, this._deactivateActiveWorkspace], 94 [workspaceActions.deactivate, this._deactivateActiveWorkspace],
95 [ 95 [
96 workspaceActions.toggleKeepAllWorkspacesLoadedSetting, 96 workspaceActions.toggleKeepAllWorkspacesLoadedSetting,
@@ -114,10 +114,10 @@ export default class WorkspacesStore extends FeatureStore {
114 } 114 }
115 115
116 @action reset() { 116 @action reset() {
117 this.activeWorkspace = null; 117 this._setActiveWorkspace(null);
118 this.nextWorkspace = null; 118 this._setNextWorkspace(null);
119 this.workspaceBeingEdited = null; 119 this.workspaceBeingEdited = null;
120 this.isSwitchingWorkspace = false; 120 this._setIsSwitchingWorkspace(false);
121 this.isWorkspaceDrawerOpen = false; 121 this.isWorkspaceDrawerOpen = false;
122 } 122 }
123 123
@@ -181,19 +181,31 @@ export default class WorkspacesStore extends FeatureStore {
181 this.stores.router.push('/settings/workspaces'); 181 this.stores.router.push('/settings/workspaces');
182 }; 182 };
183 183
184 @action _setActiveWorkspace = ({ workspace }) => { 184 @action _setNextWorkspace(workspace) {
185 // Indicate that we are switching to another workspace
186 this.isSwitchingWorkspace = true;
187 this.nextWorkspace = workspace; 185 this.nextWorkspace = workspace;
186 }
187
188 @action _setIsSwitchingWorkspace(bool) {
189 this.isSwitchingWorkspace = bool;
190 }
191
192 @action _setActiveWorkspace(workspace) {
193 this.activeWorkspace = workspace;
194 }
195
196 @action _setActivateWorkspace = ({ workspace }) => {
197 // Indicate that we are switching to another workspace
198 this._setIsSwitchingWorkspace(true);
199 this._setNextWorkspace(workspace);
188 // Delay switching to next workspace so that the services loading does not drag down UI 200 // Delay switching to next workspace so that the services loading does not drag down UI
189 setTimeout(() => { 201 setTimeout(() => {
190 this.activeWorkspace = workspace; 202 this._setActiveWorkspace(workspace);
191 this._updateSettings({ lastActiveWorkspace: workspace.id }); 203 this._updateSettings({ lastActiveWorkspace: workspace.id });
192 }, 100); 204 }, 100);
193 // Indicate that we are done switching to the next workspace 205 // Indicate that we are done switching to the next workspace
194 setTimeout(() => { 206 setTimeout(() => {
195 this.isSwitchingWorkspace = false; 207 this._setIsSwitchingWorkspace(false);
196 this.nextWorkspace = null; 208 this._setNextWorkspace(null);
197 if (this.stores.settings.app.splitMode) { 209 if (this.stores.settings.app.splitMode) {
198 const serviceNames = new Set( 210 const serviceNames = new Set(
199 this.getWorkspaceServices(workspace).map(service => service.name), 211 this.getWorkspaceServices(workspace).map(service => service.name),
@@ -211,16 +223,16 @@ export default class WorkspacesStore extends FeatureStore {
211 223
212 @action _deactivateActiveWorkspace = () => { 224 @action _deactivateActiveWorkspace = () => {
213 // Indicate that we are switching to default workspace 225 // Indicate that we are switching to default workspace
214 this.isSwitchingWorkspace = true; 226 this._setIsSwitchingWorkspace(true);
215 this.nextWorkspace = null; 227 this._setNextWorkspace(null);
216 this._updateSettings({ lastActiveWorkspace: null }); 228 this._updateSettings({ lastActiveWorkspace: null });
217 // Delay switching to next workspace so that the services loading does not drag down UI 229 // Delay switching to next workspace so that the services loading does not drag down UI
218 setTimeout(() => { 230 setTimeout(() => {
219 this.activeWorkspace = null; 231 this._setActiveWorkspace(null);
220 }, 100); 232 }, 100);
221 // Indicate that we are done switching to the default workspace 233 // Indicate that we are done switching to the default workspace
222 setTimeout(() => { 234 setTimeout(() => {
223 this.isSwitchingWorkspace = false; 235 this._setIsSwitchingWorkspace(false);
224 if (this.stores.settings.app.splitMode) { 236 if (this.stores.settings.app.splitMode) {
225 for (const wrapper of document.querySelectorAll( 237 for (const wrapper of document.querySelectorAll(
226 '.services__webview-wrapper', 238 '.services__webview-wrapper',
@@ -247,6 +259,37 @@ export default class WorkspacesStore extends FeatureStore {
247 await updateWorkspaceRequest.execute(activeWorkspace); 259 await updateWorkspaceRequest.execute(activeWorkspace);
248 }; 260 };
249 261
262 @action _setOpenDrawerWithSettings() {
263 const { router } = this.stores;
264 const isWorkspaceSettingsRoute = router.location.pathname.includes(
265 WORKSPACES_ROUTES.ROOT,
266 );
267 const isSwitchingToSettingsRoute =
268 !this.isSettingsRouteActive && isWorkspaceSettingsRoute;
269 const isLeavingSettingsRoute =
270 !isWorkspaceSettingsRoute && this.isSettingsRouteActive;
271
272 if (isSwitchingToSettingsRoute) {
273 this.isSettingsRouteActive = true;
274 this._wasDrawerOpenBeforeSettingsRoute = this.isWorkspaceDrawerOpen;
275 if (!this._wasDrawerOpenBeforeSettingsRoute) {
276 workspaceActions.toggleWorkspaceDrawer();
277 }
278 } else if (isLeavingSettingsRoute) {
279 this.isSettingsRouteActive = false;
280 if (
281 !this._wasDrawerOpenBeforeSettingsRoute &&
282 this.isWorkspaceDrawerOpen
283 ) {
284 workspaceActions.toggleWorkspaceDrawer();
285 }
286 }
287 }
288
289 @action _setWorkspaceBeingEdited(match) {
290 this.workspaceBeingEdited = this._getWorkspaceById(match.id);
291 }
292
250 _toggleKeepAllWorkspacesLoadedSetting = async () => { 293 _toggleKeepAllWorkspacesLoadedSetting = async () => {
251 this._updateSettings({ 294 this._updateSettings({
252 keepAllWorkspacesLoaded: !this.settings.keepAllWorkspacesLoaded, 295 keepAllWorkspacesLoaded: !this.settings.keepAllWorkspacesLoaded,
@@ -259,7 +302,7 @@ export default class WorkspacesStore extends FeatureStore {
259 const { pathname } = this.stores.router.location; 302 const { pathname } = this.stores.router.location;
260 const match = matchRoute('/settings/workspaces/edit/:id', pathname); 303 const match = matchRoute('/settings/workspaces/edit/:id', pathname);
261 if (match) { 304 if (match) {
262 this.workspaceBeingEdited = this._getWorkspaceById(match.id); 305 this._setWorkspaceBeingEdited(match);
263 } 306 }
264 }; 307 };
265 308
@@ -286,36 +329,13 @@ export default class WorkspacesStore extends FeatureStore {
286 const { lastActiveWorkspace } = this.settings; 329 const { lastActiveWorkspace } = this.settings;
287 if (lastActiveWorkspace) { 330 if (lastActiveWorkspace) {
288 const workspace = this._getWorkspaceById(lastActiveWorkspace); 331 const workspace = this._getWorkspaceById(lastActiveWorkspace);
289 if (workspace) this._setActiveWorkspace({ workspace }); 332 if (workspace) this._setActivateWorkspace({ workspace });
290 } 333 }
291 } 334 }
292 }; 335 };
293 336
294 _openDrawerWithSettingsReaction = () => { 337 _openDrawerWithSettingsReaction = () => {
295 const { router } = this.stores; 338 this._setOpenDrawerWithSettings();
296 const isWorkspaceSettingsRoute = router.location.pathname.includes(
297 WORKSPACES_ROUTES.ROOT,
298 );
299 const isSwitchingToSettingsRoute =
300 !this.isSettingsRouteActive && isWorkspaceSettingsRoute;
301 const isLeavingSettingsRoute =
302 !isWorkspaceSettingsRoute && this.isSettingsRouteActive;
303
304 if (isSwitchingToSettingsRoute) {
305 this.isSettingsRouteActive = true;
306 this._wasDrawerOpenBeforeSettingsRoute = this.isWorkspaceDrawerOpen;
307 if (!this._wasDrawerOpenBeforeSettingsRoute) {
308 workspaceActions.toggleWorkspaceDrawer();
309 }
310 } else if (isLeavingSettingsRoute) {
311 this.isSettingsRouteActive = false;
312 if (
313 !this._wasDrawerOpenBeforeSettingsRoute &&
314 this.isWorkspaceDrawerOpen
315 ) {
316 workspaceActions.toggleWorkspaceDrawer();
317 }
318 }
319 }; 339 };
320 340
321 _cleanupInvalidServiceReferences = () => { 341 _cleanupInvalidServiceReferences = () => {