diff options
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 9 | ||||
-rw-r--r-- | src/stores/FeaturesStore.js | 4 | ||||
-rw-r--r-- | src/stores/PaymentStore.js | 17 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 24 | ||||
-rw-r--r-- | src/stores/UserStore.js | 1 | ||||
-rw-r--r-- | src/stores/index.js | 4 | ||||
-rw-r--r-- | src/stores/lib/Reaction.js | 19 |
7 files changed, 49 insertions, 29 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 351ad6422..72c4b4d0b 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -14,7 +14,7 @@ import Request from './lib/Request'; | |||
14 | import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; | 14 | import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; |
15 | import { isMac } from '../environment'; | 15 | import { isMac } from '../environment'; |
16 | import locales from '../i18n/translations'; | 16 | import locales from '../i18n/translations'; |
17 | import { gaEvent, gaPage } from '../lib/analytics'; | 17 | import { gaEvent, gaPage, statsEvent } from '../lib/analytics'; |
18 | import { onVisibilityChange } from '../helpers/visibility-helper'; | 18 | import { onVisibilityChange } from '../helpers/visibility-helper'; |
19 | import { getLocale } from '../helpers/i18n-helpers'; | 19 | import { getLocale } from '../helpers/i18n-helpers'; |
20 | 20 | ||
@@ -67,6 +67,8 @@ export default class AppStore extends Store { | |||
67 | 67 | ||
68 | @observable isFocused = true; | 68 | @observable isFocused = true; |
69 | 69 | ||
70 | @observable nextAppReleaseVersion = null; | ||
71 | |||
70 | dictionaries = []; | 72 | dictionaries = []; |
71 | 73 | ||
72 | constructor(...args) { | 74 | constructor(...args) { |
@@ -123,7 +125,7 @@ export default class AppStore extends Store { | |||
123 | ipcRenderer.on('autoUpdate', (event, data) => { | 125 | ipcRenderer.on('autoUpdate', (event, data) => { |
124 | if (data.available) { | 126 | if (data.available) { |
125 | this.updateStatus = this.updateStatusTypes.AVAILABLE; | 127 | this.updateStatus = this.updateStatusTypes.AVAILABLE; |
126 | 128 | this.nextAppReleaseVersion = data.version; | |
127 | if (isMac) { | 129 | if (isMac) { |
128 | app.dock.bounce(); | 130 | app.dock.bounce(); |
129 | } | 131 | } |
@@ -172,7 +174,8 @@ export default class AppStore extends Store { | |||
172 | reaction(() => this.stores.router.location.pathname, (pathname) => { | 174 | reaction(() => this.stores.router.location.pathname, (pathname) => { |
173 | gaPage(pathname); | 175 | gaPage(pathname); |
174 | }); | 176 | }); |
175 | console.log('router location', this.stores.router.location); | 177 | |
178 | statsEvent('app-start'); | ||
176 | } | 179 | } |
177 | 180 | ||
178 | @computed get cacheSize() { | 181 | @computed get cacheSize() { |
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js index 8fe576813..e7832088b 100644 --- a/src/stores/FeaturesStore.js +++ b/src/stores/FeaturesStore.js | |||
@@ -14,6 +14,8 @@ import serviceProxy from '../features/serviceProxy'; | |||
14 | import basicAuth from '../features/basicAuth'; | 14 | import basicAuth from '../features/basicAuth'; |
15 | import workspaces from '../features/workspaces'; | 15 | import workspaces from '../features/workspaces'; |
16 | import shareFranz from '../features/shareFranz'; | 16 | import shareFranz from '../features/shareFranz'; |
17 | import announcements from '../features/announcements'; | ||
18 | import settingsWS from '../features/settingsWS'; | ||
17 | 19 | ||
18 | import { DEFAULT_FEATURES_CONFIG } from '../config'; | 20 | import { DEFAULT_FEATURES_CONFIG } from '../config'; |
19 | 21 | ||
@@ -71,5 +73,7 @@ export default class FeaturesStore extends Store { | |||
71 | basicAuth(this.stores, this.actions); | 73 | basicAuth(this.stores, this.actions); |
72 | workspaces(this.stores, this.actions); | 74 | workspaces(this.stores, this.actions); |
73 | shareFranz(this.stores, this.actions); | 75 | shareFranz(this.stores, this.actions); |
76 | announcements(this.stores, this.actions); | ||
77 | settingsWS(this.stores, this.actions); | ||
74 | } | 78 | } |
75 | } | 79 | } |
diff --git a/src/stores/PaymentStore.js b/src/stores/PaymentStore.js index 4cabee194..d4de476c8 100644 --- a/src/stores/PaymentStore.js +++ b/src/stores/PaymentStore.js | |||
@@ -10,15 +10,10 @@ export default class PaymentStore extends Store { | |||
10 | 10 | ||
11 | @observable createHostedPageRequest = new Request(this.api.payment, 'getHostedPage'); | 11 | @observable createHostedPageRequest = new Request(this.api.payment, 'getHostedPage'); |
12 | 12 | ||
13 | @observable createDashboardUrlRequest = new Request(this.api.payment, 'getDashboardUrl'); | ||
14 | |||
15 | @observable ordersDataRequest = new CachedRequest(this.api.payment, 'getOrders'); | ||
16 | |||
17 | constructor(...args) { | 13 | constructor(...args) { |
18 | super(...args); | 14 | super(...args); |
19 | 15 | ||
20 | this.actions.payment.createHostedPage.listen(this._createHostedPage.bind(this)); | 16 | this.actions.payment.createHostedPage.listen(this._createHostedPage.bind(this)); |
21 | this.actions.payment.createDashboardUrl.listen(this._createDashboardUrl.bind(this)); | ||
22 | } | 17 | } |
23 | 18 | ||
24 | @computed get plan() { | 19 | @computed get plan() { |
@@ -28,10 +23,6 @@ export default class PaymentStore extends Store { | |||
28 | return this.plansRequest.execute().result || {}; | 23 | return this.plansRequest.execute().result || {}; |
29 | } | 24 | } |
30 | 25 | ||
31 | @computed get orders() { | ||
32 | return this.ordersDataRequest.execute().result || []; | ||
33 | } | ||
34 | |||
35 | @action _createHostedPage({ planId }) { | 26 | @action _createHostedPage({ planId }) { |
36 | const request = this.createHostedPageRequest.execute(planId); | 27 | const request = this.createHostedPageRequest.execute(planId); |
37 | 28 | ||
@@ -39,12 +30,4 @@ export default class PaymentStore extends Store { | |||
39 | 30 | ||
40 | return request; | 31 | return request; |
41 | } | 32 | } |
42 | |||
43 | @action _createDashboardUrl() { | ||
44 | const request = this.createDashboardUrlRequest.execute(); | ||
45 | |||
46 | gaEvent('Payment', 'createDashboardUrl'); | ||
47 | |||
48 | return request; | ||
49 | } | ||
50 | } | 33 | } |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 0ec6bf550..d63302fce 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -11,7 +11,7 @@ import Store from './lib/Store'; | |||
11 | import Request from './lib/Request'; | 11 | import Request from './lib/Request'; |
12 | import CachedRequest from './lib/CachedRequest'; | 12 | import CachedRequest from './lib/CachedRequest'; |
13 | import { matchRoute } from '../helpers/routing-helpers'; | 13 | import { matchRoute } from '../helpers/routing-helpers'; |
14 | import { gaEvent } from '../lib/analytics'; | 14 | import { gaEvent, statsEvent } from '../lib/analytics'; |
15 | import { workspaceStore } from '../features/workspaces'; | 15 | import { workspaceStore } from '../features/workspaces'; |
16 | 16 | ||
17 | const debug = require('debug')('Franz:ServiceStore'); | 17 | const debug = require('debug')('Franz:ServiceStore'); |
@@ -36,6 +36,7 @@ export default class ServicesStore extends Store { | |||
36 | 36 | ||
37 | // Register action handlers | 37 | // Register action handlers |
38 | this.actions.service.setActive.listen(this._setActive.bind(this)); | 38 | this.actions.service.setActive.listen(this._setActive.bind(this)); |
39 | this.actions.service.blurActive.listen(this._blurActive.bind(this)); | ||
39 | this.actions.service.setActiveNext.listen(this._setActiveNext.bind(this)); | 40 | this.actions.service.setActiveNext.listen(this._setActiveNext.bind(this)); |
40 | this.actions.service.setActivePrev.listen(this._setActivePrev.bind(this)); | 41 | this.actions.service.setActivePrev.listen(this._setActivePrev.bind(this)); |
41 | this.actions.service.showAddServiceInterface.listen(this._showAddServiceInterface.bind(this)); | 42 | this.actions.service.showAddServiceInterface.listen(this._showAddServiceInterface.bind(this)); |
@@ -290,7 +291,8 @@ export default class ServicesStore extends Store { | |||
290 | gaEvent('Service', 'clear cache'); | 291 | gaEvent('Service', 'clear cache'); |
291 | } | 292 | } |
292 | 293 | ||
293 | @action _setActive({ serviceId }) { | 294 | @action _setActive({ serviceId, keepActiveRoute }) { |
295 | if (!keepActiveRoute) this.stores.router.push('/'); | ||
294 | const service = this.one(serviceId); | 296 | const service = this.one(serviceId); |
295 | 297 | ||
296 | this.all.forEach((s, index) => { | 298 | this.all.forEach((s, index) => { |
@@ -298,9 +300,16 @@ export default class ServicesStore extends Store { | |||
298 | }); | 300 | }); |
299 | service.isActive = true; | 301 | service.isActive = true; |
300 | 302 | ||
303 | statsEvent('activate-service', service.recipe.id); | ||
304 | |||
301 | this._focusActiveService(); | 305 | this._focusActiveService(); |
302 | } | 306 | } |
303 | 307 | ||
308 | @action _blurActive() { | ||
309 | if (!this.active) return; | ||
310 | this.active.isActive = false; | ||
311 | } | ||
312 | |||
304 | @action _setActiveNext() { | 313 | @action _setActiveNext() { |
305 | const nextIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), 1, this.allDisplayed.length); | 314 | const nextIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), 1, this.allDisplayed.length); |
306 | 315 | ||
@@ -509,7 +518,16 @@ export default class ServicesStore extends Store { | |||
509 | this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); | 518 | this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); |
510 | } | 519 | } |
511 | 520 | ||
512 | @action _reorder({ oldIndex, newIndex }) { | 521 | @action _reorder(params) { |
522 | const { workspaces } = this.stores; | ||
523 | if (workspaces.isAnyWorkspaceActive) { | ||
524 | workspaces.reorderServicesOfActiveWorkspace(params); | ||
525 | } else { | ||
526 | this._reorderService(params); | ||
527 | } | ||
528 | } | ||
529 | |||
530 | @action _reorderService({ oldIndex, newIndex }) { | ||
513 | const showDisabledServices = this.stores.settings.all.app.showDisabledServices; | 531 | const showDisabledServices = this.stores.settings.all.app.showDisabledServices; |
514 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); | 532 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); |
515 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); | 533 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); |
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 534690fbb..31555dd5c 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -178,6 +178,7 @@ export default class UserStore extends Store { | |||
178 | password, | 178 | password, |
179 | accountType, | 179 | accountType, |
180 | company, | 180 | company, |
181 | locale: this.stores.app.locale, | ||
181 | }); | 182 | }); |
182 | 183 | ||
183 | this.hasCompletedSignup = false; | 184 | this.hasCompletedSignup = false; |
diff --git a/src/stores/index.js b/src/stores/index.js index 96b844c95..1912418a2 100644 --- a/src/stores/index.js +++ b/src/stores/index.js | |||
@@ -10,6 +10,8 @@ import PaymentStore from './PaymentStore'; | |||
10 | import NewsStore from './NewsStore'; | 10 | import NewsStore from './NewsStore'; |
11 | import RequestStore from './RequestStore'; | 11 | import RequestStore from './RequestStore'; |
12 | import GlobalErrorStore from './GlobalErrorStore'; | 12 | import GlobalErrorStore from './GlobalErrorStore'; |
13 | import { workspaceStore } from '../features/workspaces'; | ||
14 | import { announcementsStore } from '../features/announcements'; | ||
13 | 15 | ||
14 | export default (api, actions, router) => { | 16 | export default (api, actions, router) => { |
15 | const stores = {}; | 17 | const stores = {}; |
@@ -27,6 +29,8 @@ export default (api, actions, router) => { | |||
27 | news: new NewsStore(stores, api, actions), | 29 | news: new NewsStore(stores, api, actions), |
28 | requests: new RequestStore(stores, api, actions), | 30 | requests: new RequestStore(stores, api, actions), |
29 | globalError: new GlobalErrorStore(stores, api, actions), | 31 | globalError: new GlobalErrorStore(stores, api, actions), |
32 | workspaces: workspaceStore, | ||
33 | announcements: announcementsStore, | ||
30 | }); | 34 | }); |
31 | // Initialize all stores | 35 | // Initialize all stores |
32 | Object.keys(stores).forEach((name) => { | 36 | Object.keys(stores).forEach((name) => { |
diff --git a/src/stores/lib/Reaction.js b/src/stores/lib/Reaction.js index 46aa4dae6..f2642908f 100644 --- a/src/stores/lib/Reaction.js +++ b/src/stores/lib/Reaction.js | |||
@@ -1,24 +1,31 @@ | |||
1 | // @flow | ||
2 | import { autorun } from 'mobx'; | 1 | import { autorun } from 'mobx'; |
3 | 2 | ||
4 | export default class Reaction { | 3 | export default class Reaction { |
5 | reaction; | 4 | reaction; |
6 | 5 | ||
7 | hasBeenStarted; | 6 | isRunning = false; |
8 | 7 | ||
9 | dispose; | 8 | dispose; |
10 | 9 | ||
11 | constructor(reaction) { | 10 | constructor(reaction) { |
12 | this.reaction = reaction; | 11 | this.reaction = reaction; |
13 | this.hasBeenStarted = false; | ||
14 | } | 12 | } |
15 | 13 | ||
16 | start() { | 14 | start() { |
17 | this.dispose = autorun(() => this.reaction()); | 15 | if (!this.isRunning) { |
18 | this.hasBeenStarted = true; | 16 | this.dispose = autorun(() => this.reaction()); |
17 | this.isActive = true; | ||
18 | } | ||
19 | } | 19 | } |
20 | 20 | ||
21 | stop() { | 21 | stop() { |
22 | if (this.hasBeenStarted) this.dispose(); | 22 | if (this.isRunning) { |
23 | this.dispose(); | ||
24 | this.isActive = false; | ||
25 | } | ||
23 | } | 26 | } |
24 | } | 27 | } |
28 | |||
29 | export const createReactions = reactions => ( | ||
30 | reactions.map(r => new Reaction(r)) | ||
31 | ); | ||