diff options
-rw-r--r-- | src/app.js | 5 | ||||
-rw-r--r-- | src/features/workspaces/index.js | 5 | ||||
-rw-r--r-- | src/features/workspaces/store.js | 26 |
3 files changed, 34 insertions, 2 deletions
diff --git a/src/app.js b/src/app.js index d3b540f62..fb9f1c6ab 100644 --- a/src/app.js +++ b/src/app.js | |||
@@ -41,6 +41,7 @@ import AuthLayoutContainer from './containers/auth/AuthLayoutContainer'; | |||
41 | import SubscriptionPopupScreen from './containers/subscription/SubscriptionPopupScreen'; | 41 | import SubscriptionPopupScreen from './containers/subscription/SubscriptionPopupScreen'; |
42 | import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen'; | 42 | import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen'; |
43 | import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen'; | 43 | import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen'; |
44 | import { WORKSPACES_ROUTES } from './features/workspaces'; | ||
44 | 45 | ||
45 | // Add Polyfills | 46 | // Add Polyfills |
46 | smoothScroll.polyfill(); | 47 | smoothScroll.polyfill(); |
@@ -77,8 +78,8 @@ window.addEventListener('load', () => { | |||
77 | <Route path="/settings/recipes/:filter" component={RecipesScreen} /> | 78 | <Route path="/settings/recipes/:filter" component={RecipesScreen} /> |
78 | <Route path="/settings/services" component={ServicesScreen} /> | 79 | <Route path="/settings/services" component={ServicesScreen} /> |
79 | <Route path="/settings/services/:action/:id" component={EditServiceScreen} /> | 80 | <Route path="/settings/services/:action/:id" component={EditServiceScreen} /> |
80 | <Route path="/settings/workspaces" component={WorkspacesScreen} /> | 81 | <Route path={WORKSPACES_ROUTES.ROOT} component={WorkspacesScreen} /> |
81 | <Route path="/settings/workspaces/:action/:id" component={EditWorkspaceScreen} /> | 82 | <Route path={WORKSPACES_ROUTES.EDIT} component={EditWorkspaceScreen} /> |
82 | <Route path="/settings/user" component={AccountScreen} /> | 83 | <Route path="/settings/user" component={AccountScreen} /> |
83 | <Route path="/settings/user/edit" component={EditUserScreen} /> | 84 | <Route path="/settings/user/edit" component={EditUserScreen} /> |
84 | <Route path="/settings/app" component={EditSettingsScreen} /> | 85 | <Route path="/settings/app" component={EditSettingsScreen} /> |
diff --git a/src/features/workspaces/index.js b/src/features/workspaces/index.js index fb5135743..ad9023b8b 100644 --- a/src/features/workspaces/index.js +++ b/src/features/workspaces/index.js | |||
@@ -30,3 +30,8 @@ export default function initWorkspaces(stores, actions) { | |||
30 | }, | 30 | }, |
31 | ); | 31 | ); |
32 | } | 32 | } |
33 | |||
34 | export const WORKSPACES_ROUTES = { | ||
35 | ROOT: '/settings/workspaces', | ||
36 | EDIT: '/settings/workspaces/:action/:id', | ||
37 | }; | ||
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index 7bd969be0..2e1764f99 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js | |||
@@ -13,6 +13,7 @@ import { | |||
13 | getUserWorkspacesRequest, | 13 | getUserWorkspacesRequest, |
14 | updateWorkspaceRequest, | 14 | updateWorkspaceRequest, |
15 | } from './api'; | 15 | } from './api'; |
16 | import { WORKSPACES_ROUTES } from './index'; | ||
16 | 17 | ||
17 | const debug = require('debug')('Franz:feature:workspaces:store'); | 18 | const debug = require('debug')('Franz:feature:workspaces:store'); |
18 | 19 | ||
@@ -70,6 +71,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
70 | this._setFeatureEnabledReaction, | 71 | this._setFeatureEnabledReaction, |
71 | this._setIsPremiumFeatureReaction, | 72 | this._setIsPremiumFeatureReaction, |
72 | this._activateLastUsedWorkspaceReaction, | 73 | this._activateLastUsedWorkspaceReaction, |
74 | this._openDrawerWithSettingsReaction, | ||
73 | ]); | 75 | ]); |
74 | 76 | ||
75 | getUserWorkspacesRequest.execute(); | 77 | getUserWorkspacesRequest.execute(); |
@@ -100,6 +102,10 @@ export default class WorkspacesStore extends FeatureStore { | |||
100 | 102 | ||
101 | // ========== PRIVATE ========= // | 103 | // ========== PRIVATE ========= // |
102 | 104 | ||
105 | _wasDrawerOpenBeforeSettingsRoute = null; | ||
106 | |||
107 | _isSettingsRouteActive = null; | ||
108 | |||
103 | _getWorkspaceById = id => this.workspaces.find(w => w.id === id); | 109 | _getWorkspaceById = id => this.workspaces.find(w => w.id === id); |
104 | 110 | ||
105 | _updateSettings = (changes) => { | 111 | _updateSettings = (changes) => { |
@@ -229,4 +235,24 @@ export default class WorkspacesStore extends FeatureStore { | |||
229 | } | 235 | } |
230 | } | 236 | } |
231 | }; | 237 | }; |
238 | |||
239 | _openDrawerWithSettingsReaction = () => { | ||
240 | const { router } = this.stores; | ||
241 | const isWorkspaceSettingsRoute = router.location.pathname.includes(WORKSPACES_ROUTES.ROOT); | ||
242 | const isSwitchingToSettingsRoute = !this._isSettingsRouteActive && isWorkspaceSettingsRoute; | ||
243 | const isLeavingSettingsRoute = !isWorkspaceSettingsRoute && this._isSettingsRouteActive; | ||
244 | |||
245 | if (isSwitchingToSettingsRoute) { | ||
246 | this._isSettingsRouteActive = true; | ||
247 | this._wasDrawerOpenBeforeSettingsRoute = this.isWorkspaceDrawerOpen; | ||
248 | if (!this._wasDrawerOpenBeforeSettingsRoute) { | ||
249 | workspaceActions.toggleWorkspaceDrawer(); | ||
250 | } | ||
251 | } else if (isLeavingSettingsRoute) { | ||
252 | this._isSettingsRouteActive = false; | ||
253 | if (!this._wasDrawerOpenBeforeSettingsRoute && this.isWorkspaceDrawerOpen) { | ||
254 | workspaceActions.toggleWorkspaceDrawer(); | ||
255 | } | ||
256 | } | ||
257 | }; | ||
232 | } | 258 | } |