aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/ServicesStore.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-06-13 13:22:27 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-06-13 13:22:27 +0200
commitf65677735b02326870ada2100b55222fa69a401d (patch)
tree53adfc38c0a493e5e8fef3211d0e82b7d164d9ff /src/stores/ServicesStore.js
parentEnforce service limit (diff)
parentMerge branch 'release/5.2.0-beta.2' (diff)
downloadferdium-app-f65677735b02326870ada2100b55222fa69a401d.tar.gz
ferdium-app-f65677735b02326870ada2100b55222fa69a401d.tar.zst
ferdium-app-f65677735b02326870ada2100b55222fa69a401d.zip
Merge branch 'develop' into feature/service-limit
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 349de2c9b..ee47bf6db 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -149,18 +149,7 @@ export default class ServicesStore extends Store {
149 } 149 }
150 150
151 async _showAddServiceInterface({ recipeId }) { 151 async _showAddServiceInterface({ recipeId }) {
152 const recipesStore = this.stores.recipes; 152 this.stores.router.push(`/settings/services/add/${recipeId}`);
153
154 if (recipesStore.isInstalled(recipeId)) {
155 debug(`Recipe ${recipeId} is installed`);
156 this._redirectToAddServiceRoute(recipeId);
157 } else {
158 debug(`Recipe ${recipeId} is not installed`);
159 // We access the RecipeStore action directly
160 // returns Promise instead of action
161 await this.stores.recipes._install({ recipeId });
162 this._redirectToAddServiceRoute(recipeId);
163 }
164 } 153 }
165 154
166 // Actions 155 // Actions
@@ -294,7 +283,8 @@ export default class ServicesStore extends Store {
294 gaEvent('Service', 'clear cache'); 283 gaEvent('Service', 'clear cache');
295 } 284 }
296 285
297 @action _setActive({ serviceId }) { 286 @action _setActive({ serviceId, keepActiveRoute }) {
287 if (!keepActiveRoute) this.stores.router.push('/');
298 const service = this.one(serviceId); 288 const service = this.one(serviceId);
299 289
300 this.all.forEach((s, index) => { 290 this.all.forEach((s, index) => {
@@ -520,7 +510,16 @@ export default class ServicesStore extends Store {
520 this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); 510 this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false });
521 } 511 }
522 512
523 @action _reorder({ oldIndex, newIndex }) { 513 @action _reorder(params) {
514 const { workspaces } = this.stores;
515 if (workspaces.isAnyWorkspaceActive) {
516 workspaces.reorderServicesOfActiveWorkspace(params);
517 } else {
518 this._reorderService(params);
519 }
520 }
521
522 @action _reorderService({ oldIndex, newIndex }) {
524 const showDisabledServices = this.stores.settings.all.app.showDisabledServices; 523 const showDisabledServices = this.stores.settings.all.app.showDisabledServices;
525 const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); 524 const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]);
526 const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); 525 const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]);
@@ -683,11 +682,6 @@ export default class ServicesStore extends Store {
683 } 682 }
684 683
685 // Helper 684 // Helper
686 _redirectToAddServiceRoute(recipeId) {
687 const route = `/settings/services/add/${recipeId}`;
688 this.stores.router.push(route);
689 }
690
691 _initializeServiceRecipeInWebview(serviceId) { 685 _initializeServiceRecipeInWebview(serviceId) {
692 const service = this.one(serviceId); 686 const service = this.one(serviceId);
693 687