diff options
author | Dominik Guzei <dominik.guzei@gmail.com> | 2019-05-22 12:42:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 12:42:25 +0200 |
commit | 6d69a41ed76ce8e3b21bd07911a13f5271009152 (patch) | |
tree | 159dd569bd133e5e1e5b2828ce64fd8bd3f14a56 /src | |
parent | Merge pull request #1426 from meetfranz/fix/announcement-not-shown-within-wor... (diff) | |
parent | fix(Workspaces): Service reordering within workspaces (diff) | |
download | ferdium-app-6d69a41ed76ce8e3b21bd07911a13f5271009152.tar.gz ferdium-app-6d69a41ed76ce8e3b21bd07911a13f5271009152.tar.zst ferdium-app-6d69a41ed76ce8e3b21bd07911a13f5271009152.zip |
Merge pull request #1425 from meetfranz/fix/workspace-services-ordering-bug
Fix 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 3d7043413..51a7f3651 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 17150a023..d63302fce 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -518,7 +518,16 @@ export default class ServicesStore extends Store { | |||
518 | this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); | 518 | this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); |
519 | } | 519 | } |
520 | 520 | ||
521 | @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 }) { | ||
522 | const showDisabledServices = this.stores.settings.all.app.showDisabledServices; | 531 | const showDisabledServices = this.stores.settings.all.app.showDisabledServices; |
523 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); | 532 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); |
524 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); | 533 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); |