diff options
Diffstat (limited to 'src/features/workspaces/index.js')
-rw-r--r-- | src/features/workspaces/index.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/features/workspaces/index.js b/src/features/workspaces/index.js new file mode 100644 index 000000000..ad9023b8b --- /dev/null +++ b/src/features/workspaces/index.js | |||
@@ -0,0 +1,37 @@ | |||
1 | import { reaction } from 'mobx'; | ||
2 | import WorkspacesStore from './store'; | ||
3 | import { resetApiRequests } from './api'; | ||
4 | |||
5 | const debug = require('debug')('Franz:feature:workspaces'); | ||
6 | |||
7 | export const GA_CATEGORY_WORKSPACES = 'Workspaces'; | ||
8 | |||
9 | export const workspaceStore = new WorkspacesStore(); | ||
10 | |||
11 | export default function initWorkspaces(stores, actions) { | ||
12 | stores.workspaces = workspaceStore; | ||
13 | const { features } = stores; | ||
14 | |||
15 | // Toggle workspace feature | ||
16 | reaction( | ||
17 | () => features.features.isWorkspaceEnabled, | ||
18 | (isEnabled) => { | ||
19 | if (isEnabled && !workspaceStore.isFeatureActive) { | ||
20 | debug('Initializing `workspaces` feature'); | ||
21 | workspaceStore.start(stores, actions); | ||
22 | } else if (workspaceStore.isFeatureActive) { | ||
23 | debug('Disabling `workspaces` feature'); | ||
24 | workspaceStore.stop(); | ||
25 | resetApiRequests(); | ||
26 | } | ||
27 | }, | ||
28 | { | ||
29 | fireImmediately: true, | ||
30 | }, | ||
31 | ); | ||
32 | } | ||
33 | |||
34 | export const WORKSPACES_ROUTES = { | ||
35 | ROOT: '/settings/workspaces', | ||
36 | EDIT: '/settings/workspaces/:action/:id', | ||
37 | }; | ||