diff options
author | Dominik Guzei <dominik.guzei@gmail.com> | 2019-05-08 13:57:03 +0200 |
---|---|---|
committer | Dominik Guzei <dominik.guzei@gmail.com> | 2019-05-08 13:57:03 +0200 |
commit | 17f3a22e4193dfcf8dfd5cbd5aa2e812f2cbd6ae (patch) | |
tree | 858835c95bc8022a98c932b0fa2fd793c5d6ec81 /src | |
parent | fix debug message for announcement semver logic (diff) | |
download | ferdium-app-17f3a22e4193dfcf8dfd5cbd5aa2e812f2cbd6ae.tar.gz ferdium-app-17f3a22e4193dfcf8dfd5cbd5aa2e812f2cbd6ae.tar.zst ferdium-app-17f3a22e4193dfcf8dfd5cbd5aa2e812f2cbd6ae.zip |
fix(Workspaces): Service reordering within workspaces
Diffstat (limited to 'src')
-rw-r--r-- | src/features/workspaces/store.js | 12 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 11 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index e11513d1f..e0bef8aea 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js | |||
@@ -57,6 +57,10 @@ export default class WorkspacesStore extends FeatureStore { | |||
57 | return !this.isPremiumUpgradeRequired; | 57 | return !this.isPremiumUpgradeRequired; |
58 | } | 58 | } |
59 | 59 | ||
60 | @computed get isAnyWorkspaceActive() { | ||
61 | return !!this.activeWorkspace; | ||
62 | } | ||
63 | |||
60 | // ========== PRIVATE PROPERTIES ========= // | 64 | // ========== PRIVATE PROPERTIES ========= // |
61 | 65 | ||
62 | _wasDrawerOpenBeforeSettingsRoute = null; | 66 | _wasDrawerOpenBeforeSettingsRoute = null; |
@@ -229,6 +233,14 @@ export default class WorkspacesStore extends FeatureStore { | |||
229 | this.actions.ui.openSettings({ path: 'workspaces' }); | 233 | this.actions.ui.openSettings({ path: 'workspaces' }); |
230 | }; | 234 | }; |
231 | 235 | ||
236 | @action reorderServicesOfActiveWorkspace = async ({ oldIndex, newIndex }) => { | ||
237 | const { activeWorkspace } = this; | ||
238 | const { services } = activeWorkspace; | ||
239 | // Move services from the old to the new position | ||
240 | services.splice(newIndex, 0, services.splice(oldIndex, 1)[0]); | ||
241 | await updateWorkspaceRequest.execute(activeWorkspace); | ||
242 | }; | ||
243 | |||
232 | // Reactions | 244 | // Reactions |
233 | 245 | ||
234 | _setFeatureEnabledReaction = () => { | 246 | _setFeatureEnabledReaction = () => { |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 13f929c2f..d22a943d6 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -517,7 +517,16 @@ export default class ServicesStore extends Store { | |||
517 | this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); | 517 | this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); |
518 | } | 518 | } |
519 | 519 | ||
520 | @action _reorder({ oldIndex, newIndex }) { | 520 | @action _reorder(params) { |
521 | const { workspaces } = this.stores; | ||
522 | if (workspaces.isAnyWorkspaceActive) { | ||
523 | workspaces.reorderServicesOfActiveWorkspace(params); | ||
524 | } else { | ||
525 | this._reorderService(params); | ||
526 | } | ||
527 | } | ||
528 | |||
529 | @action _reorderService({ oldIndex, newIndex }) { | ||
521 | const showDisabledServices = this.stores.settings.all.app.showDisabledServices; | 530 | const showDisabledServices = this.stores.settings.all.app.showDisabledServices; |
522 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); | 531 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); |
523 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); | 532 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); |