diff options
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r-- | src/stores/ServicesStore.js | 24 |
1 files changed, 21 insertions, 3 deletions
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]); |