Skip to content
Permalink
Browse files

fix(Workspaces): Service reordering within workspaces

  • Loading branch information...
DominikGuzei committed May 8, 2019
1 parent 6cdcafe commit 17f3a22e4193dfcf8dfd5cbd5aa2e812f2cbd6ae
Showing with 22 additions and 1 deletion.
  1. +12 −0 src/features/workspaces/store.js
  2. +10 −1 src/stores/ServicesStore.js
@@ -57,6 +57,10 @@ export default class WorkspacesStore extends FeatureStore {
return !this.isPremiumUpgradeRequired;
}

@computed get isAnyWorkspaceActive() {
return !!this.activeWorkspace;
}

// ========== PRIVATE PROPERTIES ========= //

_wasDrawerOpenBeforeSettingsRoute = null;
@@ -229,6 +233,14 @@ export default class WorkspacesStore extends FeatureStore {
this.actions.ui.openSettings({ path: 'workspaces' });
};

@action reorderServicesOfActiveWorkspace = async ({ oldIndex, newIndex }) => {
const { activeWorkspace } = this;
const { services } = activeWorkspace;
// Move services from the old to the new position
services.splice(newIndex, 0, services.splice(oldIndex, 1)[0]);
await updateWorkspaceRequest.execute(activeWorkspace);
};

// Reactions

_setFeatureEnabledReaction = () => {
@@ -517,7 +517,16 @@ export default class ServicesStore extends Store {
this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false });
}

@action _reorder({ oldIndex, newIndex }) {
@action _reorder(params) {
const { workspaces } = this.stores;
if (workspaces.isAnyWorkspaceActive) {
workspaces.reorderServicesOfActiveWorkspace(params);
} else {
this._reorderService(params);
}
}

@action _reorderService({ oldIndex, newIndex }) {
const showDisabledServices = this.stores.settings.all.app.showDisabledServices;
const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]);
const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]);

0 comments on commit 17f3a22

Please sign in to comment.
You can’t perform that action at this time.