aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/ServicesStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r--src/stores/ServicesStore.js32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 13f929c2f..109ac5cd7 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -148,18 +148,7 @@ export default class ServicesStore extends Store {
148 } 148 }
149 149
150 async _showAddServiceInterface({ recipeId }) { 150 async _showAddServiceInterface({ recipeId }) {
151 const recipesStore = this.stores.recipes; 151 this.stores.router.push(`/settings/services/add/${recipeId}`);
152
153 if (recipesStore.isInstalled(recipeId)) {
154 debug(`Recipe ${recipeId} is installed`);
155 this._redirectToAddServiceRoute(recipeId);
156 } else {
157 debug(`Recipe ${recipeId} is not installed`);
158 // We access the RecipeStore action directly
159 // returns Promise instead of action
160 await this.stores.recipes._install({ recipeId });
161 this._redirectToAddServiceRoute(recipeId);
162 }
163 } 152 }
164 153
165 // Actions 154 // Actions
@@ -291,7 +280,8 @@ export default class ServicesStore extends Store {
291 gaEvent('Service', 'clear cache'); 280 gaEvent('Service', 'clear cache');
292 } 281 }
293 282
294 @action _setActive({ serviceId }) { 283 @action _setActive({ serviceId, keepActiveRoute }) {
284 if (!keepActiveRoute) this.stores.router.push('/');
295 const service = this.one(serviceId); 285 const service = this.one(serviceId);
296 286
297 this.all.forEach((s, index) => { 287 this.all.forEach((s, index) => {
@@ -517,7 +507,16 @@ export default class ServicesStore extends Store {
517 this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); 507 this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false });
518 } 508 }
519 509
520 @action _reorder({ oldIndex, newIndex }) { 510 @action _reorder(params) {
511 const { workspaces } = this.stores;
512 if (workspaces.isAnyWorkspaceActive) {
513 workspaces.reorderServicesOfActiveWorkspace(params);
514 } else {
515 this._reorderService(params);
516 }
517 }
518
519 @action _reorderService({ oldIndex, newIndex }) {
521 const showDisabledServices = this.stores.settings.all.app.showDisabledServices; 520 const showDisabledServices = this.stores.settings.all.app.showDisabledServices;
522 const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); 521 const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]);
523 const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); 522 const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]);
@@ -680,11 +679,6 @@ export default class ServicesStore extends Store {
680 } 679 }
681 680
682 // Helper 681 // Helper
683 _redirectToAddServiceRoute(recipeId) {
684 const route = `/settings/services/add/${recipeId}`;
685 this.stores.router.push(route);
686 }
687
688 _initializeServiceRecipeInWebview(serviceId) { 682 _initializeServiceRecipeInWebview(serviceId) {
689 const service = this.one(serviceId); 683 const service = this.one(serviceId);
690 684